git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #809 from davidchambers/triple-quotes

use triple-quoted strings to avoid backslashes

commit145c4c5b6bab8273a9176542fad0db04ca16d045 authorPhil Freeman <paf31@cantab.net> dateSat 24 Jan 2015, 11:31 (12 years ago) parent19ee2bef37dcd8
14 files changed+114−69
examples/passing/BindersInFunctions.purs+5−3 examples/passing/CheckSynonymBug.purs+5−3 examples/passing/Comparisons.purs+8−6 examples/passing/DeepArrayBinder.purs+5−3 examples/passing/EmptyDataDecls.purs+12−8 examples/passing/ExternRaw.purs+20−7 examples/passing/FFI.purs+5−3 examples/passing/FunctionScope.purs+5−3 examples/passing/Functions2.purs+5−3 examples/passing/HoistError.purs+7−5 examples/passing/OperatorAssociativity.purs+15−9 examples/passing/PartialFunction.purs+10−8 examples/passing/Person.purs+5−3 examples/passing/ShadowedRename.purs+7−5
examples/passing/BindersInFunctions.purs+5−3
@@ -5,9 +5,11 @@ import Prelude
55tail = \(_:xs) -> xs
66
77foreign 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
1214main =
1315 let ts = tail [1, 2, 3] in
examples/passing/CheckSynonymBug.purs+5−3
@@ -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+8−6
@@ -6,12 +6,14 @@ import Debug.Trace
66foreign import data Assert :: !
77
88foreign 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
1618main = do
1719 assert (1 < 2)
examples/passing/DeepArrayBinder.purs+5−3
@@ -7,9 +7,11 @@ match2 (x : y : xs) = x * y + match2 xs
77match2 _ = 0
88
99foreign 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
1416main = case match2 [1, 2, 3, 4, 5, 6, 7, 8, 9] of
1517 100 -> Debug.Trace.trace "Done"
examples/passing/EmptyDataDecls.purs+12−8
@@ -11,19 +11,23 @@ nil :: forall a. ArrayBox Z a
1111nil = ArrayBox []
1212
1313foreign 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
2022cons' :: forall a n. a -> ArrayBox n a -> ArrayBox (S n) a
2123cons' x (ArrayBox xs) = ArrayBox $ concat [x] xs
2224
2325foreign 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
2832main = case cons' 1 $ cons' 2 $ cons' 3 nil of
2933 ArrayBox [1, 2, 3] -> Debug.Trace.trace "Done"
examples/passing/ExternRaw.purs+20−7
@@ -1,13 +1,26 @@
11module 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
1326main = Debug.Trace.trace "Done"
examples/passing/FFI.purs+5−3
@@ -1,9 +1,11 @@
11module Main where
22
33foreign 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
810bar :: String -> String
911bar _ = foo "test"
examples/passing/FunctionScope.purs+5−3
@@ -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+5−3
@@ -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+7−5
@@ -4,11 +4,13 @@ import Control.Monad.Eff
44import Debug.Trace
55
66foreign 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
1315main = do
1416 let x = 0
examples/passing/OperatorAssociativity.purs+15−9
@@ -6,20 +6,26 @@ import Debug.Trace
66foreign import data Assert :: !
77
88foreign import assert
9− "function assert(x) { return function (desc) {\
10− \ return function () {\
11− \ if (!x) throw new Error('assertion (' + desc + ') failed');\
12− \ return {};\
13− \ };\
14− \};};" :: forall e. Boolean -> String -> Eff (assert :: Assert | e) Unit
9+ """
10+ function assert(x) {
11+ return function(desc) {
12+ return function() {
13+ if (!x) throw new Error('assertion (' + desc + ') failed');
14+ return {};
15+ };
16+ };
17+ }
18+ """ :: forall e. Boolean -> String -> Eff (assert :: Assert | e) Unit
1519
1620bug :: Number -> Number -> Number
1721bug a b = 0 - (a - b)
1822
1923foreign import explode
20− "function explode() {\
21− \ throw new Error('Assertion failed!');\
22− \}":: forall eff a. Eff eff a
24+ """
25+ function explode() {
26+ throw new Error('Assertion failed!');
27+ }
28+ """ :: forall eff a. Eff eff a
2329
2430main = do
2531 assert (bug 0 2 == 2) "bug 0 2 == 2"
examples/passing/PartialFunction.purs+10−8
@@ -1,14 +1,16 @@
11module Main where
22
33foreign import testError
4− "function testError(f) {\
5− \ try {\
6− \ return f();\
7− \ } catch (e) {\
8− \ if (e instanceof Error) return 'success';\
9− \ throw new Error('Pattern match failure is not Error');\
10− \ }\
11− \}" :: (Unit -> Number) -> String
4+ """
5+ function testError(f) {
6+ try {
7+ return f();
8+ } catch (e) {
9+ if (e instanceof Error) return 'success';
10+ throw new Error('Pattern match failure is not Error');
11+ }
12+ }
13+ """ :: (Unit -> Number) -> String
1214
1315fn :: Number -> Number
1416fn 0 = 0
examples/passing/Person.purs+5−3
@@ -5,9 +5,11 @@ module Main where
55 data Person = Person { name :: String, age :: Number }
66
77 foreign import itoa
8− "function itoa(n) {\
9− \ return n.toString();\
10− \}" :: Number -> String
8+ """
9+ function itoa(n) {
10+ return n.toString();
11+ }
12+ """ :: Number -> String
1113
1214 showPerson :: Person -> String
1315 showPerson = \p -> case p of
examples/passing/ShadowedRename.purs+7−5
@@ -4,11 +4,13 @@ import Control.Monad.Eff
44import Debug.Trace
55
66foreign import f
7− "function f(x) {\
8− \ return function () {\
9− \ if (x !== 2) throw new Error('x is not 2');\
10− \ }\
11− \}" :: forall e. Number -> Eff e Number
7+ """
8+ function f(x) {
9+ return function() {
10+ if (x !== 2) throw new Error('x is not 2');
11+ };
12+ }
13+ """ :: forall e. Number -> Eff e Number
1214
1315foo foo = let foo_1 = \_ -> foo
1416 foo_2 = foo_1 unit + 1