Skip to content

Commit d140f08

Browse files
committed
use triple-quoted strings to avoid backslashes
1 parent 4db7688 commit d140f08

File tree

1 file changed

+39
-29
lines changed

1 file changed

+39
-29
lines changed

src/Control/Monad/Eff/Exception.purs

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,50 @@ instance showError :: Show Error where
1010
show = showErrorImpl
1111

1212
foreign import showErrorImpl
13-
"function showErrorImpl(err) {\
14-
\ return err.stack ? err.stack : err.toString();\
15-
\}" :: Error -> String
13+
"""
14+
function showErrorImpl(err) {
15+
return err.stack || err.toString();
16+
}
17+
""" :: Error -> String
1618

1719
foreign import error
18-
"function error(msg) {\
19-
\ return new Error(msg);\
20-
\};" :: String -> Error
20+
"""
21+
function error(msg) {
22+
return new Error(msg);
23+
}
24+
""" :: String -> Error
2125

2226
foreign import message
23-
"function message(e) {\
24-
\ return e.message;\
25-
\}" :: Error -> String
27+
"""
28+
function message(e) {
29+
return e.message;
30+
}
31+
""" :: Error -> String
2632

2733
foreign import throwException
28-
"function throwException(e) {\
29-
\ return function() {\
30-
\ throw e;\
31-
\ };\
32-
\}" :: forall a eff. Error -> Eff (err :: Exception | eff) a
34+
"""
35+
function throwException(e) {
36+
return function() {
37+
throw e;
38+
};
39+
}
40+
""" :: forall a eff. Error -> Eff (err :: Exception | eff) a
3341

3442
foreign import catchException
35-
"function catchException(c) {\
36-
\ return function(t) {\
37-
\ return function() {\
38-
\ try {\
39-
\ return t();\
40-
\ } catch(e) {\
41-
\ if (e instanceof Error || {}.toString.call(e) === '[object Error]') {\
42-
\ return c(e)();\
43-
\ } else {\
44-
\ return c(new Error(e.toString()))();\
45-
\ }\
46-
\ }\
47-
\ };\
48-
\ };\
49-
\}" :: forall a eff. (Error -> Eff eff a) -> Eff (err :: Exception | eff) a -> Eff eff a
43+
"""
44+
function catchException(c) {
45+
return function(t) {
46+
return function() {
47+
try {
48+
return t();
49+
} catch(e) {
50+
if (e instanceof Error || Object.prototype.toString.call(e) === '[object Error]') {
51+
return c(e)();
52+
} else {
53+
return c(new Error(e.toString()))();
54+
}
55+
}
56+
};
57+
};
58+
}
59+
""" :: forall a eff. (Error -> Eff eff a) -> Eff (err :: Exception | eff) a -> Eff eff a

0 commit comments

Comments
 (0)