git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix some examples
commitd1d5cc2cffe059303a702cc5ee2948de950d7be9 authorPhil Freeman <paf31@cantab.net> dateSun 29 Dec 2013, 19:07 (13 years ago) parentea3e968
46 files changed+618−541
examples/failing/Arrays.purs+3−1 examples/failing/Import.purs+3−1 examples/failing/KindError.purs+3−1 examples/failing/LocalVars.purs+6−3 examples/failing/PatternScope.purs+9−6 examples/failing/Rank2Types.purs+4−2 examples/failing/ReadShow.purs+5−3 examples/failing/SkolemEscape.purs+4−2 examples/failing/TypeError.purs+3−3 examples/passing/Arrays.purs+17−15 examples/passing/Assign.purs+8−6 examples/passing/Auto.purs+8−6 examples/passing/Church.purs+10−8 examples/passing/Conditional.purs+5−3 examples/passing/Cons.purs+6−4 examples/passing/Console.purs+17−15 examples/passing/ExternData.purs+9−7 examples/passing/FFI.purs+5−3 examples/passing/Foreach.purs+8−6 examples/passing/Functions.purs+8−6 examples/passing/Guards.purs+9−7 examples/passing/IfThenElse.purs+30−28 examples/passing/List.purs+17−15 examples/passing/Match.purs+4−2 examples/passing/Maybe.purs+8−6 examples/passing/MethodCall.purs+7−5 examples/passing/Monad.purs+21−19 examples/passing/NameResolution.purs−15 examples/passing/NamedPatterns.purs+5−3 examples/passing/Nested.purs+4−2 examples/passing/ObjectUpdate.purs+12−10 examples/passing/Objects.purs+9−7 examples/passing/Operators.purs+27−25 examples/passing/Patterns.purs+20−18 examples/passing/Person.purs+8−6 examples/passing/Rank2Data.purs+18−16 examples/passing/Rank2Types.purs+13−11 examples/passing/Recursion.purs+6−4 examples/passing/TopLevelCase.purs+11−9 examples/passing/TypeDecl.purs+13−11 examples/passing/TypeSynonyms.purs+26−24 examples/passing/iota.purs+5−3 examples/passing/s.purs+3−1 libraries/jquery/example.purs+10−6 libraries/jquery/jquery.purs+18−16 libraries/prelude/prelude.purs+173−171
examples/failing/Arrays.purs+3−1
@@ -1 +1,3 @@
1−test = \arr -> arr !! (0 !! 0)
1+module Arrays where
2+
3+ test = \arr -> arr !! (0 !! 0)
examples/failing/Import.purs+3−1
@@ -1 +1,3 @@
1−import UndefinedModule
1+module Module where
2+
3+ import UndefinedModule
examples/failing/KindError.purs+3−1
@@ -1 +1,3 @@
1−data KindError f a = One f | Two f a
1+module KindError where
2+
3+ data KindError f a = One f | Two f a
examples/failing/LocalVars.purs+6−3
@@ -1,3 +1,6 @@
1−bad = \x -> do
2− x = x + 1
3− return x
1+module LocalVars where
2+
3+ bad = \x -> {
4+ x = x + 1;
5+ return x;
6+ }
examples/failing/PatternScope.purs+9−6
@@ -1,7 +1,10 @@
1−-- Pattern scope doesn't leak
2−foobar = \x -> do
3− var y = case x of
4− z | z % 2 == 0 -> 1
5− _ -> 2
6− return z
1+module PatternScope where
2+
3+ -- Pattern scope doesn't leak
4+ foobar = \x -> {
5+ var y = case x of
6+ z | z % 2 == 0 -> 1
7+ _ -> 2;
8+ return z;
9+ }
710
examples/failing/Rank2Types.purs+4−2
@@ -1,3 +1,5 @@
1−foreign import test :: (forall a. a -> a) -> Number
1+module Rank2Types where
22
3−test1 = test (\n -> n + 1)
3+ foreign import test :: (forall a. a -> a) -> Number
4+
5+ test1 = test (\n -> n + 1)
examples/failing/ReadShow.purs+5−3
@@ -1,5 +1,7 @@
1−foreign import read :: forall a. String -> a
1+module ReadShow where
22
3−foreign import show :: forall a. a -> String
3+ foreign import read :: forall a. String -> a
44
5−test = \x -> show (read x)
5+ foreign import show :: forall a. a -> String
6+
7+ test = \x -> show (read x)
examples/failing/SkolemEscape.purs+4−2
@@ -1,3 +1,5 @@
1−foreign import foo :: (forall a. a -> a) -> Number
1+module SkolemEscape where
22
3−test = \x -> foo x
3+ foreign import foo :: (forall a. a -> a) -> Number
4+
5+ test = \x -> foo x
examples/failing/TypeError.purs+3−3
@@ -1,3 +1,3 @@
1−test = do
2− var x = 0
3− return x ++ "A"
1+module TypeError where
2+
3+ test = x ++ "A"
examples/passing/Arrays.purs+17−15
@@ -1,20 +1,22 @@
1−test1 = \arr -> arr !! 0 + arr !! 1
1+module Arrays where
22
3−test2 = \arr -> case arr of
4− [x, y] -> x + y
5− [x] -> x
6− [] -> 0
7− (x : y : _) -> x + y
3+ test1 = \arr -> arr !! 0 + arr !! 1
84
9−data Tree = One Number | Some [Tree]
5+ test2 = \arr -> case arr of
6+ [x, y] -> x + y
7+ [x] -> x
8+ [] -> 0
9+ (x : y : _) -> x + y
1010
11−test3 = \(tree, sum) -> case tree of
12− One n -> n
13− Some (n1 : n2 : rest) -> test3(n1, sum) * 10 + test3(n2, sum) * 5 + sum(rest)
11+ data Tree = One Number | Some [Tree]
1412
15−test4 = \arr -> case arr of
16− [] -> 0
17− [_] -> 0
18− x : y : xs -> x * y + test4 xs
19−
13+ test3 = \(tree, sum) -> case tree of
14+ One n -> n
15+ Some (n1 : n2 : rest) -> test3(n1, sum) * 10 + test3(n2, sum) * 5 + sum(rest)
16+
17+ test4 = \arr -> case arr of
18+ [] -> 0
19+ [_] -> 0
20+ x : y : xs -> x * y + test4 xs
21+
2022
examples/passing/Assign.purs+8−6
@@ -1,7 +1,9 @@
1−sum = \n -> {
2− var x = 0;
3− for (i <- 0 until n) {
4− x = x + i;
1+module Assign where
2+
3+ sum = \n -> {
4+ var x = 0;
5+ for (i <- 0 until n) {
6+ x = x + i;
7+ }
8+ return x;
59 }
6− return x;
7− }
examples/passing/Auto.purs+8−6
@@ -1,9 +1,11 @@
1−data Auto s i o = Auto { state :: s, step :: s -> i -> o }
1+module Auto where
22
3−type SomeAuto i o = forall r. (forall s. Auto s i o -> r) -> r
3+ data Auto s i o = Auto { state :: s, step :: s -> i -> o }
44
5−exists :: forall s i o. s -> (s -> i -> o) -> SomeAuto i o
6−exists = \state step f -> f (Auto { state: state, step: step })
5+ type SomeAuto i o = forall r. (forall s. Auto s i o -> r) -> r
76
8−run :: forall i o. SomeAuto i o -> i -> o
9−run = \s i -> s (\a -> case a of Auto a -> a.step a.state i)
7+ exists :: forall s i o. s -> (s -> i -> o) -> SomeAuto i o
8+ exists = \state step f -> f (Auto { state: state, step: step })
9+
10+ run :: forall i o. SomeAuto i o -> i -> o
11+ run = \s i -> s (\a -> case a of Auto a -> a.step a.state i)
examples/passing/Church.purs+10−8
@@ -1,12 +1,14 @@
1−type List a = forall r. r -> (a -> r -> r) -> r
1+module Church where
22
3−empty :: forall a. List a
4−empty = \r f -> r
3+ type List a = forall r. r -> (a -> r -> r) -> r
54
6−cons :: forall a. a -> List a -> List a
7−cons = \a l r f -> f a (l r f)
5+ empty :: forall a. List a
6+ empty = \r f -> r
87
9−append :: forall a. List a -> List a -> List a
10−append = \l1 l2 r f -> l2 (l1 r f) f
8+ cons :: forall a. a -> List a -> List a
9+ cons = \a l r f -> f a (l r f)
1110
12−test = append (cons 1 empty) (cons 2 empty)
11+ append :: forall a. List a -> List a -> List a
12+ append = \l1 l2 r f -> l2 (l1 r f) f
13+
14+ test = append (cons 1 empty) (cons 2 empty)
examples/passing/Conditional.purs+5−3
@@ -1,5 +1,7 @@
1−fns = \f -> if f true then f else \x -> x
1+module Conditional where
22
3−bin = \x -> if x && !x then x else x
3+ fns = \f -> if f true then f else \x -> x
44
5−not = \x -> if x then false else true
5+ bin = \x -> if x && !x then x else x
6+
7+ not = \x -> if x then false else true
examples/passing/Cons.purs+6−4
@@ -1,7 +1,9 @@
1−infixr 6 :
1+module Cons where
22
3−foreign import (:) :: forall a. a -> [a] -> [a]
3+ infixr 6 :
44
5−test1 = \xs -> 1 : xs
5+ foreign import (:) :: forall a. a -> [a] -> [a]
66
7−test2 = 1 : 2 : 3 : []
7+ test1 = \xs -> 1 : xs
8+
9+ test2 = 1 : 2 : 3 : []
examples/passing/Console.purs+17−15
@@ -1,23 +1,25 @@
1−foreign import data IO :: * -> *
1+module Console where
22
3−foreign import ret :: forall a. a -> IO a
3+ foreign import data IO :: * -> *
44
5−foreign import (>>=) :: forall a b. IO a -> (a -> IO b) -> IO b
5+ foreign import ret :: forall a. a -> IO a
66
7−(*>) = \a -> \b -> a >>= \x -> b
7+ foreign import (>>=) :: forall a b. IO a -> (a -> IO b) -> IO b
88
9−foreign import putStrLn :: String -> IO {}
9+ (*>) = \a -> \b -> a >>= \x -> b
1010
11−replicateM_ :: forall a. Number -> IO a -> IO {}
12−replicateM_ = \n -> \x ->
13− {
14− var io = ret {};
15− for (i <- 0 until n)
16− {
17− io = x *> io;
11+ foreign import putStrLn :: String -> IO {}
12+
13+ replicateM_ :: forall a. Number -> IO a -> IO {}
14+ replicateM_ = \n -> \x ->
15+ {
16+ var io = ret {};
17+ for (i <- 0 until n)
18+ {
19+ io = x *> io;
20+ }
21+ return io;
1822 }
19− return io;
20− }
2123
22−main = replicateM_ 10 (putStrLn "Hello World!")
24+ main = replicateM_ 10 (putStrLn "Hello World!")
2325
examples/passing/ExternData.purs+9−7
@@ -1,13 +1,15 @@
1−foreign import data IO :: * -> *
1+module ExternData where
22
3−foreign import fmap :: forall a b. IO a -> (a -> b) -> IO b
3+ foreign import data IO :: * -> *
44
5−foreign import ret :: forall a. a -> IO a
5+ foreign import fmap :: forall a b. IO a -> (a -> b) -> IO b
66
7−foreign import bind :: forall a b. IO a -> (a -> IO b) -> IO b
7+ foreign import ret :: forall a. a -> IO a
88
9−foreign import showMessage :: String -> IO { }
9+ foreign import bind :: forall a b. IO a -> (a -> IO b) -> IO b
1010
11−foreign import prompt :: IO String
11+ foreign import showMessage :: String -> IO { }
1212
13−main = prompt `bind` \s -> showMessage s
13+ foreign import prompt :: IO String
14+
15+ main = prompt `bind` \s -> showMessage s
examples/passing/FFI.purs+5−3
@@ -1,5 +1,7 @@
1−foreign import foo :: String -> String
1+module FFI where
22
3−bar :: String -> String
3+ foreign import foo :: String -> String
44
5−bar = \x -> foo (x ++ "bar")
5+ bar :: String -> String
6+
7+ bar = \x -> foo (x ++ "bar")
examples/passing/Foreach.purs+8−6
@@ -1,7 +1,9 @@
1−sum = \ns -> {
2− var total = 0;
3− foreach (n in ns) {
4− total = total + n;
1+module Foreach where
2+
3+ sum = \ns -> {
4+ var total = 0;
5+ foreach (n in ns) {
6+ total = total + n;
7+ }
8+ return total;
59 }
6− return total;
7− }
examples/passing/Functions.purs+8−6
@@ -1,11 +1,13 @@
1−test1 = \ -> 0
1+module Functions where
22
3−test2 = \() -> 0
3+ test1 = \ -> 0
44
5−test3 = \a (b, c) d -> a + b + c + d
5+ test2 = \() -> 0
66
7−test4 = \(a) -> a
7+ test3 = \a (b, c) d -> a + b + c + d
88
9−test5 = \(%%) -> 1 %% 2
9+ test4 = \(a) -> a
1010
11−test6 = \((+++), (***)) -> 1 +++ 2 *** 3
11+ test5 = \(%%) -> 1 %% 2
12+
13+ test6 = \((+++), (***)) -> 1 +++ 2 *** 3
examples/passing/Guards.purs+9−7
@@ -1,8 +1,10 @@
1−collatz = \x -> case x of
2− y | y % 2 == 0 -> y / 2
3− y -> y * 3 + 1
1+module Guards where
42
5−-- Guards have access to current scope
6−collatz2 = \x y -> case x of
7− z | y > 0 -> z / 2
8− z -> z * 3 + 1
3+ collatz = \x -> case x of
4+ y | y % 2 == 0 -> y / 2
5+ y -> y * 3 + 1
6+
7+ -- Guards have access to current scope
8+ collatz2 = \x y -> case x of
9+ z | y > 0 -> z / 2
10+ z -> z * 3 + 1
examples/passing/IfThenElse.purs+30−28
@@ -1,34 +1,36 @@
1−testIf =
2− {
3− var x = 0;
4− if (x == 0) {
5− x = x + 1;
6− }
7− return x;
8− }
1+module IfThenElse where
92
10−testIfElse =
11− {
12− var x = 0;
13− if (x == 0) {
14− x = x + 1;
15− } else {
16− x = x - 1;
3+ testIf =
4+ {
5+ var x = 0;
6+ if (x == 0) {
7+ x = x + 1;
8+ }
9+ return x;
1710 }
18− return x;
19− }
2011
21−testIfElseIf = \x ->
22− {
23− var y = x;
24− while (y > 1) {
25− if (y % 3 == 0) {
26− y = y / 3;
27− } else if (y % 3 == 1) {
28− y = (y - 1) % 3;
12+ testIfElse =
13+ {
14+ var x = 0;
15+ if (x == 0) {
16+ x = x + 1;
2917 } else {
30− y = y * 4 + 1;
18+ x = x - 1;
19+ }
20+ return x;
21+ }
22+
23+ testIfElseIf = \x ->
24+ {
25+ var y = x;
26+ while (y > 1) {
27+ if (y % 3 == 0) {
28+ y = y / 3;
29+ } else if (y % 3 == 1) {
30+ y = (y - 1) % 3;
31+ } else {
32+ y = y * 4 + 1;
33+ }
3134 }
35+ return y;
3236 }
33− return y;
34− }
examples/passing/List.purs+17−15
@@ -1,19 +1,21 @@
1−data List a
2− = Nil
3− | Cons
4− { head :: a
5− , tail :: List a
6− }
1+module List where
2+
3+ data List a
4+ = Nil
5+ | Cons
6+ { head :: a
7+ , tail :: List a
8+ }
79
8−isNull Nil = true
9−isNull _ = false
10+ isNull Nil = true
11+ isNull _ = false
1012
11−concat Nil l2 = l2
12−concat (Cons x) l2 = Cons
13− { head: x.head
14− , tail: concat x.tail l2
15− }
13+ concat Nil l2 = l2
14+ concat (Cons x) l2 = Cons
15+ { head: x.head
16+ , tail: concat x.tail l2
17+ }
1618
17−flatten Nil = Nil
18−flatten (Cons cons) = concat cons.head (flatten cons.tail)
19+ flatten Nil = Nil
20+ flatten (Cons cons) = concat cons.head (flatten cons.tail)
1921
examples/passing/Match.purs+4−2
@@ -1,3 +1,5 @@
1−data Foo a = Foo
1+module Match where
22
3−foo = \f -> case f of Foo -> "foo"
3+ data Foo a = Foo
4+
5+ foo = \f -> case f of Foo -> "foo"
examples/passing/Maybe.purs+8−6
@@ -1,9 +1,11 @@
1−data Maybe a = Nothing | Just a
1+module Maybe where
22
3−maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
4−maybe b _ Nothing = b
5−maybe _ f (Just a) = f a
3+ data Maybe a = Nothing | Just a
64
7−fmap m f = maybe Nothing (\a -> Just (f a)) m
5+ maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
6+ maybe b _ Nothing = b
7+ maybe _ f (Just a) = f a
88
9−bind m f = maybe Nothing f m
9+ fmap m f = maybe Nothing (\a -> Just (f a)) m
10+
11+ bind m f = maybe Nothing f m
examples/passing/MethodCall.purs+7−5
@@ -1,6 +1,8 @@
1−foreign import foo :: () -> {}
1+module MethodCall where
22
3−test = {
4− foo();
5− return 0;
6− }
3+ foreign import foo :: () -> {}
4+
5+ test = {
6+ foo();
7+ return 0;
8+ }
examples/passing/Monad.purs+21−19
@@ -1,26 +1,28 @@
1−type Monad m = { ret :: forall a. a -> m a
2− , bind :: forall a b. m a -> (a -> m b) -> m b }
1+module Monad where
32
4−data Id a = Id a
3+ type Monad m = { ret :: forall a. a -> m a
4+ , bind :: forall a b. m a -> (a -> m b) -> m b }
55
6−id :: Monad Id
7−id = { ret : Id
8− , bind : \ma f -> case ma of Id a -> f a }
6+ data Id a = Id a
97
10−data Maybe a = Nothing | Just a
8+ id :: Monad Id
9+ id = { ret : Id
10+ , bind : \ma f -> case ma of Id a -> f a }
1111
12−maybe :: Monad Maybe
13−maybe = { ret : Just
14− , bind : \ma f -> case ma of
15− Nothing -> Nothing
16− Just a -> f a
17− }
12+ data Maybe a = Nothing | Just a
1813
19−test :: forall m. Monad m -> m Number
20−test = \m -> m.bind (m.ret 1) (\n1 ->
21− m.bind (m.ret "Test") (\n2 ->
22− m.ret n1))
14+ maybe :: Monad Maybe
15+ maybe = { ret : Just
16+ , bind : \ma f -> case ma of
17+ Nothing -> Nothing
18+ Just a -> f a
19+ }
2320
24−test1 = test id
21+ test :: forall m. Monad m -> m Number
22+ test = \m -> m.bind (m.ret 1) (\n1 ->
23+ m.bind (m.ret "Test") (\n2 ->
24+ m.ret n1))
2525
26−test2 = test maybe
26+ test1 = test id
27+
28+ test2 = test maybe
examples/passing/NameResolution.pursdeleted−15
@@ -1,15 +0,0 @@
1−foo = \x -> x
2−
3−module A where
4− bar = foo
5−
6− module B where
7−
8− abc = foo
9− xyz = bar
10−
11− foo = \x y -> x
12−
13− baz = foo
14−
15− abc = A.B.abc
examples/passing/NamedPatterns.purs+5−3
@@ -1,3 +1,5 @@
1−foo = \x -> case x of
2− y@{ foo = "Foo" } -> y
3− y -> y
1+module NamedPatterns where
2+
3+ foo = \x -> case x of
4+ y@{ foo = "Foo" } -> y
5+ y -> y
examples/passing/Nested.purs+4−2
@@ -1,3 +1,5 @@
1−data Extend r a = Extend { prev :: r a, next :: a }
1+module Nested where
22
3−data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
3+ data Extend r a = Extend { prev :: r a, next :: a }
4+
5+ data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
examples/passing/ObjectUpdate.purs+12−10
@@ -1,14 +1,16 @@
1−update1 = \o -> o { foo = "Foo" }
1+module ObjectUpdate where
22
3−update2 :: forall r. { foo :: String | r } -> { foo :: String | r }
4−update2 = \o -> o { foo = "Foo" }
3+ update1 = \o -> o { foo = "Foo" }
54
6−replace = \o -> case o of
7− { foo = "Foo" } -> o { foo = "Bar" }
8− { foo = "Bar" } -> o { bar = "Baz" }
9− o -> o
5+ update2 :: forall r. { foo :: String | r } -> { foo :: String | r }
6+ update2 = \o -> o { foo = "Foo" }
107
11−polyUpdate :: forall a r. { foo :: a | r } -> { foo :: String | r }
12−polyUpdate = \o -> o { foo = "Foo" }
8+ replace = \o -> case o of
9+ { foo = "Foo" } -> o { foo = "Bar" }
10+ { foo = "Bar" } -> o { bar = "Baz" }
11+ o -> o
1312
14−inferPolyUpdate = \o -> o { foo = "Foo" }
13+ polyUpdate :: forall a r. { foo :: a | r } -> { foo :: String | r }
14+ polyUpdate = \o -> o { foo = "Foo" }
15+
16+ inferPolyUpdate = \o -> o { foo = "Foo" }
examples/passing/Objects.purs+9−7
@@ -1,12 +1,14 @@
1−test = \x -> x.foo + x.bar
1+module Objects where
22
3−append = \o -> { foo: o.foo, bar: 1 }
3+ test = \x -> x.foo + x.bar
44
5−apTest = append({foo : "Foo", baz: "Baz"})
5+ append = \o -> { foo: o.foo, bar: 1 }
66
7−f = (\a -> a.b.c) { b: { c: 1, d: "Hello" }, e: "World" }
7+ apTest = append({foo : "Foo", baz: "Baz"})
88
9−g = (\a -> a.f { x: 1, y: "y" }) { f: \o -> o.x + 1 }
9+ f = (\a -> a.b.c) { b: { c: 1, d: "Hello" }, e: "World" }
1010
11−typed :: { foo :: Number }
12−typed = { foo: 0 }
11+ g = (\a -> a.f { x: 1, y: "y" }) { f: \o -> o.x + 1 }
12+
13+ typed :: { foo :: Number }
14+ typed = { foo: 0 }
examples/passing/Operators.purs+27−25
@@ -1,42 +1,44 @@
1−test1 = \(x, y, z) -> x * y + z(x)(y)
1+module Operators1 where
22
3−test2 = (\x -> x.foo false) { foo : \_ -> 1 }
3+ (@@) :: forall a b. (a -> b) -> a -> b
4+ (@@) = \f x -> f x
45
5−test3 = (\(x, y) -> x)(1 + 2 * (1 + 2), true && (false || false))
6+ foo :: String -> String
7+ foo = \s -> s
8+
9+ test8 = foo @@ "Hello World"
610
7−k = \x -> \y -> x
11+ bar = \s1 s2 -> s1 ++ s2
812
9−test4 = 1 `k` 2
13+module Operators2 where
1014
11−infixl 5 %%
15+ test1 = \(x, y, z) -> x * y + z(x)(y)
1216
13−(%%) = \x -> \y -> x * y + y
17+ test2 = (\x -> x.foo false) { foo : \_ -> 1 }
1418
15−test5 = 1 %% 2 %% 3
19+ test3 = (\(x, y) -> x)(1 + 2 * (1 + 2), true && (false || false))
1620
17−test6 = ((\x -> x) `k` 2) 3
21+ k = \x -> \y -> x
1822
19−(<>) = \s1 -> \s2 -> s1 ++ s2
23+ test4 = 1 `k` 2
2024
21−test7 = "Hello" <> "World!"
25+ infixl 5 %%
2226
23−module Ops where
24−
25− (@@) :: forall a b. (a -> b) -> a -> b
26− (@@) = \f x -> f x
27+ (%%) = \x -> \y -> x * y + y
2728
28− foo :: String -> String
29− foo = \s -> s
30−
31− test8 = foo @@ "Hello World"
29+ test5 = 1 %% 2 %% 3
3230
33− bar = \s1 s2 -> s1 ++ s2
31+ test6 = ((\x -> x) `k` 2) 3
32+
33+ (<>) = \s1 -> \s2 -> s1 ++ s2
34+
35+ test7 = "Hello" <> "World!"
3436
35−test9 = Ops.foo Ops.@@ "Hello World"
37+ test9 = Operators1.foo Operators1.@@ "Hello World"
3638
37−test10 = "Hello" `Ops.bar` "World"
39+ test10 = "Hello" `Operators1.bar` "World"
3840
39−(...) :: forall a. [a] -> [a] -> [a]
40−(...) = \as -> \bs -> as
41+ (...) :: forall a. [a] -> [a] -> [a]
42+ (...) = \as -> \bs -> as
4143
42−test11 = [1, 2, 3] ... [4, 5, 6]
44+ test11 = [1, 2, 3] ... [4, 5, 6]
examples/passing/Patterns.purs+20−18
@@ -1,23 +1,25 @@
1−test = \x -> case x of
2− { str = "Foo", bool = true } -> true
3− { str = "Bar", bool = b } -> b
4− _ -> false
1+module Patterns where
52
6−f = \o -> case o of
7− { foo = "Foo" } -> o.bar
8− _ -> 0
3+ test = \x -> case x of
4+ { str = "Foo", bool = true } -> true
5+ { str = "Bar", bool = b } -> b
6+ _ -> false
97
10−g = \o -> case o of
11− { arr = [x : xs], take = "car" } -> x
12− { arr = [_, x : xs], take = "cadr" } -> x
13− _ -> 0
8+ f = \o -> case o of
9+ { foo = "Foo" } -> o.bar
10+ _ -> 0
1411
12+ g = \o -> case o of
13+ { arr = [x : xs], take = "car" } -> x
14+ { arr = [_, x : xs], take = "cadr" } -> x
15+ _ -> 0
1516
16−h = \o -> case o of
17− a@[_,_,_] -> a
18− _ -> []
1917
20−isDesc = \o -> case o of
21− [x, y] | x > y -> true
22− _ -> false
23−
18+ h = \o -> case o of
19+ a@[_,_,_] -> a
20+ _ -> []
21+
22+ isDesc = \o -> case o of
23+ [x, y] | x > y -> true
24+ _ -> false
25+
examples/passing/Person.purs+8−6
@@ -1,7 +1,9 @@
1−data Person = Person { name :: String, age :: Number }
1+module Person where
22
3−foreign import itoa :: Number -> String
4−
5−showPerson :: Person -> String
6−showPerson = \p -> case p of
7− Person o -> o.name ++ ", aged " ++ itoa(o.age)
3+ data Person = Person { name :: String, age :: Number }
4+
5+ foreign import itoa :: Number -> String
6+
7+ showPerson :: Person -> String
8+ showPerson = \p -> case p of
9+ Person o -> o.name ++ ", aged " ++ itoa(o.age)
examples/passing/Rank2Data.purs+18−16
@@ -1,23 +1,25 @@
1−data Id = Id forall a. a -> a
1+module Rank2Data where
22
3−runId = \id a -> case id of
4− Id f -> f a
3+ data Id = Id forall a. a -> a
54
6−data Nat = Nat forall r. r -> (r -> r) -> r
5+ runId = \id a -> case id of
6+ Id f -> f a
77
8−runNat = \nat -> case nat of
9− Nat f -> f 0 (\n -> n + 1)
8+ data Nat = Nat forall r. r -> (r -> r) -> r
109
11−zero = Nat (\zero _ -> zero)
10+ runNat = \nat -> case nat of
11+ Nat f -> f 0 (\n -> n + 1)
1212
13−succ = \n -> case n of
14− Nat f -> Nat (\zero succ -> succ (f zero succ))
13+ zero = Nat (\zero _ -> zero)
1514
16−add = \n m -> case n of
17− Nat f -> case m of
18− Nat g -> Nat (\zero succ -> g (f zero succ) succ)
15+ succ = \n -> case n of
16+ Nat f -> Nat (\zero succ -> succ (f zero succ))
1917
20−one = succ zero
21−two = succ zero
22−four = add two two
23−fourNumber = runNat four
18+ add = \n m -> case n of
19+ Nat f -> case m of
20+ Nat g -> Nat (\zero succ -> g (f zero succ) succ)
21+
22+ one = succ zero
23+ two = succ zero
24+ four = add two two
25+ fourNumber = runNat four
examples/passing/Rank2Types.purs+13−11
@@ -1,17 +1,19 @@
1−test1 :: (forall a. (a -> a)) -> Number
2−test1 = \f -> f 0
1+module Rank2Types where
32
4−foreign import data ST :: * -> * -> *
3+ test1 :: (forall a. (a -> a)) -> Number
4+ test1 = \f -> f 0
55
6−foreign import runST :: forall a. (forall s. ST s a) -> a
6+ foreign import data ST :: * -> * -> *
77
8−foreign import exampleST :: forall s. ST s Number
8+ foreign import runST :: forall a. (forall s. ST s a) -> a
99
10−testST = runST exampleST
10+ foreign import exampleST :: forall s. ST s Number
1111
12−foreign import push :: forall el. el -> [el] -> [el]
12+ testST = runST exampleST
1313
14−replicateM :: forall m a. (forall a. a -> m a) -> (forall a b. m a -> (a -> m b) -> m b) -> Number -> m a -> m [a]
15−replicateM = \ret bind n m -> case n of
16− 0 -> ret []
17− n -> bind m (\x -> bind (replicateM ret bind (n - 1) m) (\xs -> ret (push x xs)))
14+ foreign import push :: forall el. el -> [el] -> [el]
15+
16+ replicateM :: forall m a. (forall a. a -> m a) -> (forall a b. m a -> (a -> m b) -> m b) -> Number -> m a -> m [a]
17+ replicateM = \ret bind n m -> case n of
18+ 0 -> ret []
19+ n -> bind m (\x -> bind (replicateM ret bind (n - 1) m) (\xs -> ret (push x xs)))
examples/passing/Recursion.purs+6−4
@@ -1,4 +1,6 @@
1−fib = \n -> case n of
2− 0 -> 1
3− 1 -> 1
4− n -> fib (n - 1) + fib (n - 2)
1+module Recursion where
2+
3+ fib = \n -> case n of
4+ 0 -> 1
5+ 1 -> 1
6+ n -> fib (n - 1) + fib (n - 2)
examples/passing/TopLevelCase.purs+11−9
@@ -1,12 +1,14 @@
1−gcd :: (Number, Number) -> Number
2−gcd (0, x) = x
3−gcd (x, 0) = x
4−gcd (x, y) | x > y = gcd (x % y, y)
5−gcd (x, y) = gcd (y % x, x)
1+module TopLevelCase where
62
7−guardsTest (x:xs) | x > 0 = guardsTest xs
8−guardsTest xs = xs
3+ gcd :: (Number, Number) -> Number
4+ gcd (0, x) = x
5+ gcd (x, 0) = x
6+ gcd (x, y) | x > y = gcd (x % y, y)
7+ gcd (x, y) = gcd (y % x, x)
98
10−data A = A
9+ guardsTest (x:xs) | x > 0 = guardsTest xs
10+ guardsTest xs = xs
1111
12−parseTest A 0 = 0
12+ data A = A
13+
14+ parseTest A 0 = 0
examples/passing/TypeDecl.purs+13−11
@@ -1,14 +1,16 @@
1−id :: forall a. (a) -> a
2−id = \x -> x
1+module TypeDecl where
32
4−k :: String -> Number -> String
5−k = \x -> \y -> x
3+ id :: forall a. (a) -> a
4+ id = \x -> x
65
7−iterate :: forall a. Number -> (a -> a) -> a -> a
8−iterate = \n -> \f -> \a -> {
9− var result = a;
10− for (i <- 0 until n) {
11− result = f result;
6+ k :: String -> Number -> String
7+ k = \x -> \y -> x
8+
9+ iterate :: forall a. Number -> (a -> a) -> a -> a
10+ iterate = \n -> \f -> \a -> {
11+ var result = a;
12+ for (i <- 0 until n) {
13+ result = f result;
14+ }
15+ return result;
1216 }
13− return result;
14− }
examples/passing/TypeSynonyms.purs+26−24
@@ -1,31 +1,33 @@
1−type Lens a b =
2− { get :: a -> b
3− , set :: a -> b -> a
4− }
1+module TypeSynonyms where
52
6−composeLenses :: forall a b c. Lens a b -> Lens b c -> Lens a c
7−composeLenses = \l1 -> \l2 ->
8− { get: \a -> l2.get (l1.get a)
9− , set: \a -> \c ->
10− {
11− var b = l1.get a;
12− var b1 = l2.set b c;
13− return l1.set a b1;
3+ type Lens a b =
4+ { get :: a -> b
5+ , set :: a -> b -> a
146 }
15− }
167
17−type Pair a b = { fst :: a, snd :: b }
8+ composeLenses :: forall a b c. Lens a b -> Lens b c -> Lens a c
9+ composeLenses = \l1 -> \l2 ->
10+ { get: \a -> l2.get (l1.get a)
11+ , set: \a -> \c ->
12+ {
13+ var b = l1.get a;
14+ var b1 = l2.set b c;
15+ return l1.set a b1;
16+ }
17+ }
18+
19+ type Pair a b = { fst :: a, snd :: b }
1820
19−fst :: forall a b. Lens (Pair a b) a
20−fst =
21− { get: \p -> p.fst
22− , set: \p -> \a -> { fst: a, snd: p.snd }
23− }
21+ fst :: forall a b. Lens (Pair a b) a
22+ fst =
23+ { get: \p -> p.fst
24+ , set: \p -> \a -> { fst: a, snd: p.snd }
25+ }
2426
25−test1 :: forall a b c. Lens (Pair (Pair a b) c) a
26−test1 = composeLenses fst fst
27+ test1 :: forall a b c. Lens (Pair (Pair a b) c) a
28+ test1 = composeLenses fst fst
2729
28−foreign import head :: forall a. Lens [a] a
30+ foreign import head :: forall a. Lens [a] a
2931
30−test2 :: forall a b c. Lens (Pair [Pair a b] c) a
31−test2 = composeLenses fst (composeLenses head fst)
32+ test2 :: forall a b c. Lens (Pair [Pair a b] c) a
33+ test2 = composeLenses fst (composeLenses head fst)
examples/passing/iota.purs+5−3
@@ -1,5 +1,7 @@
1−s = \x -> \y -> \z -> x z (y z)
1+module Iota where
22
3−k = \x -> \y -> x
3+ s = \x -> \y -> \z -> x z (y z)
44
5−iota = \x -> x s k
5+ k = \x -> \y -> x
6+
7+ iota = \x -> x s k
examples/passing/s.purs+3−1
@@ -1 +1,3 @@
1−s = \x y z -> x z (y z)
1+module S where
2+
3+ s = \x y z -> x z (y z)
libraries/jquery/example.purs+10−6
@@ -1,6 +1,10 @@
1−main = {
2− var div = create "<div>";
3− div = div `appendText` "Hello World!" `css` { color: "#FF0000" };
4− div = div `appendTo` select "body";
5− return { };
6− }
1+module Example where
2+
3+ import JQuery
4+
5+ main = {
6+ var div = create "<div>";
7+ div = div `appendText` "Hello World!" `css` { color: "#FF0000" };
8+ div = div `appendTo` select "body";
9+ return { };
10+ }
libraries/jquery/jquery.purs+18−16
@@ -1,23 +1,25 @@
1−-- The jQuery wrapper type
2−foreign import data JQuery :: *
1+module JQuery where
32
4−-- Wrapper function for jQuery selection $('..')
5−foreign import select :: String -> JQuery
3+ -- The jQuery wrapper type
4+ foreign import data JQuery :: *
65
7−-- Wrapper function for jQuery creation e.g. $('<div>')
8−foreign import create :: String -> JQuery
6+ -- Wrapper function for jQuery selection $('..')
7+ foreign import select :: String -> JQuery
98
10−-- .attr({ ... })
11−foreign import attr :: forall attr. JQuery -> { | attr } -> JQuery
9+ -- Wrapper function for jQuery creation e.g. $('<div>')
10+ foreign import create :: String -> JQuery
1211
13−-- .css({ ... })
14−foreign import css :: forall css. JQuery -> { | css } -> JQuery
12+ -- .attr({ ... })
13+ foreign import attr :: forall attr. JQuery -> { | attr } -> JQuery
1514
16−-- .append(...)
17−foreign import append :: JQuery -> JQuery -> JQuery
15+ -- .css({ ... })
16+ foreign import css :: forall css. JQuery -> { | css } -> JQuery
1817
19−-- .appendTo(...)
20−foreign import appendTo :: JQuery -> JQuery -> JQuery
18+ -- .append(...)
19+ foreign import append :: JQuery -> JQuery -> JQuery
2120
22−-- .append(...)
23−foreign import appendText :: JQuery -> String -> JQuery
21+ -- .appendTo(...)
22+ foreign import appendTo :: JQuery -> JQuery -> JQuery
23+
24+ -- .append(...)
25+ foreign import appendText :: JQuery -> String -> JQuery
libraries/prelude/prelude.purs+173−171
@@ -1,263 +1,265 @@
1−id :: forall a. a -> a
2−id = \x -> x
1+module Prelude where
32
4−flip :: forall a b c. (a -> b -> c) -> b -> a -> c
5−flip = \f -> \b -> \a -> f a b
3+ id :: forall a. a -> a
4+ id = \x -> x
65
7−konst :: forall a b. a -> b -> a
8−konst = \a -> \b -> a
6+ flip :: forall a b c. (a -> b -> c) -> b -> a -> c
7+ flip = \f -> \b -> \a -> f a b
98
10−(|>) :: forall a b c. (a -> b) -> (b -> c) -> a -> c
11−(|>) = \f -> \g -> \a -> g (f a)
9+ konst :: forall a b. a -> b -> a
10+ konst = \a -> \b -> a
1211
13−(<|) :: forall a b c. (b -> c) -> (a -> b) -> a -> c
14−(<|) = flip (|>)
12+ (|>) :: forall a b c. (a -> b) -> (b -> c) -> a -> c
13+ (|>) = \f -> \g -> \a -> g (f a)
1514
16−-- Maybe
15+ (<|) :: forall a b c. (b -> c) -> (a -> b) -> a -> c
16+ (<|) = flip (|>)
1717
18−data Maybe a = Nothing | Just a
18+ -- Maybe
1919
20−maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
21−maybe b _ Nothing = b
22−maybe _ f (Just a) = f a
20+ data Maybe a = Nothing | Just a
2321
24−fromMaybe :: forall a. a -> Maybe a -> a
25−fromMaybe a = maybe a id
22+ maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
23+ maybe b _ Nothing = b
24+ maybe _ f (Just a) = f a
2625
27−bindMaybe :: forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
28−bindMaybe m f = maybe Nothing f m
26+ fromMaybe :: forall a. a -> Maybe a -> a
27+ fromMaybe a = maybe a id
2928
30−-- Either
29+ bindMaybe :: forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
30+ bindMaybe m f = maybe Nothing f m
3131
32−data Either a b = Left a | Right b
32+ -- Either
3333
34−either :: forall a b c. (a -> c) -> (b -> c) -> Either a b -> c
35−either f _ (Left a) = f a
36−either _ g (Right b) = g b
34+ data Either a b = Left a | Right b
3735
38−bindEither :: forall e a b. Either e a -> (a -> Either e b) -> Either e b
39−bindEither = either (\e _ -> Left e) (\a f -> f a)
36+ either :: forall a b c. (a -> c) -> (b -> c) -> Either a b -> c
37+ either f _ (Left a) = f a
38+ either _ g (Right b) = g b
4039
41−-- Arrays
40+ bindEither :: forall e a b. Either e a -> (a -> Either e b) -> Either e b
41+ bindEither = either (\e _ -> Left e) (\a f -> f a)
4242
43−head :: forall a. [a] -> a
44−head (x : _) = x
43+ -- Arrays
4544
46−headSafe :: forall a. [a] -> Maybe a
47−headSafe (x : _) = Just x
48−headSafe _ = Nothing
45+ head :: forall a. [a] -> a
46+ head (x : _) = x
4947
50−tail :: forall a. [a] -> [a]
51−tail (_ : xs) = xs
48+ headSafe :: forall a. [a] -> Maybe a
49+ headSafe (x : _) = Just x
50+ headSafe _ = Nothing
5251
53−tailSafe :: forall a. [a] -> Maybe [a]
54−tailSafe (_ : xs) = Just xs
55−tailSafe _ = Nothing
52+ tail :: forall a. [a] -> [a]
53+ tail (_ : xs) = xs
5654
57−foreign import map :: forall a b. (a -> b) -> [a] -> [b]
55+ tailSafe :: forall a. [a] -> Maybe [a]
56+ tailSafe (_ : xs) = Just xs
57+ tailSafe _ = Nothing
5858
59−foldr :: forall a b. (a -> b -> a) -> a -> [b] -> a
60−foldr f a (b : bs) = f (foldr f a bs) b
61−foldr _ a [] = a
59+ foreign import map :: forall a b. (a -> b) -> [a] -> [b]
6260
63−foldl :: forall a b. (a -> b -> b) -> b -> [a] -> b
64−foldl f b as = {
65− var result = b;
66− foreach (a in as) {
67− result = f a result;
61+ foldr :: forall a b. (a -> b -> a) -> a -> [b] -> a
62+ foldr f a (b : bs) = f (foldr f a bs) b
63+ foldr _ a [] = a
64+
65+ foldl :: forall a b. (a -> b -> b) -> b -> [a] -> b
66+ foldl f b as = {
67+ var result = b;
68+ foreach (a in as) {
69+ result = f a result;
70+ }
71+ return result;
6872 }
69− return result;
70− }
7173
72−foreign import member "length" length :: forall a. [a] -> Number
74+ foreign import member "length" length :: forall a. [a] -> Number
7375
74−foreign import indexOf :: forall a. [a] -> a -> Number
76+ foreign import indexOf :: forall a. [a] -> a -> Number
7577
76−foreign import lastIndexOf :: forall a. [a] -> a -> Number
78+ foreign import lastIndexOf :: forall a. [a] -> a -> Number
7779
78−foreign import concat :: forall a. [a] -> [a] -> [a]
80+ foreign import concat :: forall a. [a] -> [a] -> [a]
7981
80−foreign import join :: [String] -> String
82+ foreign import join :: [String] -> String
8183
82−foreign import joinWith :: [String] -> String -> String
84+ foreign import joinWith :: [String] -> String -> String
8385
84−foreign import push :: forall a. [a] -> a -> [a]
86+ foreign import push :: forall a. [a] -> a -> [a]
8587
86−foreign import reverse :: forall a. [a] -> [a]
88+ foreign import reverse :: forall a. [a] -> [a]
8789
88−foreign import shift :: forall a. [a] -> [a]
90+ foreign import shift :: forall a. [a] -> [a]
8991
90−foreign import slice :: forall a. Number -> Number -> [a] -> [a]
92+ foreign import slice :: forall a. Number -> Number -> [a] -> [a]
9193
92−foreign import sort :: forall a. [a] -> [a]
94+ foreign import sort :: forall a. [a] -> [a]
9395
94−foreign import splice :: forall a. Number -> Number -> [a] -> [a] -> [a]
96+ foreign import splice :: forall a. Number -> Number -> [a] -> [a] -> [a]
9597
96−cons :: forall a. a -> [a] -> [a]
97−cons = \a -> concat([a])
98+ cons :: forall a. a -> [a] -> [a]
99+ cons = \a -> concat([a])
98100
99−concatMap :: forall a b. [a] -> (a -> [b]) -> [b]
100−concatMap as f = {
101− var result = [];
102− foreach (a in as) {
103− result = result `concat` f a;
101+ concatMap :: forall a b. [a] -> (a -> [b]) -> [b]
102+ concatMap as f = {
103+ var result = [];
104+ foreach (a in as) {
105+ result = result `concat` f a;
106+ }
107+ return result;
104108 }
105− return result;
106− }
107109
108−foreign import filter :: forall a. [a] -> (a -> Boolean) -> [a]
110+ foreign import filter :: forall a. [a] -> (a -> Boolean) -> [a]
109111
110−empty :: forall a. [a] -> Boolean
111−empty [] = true
112−empty _ = false
112+ empty :: forall a. [a] -> Boolean
113+ empty [] = true
114+ empty _ = false
113115
114−range :: Number -> Number -> [Number]
115−range lo hi = {
116− var ns = [];
117− for (n <- lo until hi) {
118− ns = push ns n;
116+ range :: Number -> Number -> [Number]
117+ range lo hi = {
118+ var ns = [];
119+ for (n <- lo until hi) {
120+ ns = push ns n;
121+ }
122+ return ns;
119123 }
120− return ns;
121− }
122−
123−zipWith :: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
124−zipWith f (a:as) (b:bs) = cons (f a b) (zipWith f as bs)
125−zipWith _ _ _ = []
126−
127−any :: forall a. (a -> Boolean) -> [a] -> Boolean
128−any p as = {
129− for (i <- 0 until length as) {
130− if (p (as !! i)) {
131− return true;
124+
125+ zipWith :: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
126+ zipWith f (a:as) (b:bs) = cons (f a b) (zipWith f as bs)
127+ zipWith _ _ _ = []
128+
129+ any :: forall a. (a -> Boolean) -> [a] -> Boolean
130+ any p as = {
131+ for (i <- 0 until length as) {
132+ if (p (as !! i)) {
133+ return true;
134+ }
132135 }
136+ return false;
133137 }
134− return false;
135− }
136−
137−all :: forall a. (a -> Boolean) -> [a] -> Boolean
138−all p as = {
139− for (i <- 0 until length as) {
140− if (!(p (as !! i))) {
141− return false;
138+
139+ all :: forall a. (a -> Boolean) -> [a] -> Boolean
140+ all p as = {
141+ for (i <- 0 until length as) {
142+ if (!(p (as !! i))) {
143+ return false;
144+ }
142145 }
146+ return true;
143147 }
144− return true;
145− }
146148
147−-- Pairs
149+ -- Pairs
148150
149−type Tuple a b = { fst :: a, snd :: b }
151+ type Tuple a b = { fst :: a, snd :: b }
150152
151−curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
152−curry f a b = f { fst: a, snd: b }
153+ curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
154+ curry f a b = f { fst: a, snd: b }
153155
154−uncurry :: forall a b c. (a -> b -> c) -> Tuple a b -> c
155−uncurry f t = f t.fst t.snd
156+ uncurry :: forall a b c. (a -> b -> c) -> Tuple a b -> c
157+ uncurry f t = f t.fst t.snd
156158
157−tuple :: forall a b. a -> b -> Tuple a b
158−tuple = curry id
159+ tuple :: forall a b. a -> b -> Tuple a b
160+ tuple = curry id
159161
160−zip :: forall a b. [a] -> [b] -> [Tuple a b]
161−zip = zipWith tuple
162+ zip :: forall a b. [a] -> [b] -> [Tuple a b]
163+ zip = zipWith tuple
162164
163−unzip :: forall a b. [Tuple a b] -> Tuple [a] [b]
164−unzip (t:ts) = case unzip ts of
165− { fst = as, snd = bs } -> tuple (cons t.fst as) (cons t.snd bs)
166−unzip [] = tuple [] []
165+ unzip :: forall a b. [Tuple a b] -> Tuple [a] [b]
166+ unzip (t:ts) = case unzip ts of
167+ { fst = as, snd = bs } -> tuple (cons t.fst as) (cons t.snd bs)
168+ unzip [] = tuple [] []
167169
168−-- Strings
170+ -- Strings
169171
170−foreign import member "length" lengthS :: String -> Number
172+ foreign import member "length" lengthS :: String -> Number
171173
172−foreign import charAt :: Number -> String -> String
174+ foreign import charAt :: Number -> String -> String
173175
174−foreign import indexOfS :: String -> String -> Number
176+ foreign import indexOfS :: String -> String -> Number
175177
176−foreign import lastIndexOfS :: String -> String -> Number
178+ foreign import lastIndexOfS :: String -> String -> Number
177179
178−foreign import localeCompare :: String -> String -> Number
180+ foreign import localeCompare :: String -> String -> Number
179181
180−foreign import replace :: String -> String -> String -> String
182+ foreign import replace :: String -> String -> String -> String
181183
182−foreign import sliceS :: Number -> Number -> String -> String
184+ foreign import sliceS :: Number -> Number -> String -> String
183185
184−foreign import split :: String -> String -> [String]
186+ foreign import split :: String -> String -> [String]
185187
186−foreign import substr :: Number -> Number -> String -> String
188+ foreign import substr :: Number -> Number -> String -> String
187189
188−foreign import substring :: Number -> Number -> String -> String
190+ foreign import substring :: Number -> Number -> String -> String
189191
190−foreign import toLower :: String -> String
192+ foreign import toLower :: String -> String
191193
192−foreign import toUpper :: String -> String
194+ foreign import toUpper :: String -> String
193195
194−foreign import trim :: String -> String
196+ foreign import trim :: String -> String
195197
196−-- Regex
198+ -- Regex
197199
198−foreign import data Regex :: *
200+ foreign import data Regex :: *
199201
200−foreign import regex :: String -> String -> Regex
202+ foreign import regex :: String -> String -> Regex
201203
202−foreign import test :: Regex -> String -> Boolean
204+ foreign import test :: Regex -> String -> Boolean
203205
204−foreign import match :: Regex -> String -> [String]
206+ foreign import match :: Regex -> String -> [String]
205207
206−foreign import replaceR :: Regex -> String -> String -> String
208+ foreign import replaceR :: Regex -> String -> String -> String
207209
208−foreign import search :: Regex -> String -> Number
210+ foreign import search :: Regex -> String -> Number
209211
210−-- Globals
212+ -- Globals
211213
212−foreign import nan :: Number
214+ foreign import nan :: Number
213215
214−foreign import infinity :: Number
216+ foreign import infinity :: Number
215217
216−foreign import toExponential :: Number -> String
218+ foreign import toExponential :: Number -> String
217219
218−foreign import toFixed :: Number -> Number -> String
220+ foreign import toFixed :: Number -> Number -> String
219221
220−foreign import toPrecision :: Number -> Number -> String
222+ foreign import toPrecision :: Number -> Number -> String
221223
222−foreign import numberToString :: Number -> String
224+ foreign import numberToString :: Number -> String
223225
224−foreign import isNaN :: Number -> Boolean
226+ foreign import isNaN :: Number -> Boolean
225227
226−foreign import isFinite :: Number -> Boolean
228+ foreign import isFinite :: Number -> Boolean
227229
228−foreign import parseFloat :: String -> Number
230+ foreign import parseFloat :: String -> Number
229231
230−foreign import parseInt :: String -> Number
232+ foreign import parseInt :: String -> Number
231233
232−foreign import encodeURIComponent :: String -> String
234+ foreign import encodeURIComponent :: String -> String
233235
234−foreign import decodeURIComponent :: String -> String
236+ foreign import decodeURIComponent :: String -> String
235237
236−foreign import encodeURI :: String -> String
238+ foreign import encodeURI :: String -> String
237239
238−foreign import decodeURI :: String -> String
240+ foreign import decodeURI :: String -> String
239241
240−-- Math
242+ -- Math
241243
242−type Math =
243− { abs :: Number -> Number
244− , acos :: Number -> Number
245− , asin :: Number -> Number
246− , atan :: Number -> Number
247− , atan2 :: (Number, Number) -> Number
248− , aceil :: Number -> Number
249− , cos :: Number -> Number
250− , exp :: Number -> Number
251− , floor :: Number -> Number
252− , log :: Number -> Number
253− , max :: (Number, Number) -> Number
254− , pow :: (Number, Number) -> Number
255− , random :: () -> Number
256− , round :: Number -> Number
257− , sin :: Number -> Number
258− , sqrt :: Number -> Number
259− , tan :: Number -> Number
260− }
244+ type Math =
245+ { abs :: Number -> Number
246+ , acos :: Number -> Number
247+ , asin :: Number -> Number
248+ , atan :: Number -> Number
249+ , atan2 :: (Number, Number) -> Number
250+ , aceil :: Number -> Number
251+ , cos :: Number -> Number
252+ , exp :: Number -> Number
253+ , floor :: Number -> Number
254+ , log :: Number -> Number
255+ , max :: (Number, Number) -> Number
256+ , pow :: (Number, Number) -> Number
257+ , random :: () -> Number
258+ , round :: Number -> Number
259+ , sin :: Number -> Number
260+ , sqrt :: Number -> Number
261+ , tan :: Number -> Number
262+ }
261263
262−foreign import math :: Math
264+ foreign import math :: Math
263265