Skip to content

Commit 935b557

Browse files
author
Isaac Shapira
committed
spy added
1 parent ce219e5 commit 935b557

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
fprintUnsafe :: forall a. a -> a
1616

1717

18+
## Module Debug.Spy
19+
20+
### Values
21+
22+
spy :: forall a. (Show a) => a -> a
23+
24+
1825
## Module Debug.Foreign.Eval
1926

2027
### Types

src/Debug/Foreign.purs

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
module Debug.Foreign where
22

3-
import Control.Monad.Eff
4-
import Debug.Trace
3+
import Control.Monad.Eff
4+
import Debug.Trace
55

6-
foreign import fprint """
7-
function fprint(x){
8-
return function(){
6+
foreign import fprint """
7+
function fprint(x){
8+
return function(){
9+
console.log(x);
10+
return x;
11+
};
12+
}
13+
""" :: forall a e. a -> Eff (trace :: Trace | e) a
14+
15+
foreign import fprintUnsafe """
16+
function fprintUnsafe(x){
917
console.log(x);
1018
return x;
11-
};
12-
}
13-
""" :: forall a e. a -> Eff (trace :: Trace | e) a
14-
15-
foreign import fprintUnsafe """
16-
function fprintUnsafe(x){
17-
console.log(x);
18-
return x;
19-
}
20-
""" :: forall a. a -> a
21-
22-
foreign import fprintStringify """
23-
function fprintStringify(x){
24-
console.log(JSON.stringify(x));
25-
return x;
26-
}
27-
""" :: forall a e. a -> Eff (trace :: Trace | e) a
28-
29-
fspy = fprintUnsafe
19+
}
20+
""" :: forall a. a -> a
21+
22+
foreign import fprintStringify """
23+
function fprintStringify(x){
24+
console.log(JSON.stringify(x));
25+
return x;
26+
}
27+
""" :: forall a e. a -> Eff (trace :: Trace | e) a
28+
29+
fspy = fprintUnsafe
30+
31+
module Debug.Spy (spy) where
32+
33+
foreign import _spy """
34+
function _spy(s){
35+
return function(x){
36+
console.log(s);
37+
return x;
38+
};
39+
}
40+
""" :: forall a. String -> a -> a
41+
42+
spy :: forall a. (Show a) => a -> a
43+
spy x = _spy (show x) x

0 commit comments

Comments
 (0)