Skip to content

Commit 524be1a

Browse files
committed
Implementing log
1 parent 99d37d9 commit 524be1a

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

MODULE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,30 @@
363363
setPath :: forall e. String -> Location -> LocEff e String
364364

365365

366+
## Module Angular.Log
367+
368+
### Types
369+
370+
data Log :: *
371+
372+
type LogEff e = Eff (nglog :: NgLog | e) Unit
373+
374+
data NgLog :: !
375+
376+
377+
### Values
378+
379+
debug :: forall e a. a -> Log -> LogEff e
380+
381+
error :: forall e a. a -> Log -> LogEff e
382+
383+
info :: forall e a. a -> Log -> LogEff e
384+
385+
log :: forall e a. a -> Log -> LogEff e
386+
387+
warn :: forall e a. a -> Log -> LogEff e
388+
389+
366390
## Module Angular.Module
367391

368392
### Types

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var gulp = require('gulp')
66
, http = require('http')
77
, nstatic = require('node-static')
88
, config = {
9-
clean: ['dist', 'js', 'externs'],
9+
clean: ['dist', '.psci_modules'],
1010
purescript: {
1111
src: [
1212
'bower_components/purescript-*/src/**/*.purs*',

src/Angular/Log.purs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module Angular.Log
2+
( NgLog()
3+
, Log()
4+
, LogEff()
5+
, log
6+
, info
7+
, warn
8+
, error
9+
, debug
10+
) where
11+
12+
import Control.Monad.Eff
13+
import Data.Function
14+
15+
foreign import data Log :: *
16+
17+
foreign import data NgLog :: !
18+
19+
type LogEff e = Eff (nglog :: NgLog | e) Unit
20+
21+
foreign import logFn
22+
" function logFn(fn, message, $log){ \
23+
\ return function(){ \
24+
\ return $log[fn](expression); \
25+
\ }; \
26+
\ } "
27+
:: forall e a. Fn3 String a Log (LogEff e)
28+
29+
log :: forall e a. a -> Log -> LogEff e
30+
log = runFn3 logFn "log"
31+
32+
info :: forall e a. a -> Log -> LogEff e
33+
info = runFn3 logFn "info"
34+
35+
warn :: forall e a. a -> Log -> LogEff e
36+
warn = runFn3 logFn "warn"
37+
38+
error :: forall e a. a -> Log -> LogEff e
39+
error = runFn3 logFn "error"
40+
41+
debug :: forall e a. a -> Log -> LogEff e
42+
debug = runFn3 logFn "debug"

0 commit comments

Comments
 (0)