Skip to content

Commit f37dcd8

Browse files
committed
use triple-quoted strings to avoid backslashes
1 parent f5b2d4e commit f37dcd8

14 files changed

+114
-69
lines changed

examples/passing/BindersInFunctions.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import Prelude
55
tail = \(_:xs) -> xs
66

77
foreign import error
8-
"function error(msg) {\
9-
\ throw msg;\
10-
\}" :: forall a. String -> a
8+
"""
9+
function error(msg) {
10+
throw msg;
11+
}
12+
""" :: forall a. String -> a
1113

1214
main =
1315
let ts = tail [1, 2, 3] in

examples/passing/CheckSynonymBug.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ module Main where
55
type Foo a = [a]
66

77
foreign import length
8-
"function length(a) {\
9-
\ return a.length;\
10-
\}" :: forall a. [a] -> Number
8+
"""
9+
function length(a) {
10+
return a.length;
11+
}
12+
""" :: forall a. [a] -> Number
1113

1214
foo _ = length ([] :: Foo Number)
1315

examples/passing/Comparisons.purs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import Debug.Trace
66
foreign import data Assert :: !
77

88
foreign import assert
9-
"function assert(x) {\
10-
\ return function () {\
11-
\ if (!x) throw new Error('assertion failed');\
12-
\ return {};\
13-
\ };\
14-
\};" :: forall e. Boolean -> Eff (assert :: Assert | e) Unit
9+
"""
10+
function assert(x) {
11+
return function() {
12+
if (!x) throw new Error('assertion failed');
13+
return {};
14+
};
15+
}
16+
""" :: forall e. Boolean -> Eff (assert :: Assert | e) Unit
1517

1618
main = do
1719
assert (1 < 2)

examples/passing/DeepArrayBinder.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ match2 (x : y : xs) = x * y + match2 xs
77
match2 _ = 0
88

99
foreign import explode
10-
"function explode() {\
11-
\ throw new Error('Incorrect result');\
12-
\}" :: forall eff a. Eff eff a
10+
"""
11+
function explode() {
12+
throw new Error('Incorrect result');
13+
}
14+
""" :: forall eff a. Eff eff a
1315

1416
main = case match2 [1, 2, 3, 4, 5, 6, 7, 8, 9] of
1517
100 -> Debug.Trace.trace "Done"

examples/passing/EmptyDataDecls.purs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@ nil :: forall a. ArrayBox Z a
1111
nil = ArrayBox []
1212

1313
foreign import concat
14-
"function concat(l1) {\
15-
\ return function (l2) {\
16-
\ return l1.concat(l2);\
17-
\ };\
18-
\}" :: forall a. [a] -> [a] -> [a]
14+
"""
15+
function concat(l1) {
16+
return function(l2) {
17+
return l1.concat(l2);
18+
};
19+
}
20+
""" :: forall a. [a] -> [a] -> [a]
1921

2022
cons' :: forall a n. a -> ArrayBox n a -> ArrayBox (S n) a
2123
cons' x (ArrayBox xs) = ArrayBox $ concat [x] xs
2224

2325
foreign import error
24-
"function error(msg) {\
25-
\ throw msg;\
26-
\}" :: forall a. String -> a
26+
"""
27+
function error(msg) {
28+
throw msg;
29+
}
30+
""" :: forall a. String -> a
2731

2832
main = case cons' 1 $ cons' 2 $ cons' 3 nil of
2933
ArrayBox [1, 2, 3] -> Debug.Trace.trace "Done"

examples/passing/ExternRaw.purs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
module Main where
22

3-
foreign import first "function first(xs) { return xs[0]; }" :: forall a. [a] -> a
3+
foreign import first
4+
"""
5+
function first(xs) {
6+
return xs[0];
7+
}
8+
""" :: forall a. [a] -> a
49

5-
foreign import loop "function loop() { while (true) {} }" :: forall a. a
10+
foreign import loop
11+
"""
12+
function loop() {
13+
while (true) {}
14+
}
15+
""" :: forall a. a
616

7-
foreign import concat "function concat(xs) { \
8-
\ return function(ys) { \
9-
\ return xs.concat(ys); \
10-
\ };\
11-
\}" :: forall a. [a] -> [a] -> [a]
17+
foreign import concat
18+
"""
19+
function concat(xs) {
20+
return function(ys) {
21+
return xs.concat(ys);
22+
};
23+
}
24+
""" :: forall a. [a] -> [a] -> [a]
1225

1326
main = Debug.Trace.trace "Done"

examples/passing/FFI.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module Main where
22

33
foreign import foo
4-
"function foo(s) {\
5-
\ return s;\
6-
\}" :: String -> String
4+
"""
5+
function foo(s) {
6+
return s;
7+
}
8+
""" :: String -> String
79

810
bar :: String -> String
911
bar _ = foo "test"

examples/passing/FunctionScope.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ module Main where
66
mkValue id = id
77

88
foreign import error
9-
"function error(msg) {\
10-
\ throw msg;\
11-
\}" :: forall a. String -> a
9+
"""
10+
function error(msg) {
11+
throw msg;
12+
}
13+
""" :: forall a. String -> a
1214

1315
main = do
1416
let value = mkValue 1

examples/passing/Functions2.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ module Main where
66
test = \const _ -> const
77

88
foreign import error
9-
"function error(msg) {\
10-
\ throw msg;\
11-
\}" :: forall a. String -> a
9+
"""
10+
function error(msg) {
11+
throw msg;
12+
}
13+
""" :: forall a. String -> a
1214

1315
main = do
1416
let value = test "Done" {}

examples/passing/HoistError.purs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import Control.Monad.Eff
44
import Debug.Trace
55

66
foreign import f
7-
"function f(x) {\
8-
\ return function () {\
9-
\ if (x !== 0) throw new Error('x is not 0');\
10-
\ }\
11-
\}" :: forall e. Number -> Eff e Number
7+
"""
8+
function f(x) {
9+
return function() {
10+
if (x !== 0) throw new Error('x is not 0');
11+
};
12+
}
13+
""" :: forall e. Number -> Eff e Number
1214

1315
main = do
1416
let x = 0

0 commit comments

Comments
 (0)