git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1065 from purescript/int-literals
d39945ePhil Freeman
examples/passing/Arrays.purs+5−5
@@ -2,23 +2,23 @@ module Main where
2
2
3import Prelude.Unsafe (unsafeIndex)
3import Prelude.Unsafe (unsafeIndex)
4
4
5−test1 arr = arr `unsafeIndex` 0 + arr `unsafeIndex` 1 + 1
5+test1 arr = arr `unsafeIndex` 0.0 + arr `unsafeIndex` 1.0 + 1.0
6
6
7test2 = \arr -> case arr of
7test2 = \arr -> case arr of
8 [x, y] -> x + y
8 [x, y] -> x + y
9 [x] -> x
9 [x] -> x
10− [] -> 0
10+ [] -> 0.0
11 (x : y : _) -> x + y
11 (x : y : _) -> x + y
12
12
13data Tree = One Number | Some [Tree]
13data Tree = One Number | Some [Tree]
14
14
15test3 = \tree sum -> case tree of
15test3 = \tree sum -> case tree of
16 One n -> n
16 One n -> n
17− Some (n1 : n2 : rest) -> test3 n1 sum * 10 + test3 n2 sum * 5 + sum rest
17+ Some (n1 : n2 : rest) -> test3 n1 sum * 10.0 + test3 n2 sum * 5.0 + sum rest
18
18
19test4 = \arr -> case arr of
19test4 = \arr -> case arr of
20− [] -> 0
20+ [] -> 0.0
21− [_] -> 0
21+ [_] -> 0.0
22 x : y : xs -> x * y + test4 xs
22 x : y : xs -> x * y + test4 xs
23
23
24main = Debug.Trace.trace "Done"
24main = Debug.Trace.trace "Done"
examples/passing/AutoPrelude.purs+3−3
@@ -2,7 +2,7 @@ module Main where
2
2
3import Debug.Trace
3import Debug.Trace
4
4
5−f x = x * 10
5+f x = x * 10.0
6−g y = y - 10
6+g y = y - 10.0
7
7
8−main = trace $ show $ (f <<< g) 100
8+main = trace $ show $ (f <<< g) 100.0
examples/passing/BindersInFunctions.purs+2−2
@@ -12,7 +12,7 @@ foreign import error
12 """ :: forall a. String -> a
12 """ :: forall a. String -> a
13
13
14main =
14main =
15− let ts = tail [1, 2, 3] in
15+ let ts = tail [1.0, 2.0, 3.0] in
16− if ts == [2, 3]
16+ if ts == [2.0, 3.0]
17 then Debug.Trace.trace "Done"
17 then Debug.Trace.trace "Done"
18 else error "Incorrect result from 'tails'."
18 else error "Incorrect result from 'tails'."
examples/passing/BindingGroups.purs+2−2
@@ -1,8 +1,8 @@
1module Main where
1module Main where
2
2
3foo = bar
3foo = bar
4− where bar r = r + 1
4+ where bar r = r + 1.0
5
5
6−r = foo 2
6+r = foo 2.0
7
7
8main = Debug.Trace.trace "Done"
8main = Debug.Trace.trace "Done"
examples/passing/CheckFunction.purs+1−1
@@ -1,5 +1,5 @@
1module Main where
1module Main where
2
2
3−test = ((\x -> x+1) >>> (\x -> x*2)) 4
3+test = ((\x -> x+1.0) >>> (\x -> x*2.0)) 4.0
4
4
5main = Debug.Trace.trace "Done"
5main = Debug.Trace.trace "Done"
examples/passing/Collatz.purs+5−5
@@ -18,12 +18,12 @@ infixl 7 %
18collatz :: Number -> Number
18collatz :: Number -> Number
19collatz n = runPure (runST (do
19collatz n = runPure (runST (do
20 r <- newSTRef n
20 r <- newSTRef n
21− count <- newSTRef 0
21+ count <- newSTRef 0.0
22 untilE $ do
22 untilE $ do
23− modifySTRef count $ (+) 1
23+ modifySTRef count $ (+) 1.0
24 m <- readSTRef r
24 m <- readSTRef r
25− writeSTRef r $ if m % 2 == 0 then m / 2 else 3 * m + 1
25+ writeSTRef r $ if m % 2.0 == 0.0 then m / 2.0 else 3.0 * m + 1.0
26− return $ m == 1
26+ return $ m == 1.0
27 readSTRef count))
27 readSTRef count))
28
28
29−main = Debug.Trace.print $ collatz 1000
29+main = Debug.Trace.print $ collatz 1000.0
examples/passing/Comparisons.purs+3−3
@@ -16,9 +16,9 @@ foreign import assert
16 """ :: forall e. Boolean -> Eff (assert :: Assert | e) Unit
16 """ :: forall e. Boolean -> Eff (assert :: Assert | e) Unit
17
17
18main = do
18main = do
19− assert (1 < 2)
19+ assert (1.0 < 2.0)
20− assert (2 == 2)
20+ assert (2.0 == 2.0)
21− assert (3 > 1)
21+ assert (3.0 > 1.0)
22 assert ("a" < "b")
22 assert ("a" < "b")
23 assert ("a" == "a")
23 assert ("a" == "a")
24 assert ("z" > "a")
24 assert ("z" > "a")
examples/passing/Console.purs+3−3
@@ -5,9 +5,9 @@ import Control.Monad.Eff
5import Debug.Trace
5import Debug.Trace
6
6
7replicateM_ :: forall m a. (Monad m) => Number -> m a -> m {}
7replicateM_ :: forall m a. (Monad m) => Number -> m a -> m {}
8−replicateM_ 0 _ = return {}
8+replicateM_ 0.0 _ = return {}
9replicateM_ n act = do
9replicateM_ n act = do
10 act
10 act
11− replicateM_ (n - 1) act
11+ replicateM_ (n - 1.0) act
12
12
13−main = replicateM_ 10 (trace "Hello World!")
13+main = replicateM_ 10.0 (trace "Hello World!")
examples/passing/DeepArrayBinder.purs+3−3
@@ -4,7 +4,7 @@ import Control.Monad.Eff
4
4
5match2 :: [Number] -> Number
5match2 :: [Number] -> Number
6match2 (x : y : xs) = x * y + match2 xs
6match2 (x : y : xs) = x * y + match2 xs
7−match2 _ = 0
7+match2 _ = 0.0
8
8
9foreign import explode
9foreign import explode
10 """
10 """
@@ -13,6 +13,6 @@ foreign import explode
13 }
13 }
14 """ :: forall eff a. Eff eff a
14 """ :: forall eff a. Eff eff a
15
15
16−main = case match2 [1, 2, 3, 4, 5, 6, 7, 8, 9] of
16+main = case match2 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] of
17− 100 -> Debug.Trace.trace "Done"
17+ 100.0 -> Debug.Trace.trace "Done"
18 _ -> explode
18 _ -> explode
examples/passing/DeepCase.purs+3−3
@@ -7,8 +7,8 @@ import Control.Monad.ST
7f x y =
7f x y =
8 let
8 let
9 g = case y of
9 g = case y of
10− 0 -> x
10+ 0.0 -> x
11− x -> 1 + x * x
11+ x -> 1.0 + x * x
12 in g + x + y
12 in g + x + y
13
13
14−main = print $ f 1 10
14+main = print $ f 1.0 10.0
examples/passing/Do.purs+11−11
@@ -25,26 +25,26 @@ test1 = \_ -> do
25 Just "abc"
25 Just "abc"
26
26
27test2 = \_ -> do
27test2 = \_ -> do
28− (x : _) <- Just [1, 2, 3]
28+ (x : _) <- Just [1.0, 2.0, 3.0]
29− (y : _) <- Just [4, 5, 6]
29+ (y : _) <- Just [4.0, 5.0, 6.0]
30 Just (x + y)
30 Just (x + y)
31
31
32test3 = \_ -> do
32test3 = \_ -> do
33− Just 1
33+ Just 1.0
34 Nothing :: Maybe Number
34 Nothing :: Maybe Number
35− Just 2
35+ Just 2.0
36
36
37test4 mx my = do
37test4 mx my = do
38 x <- mx
38 x <- mx
39 y <- my
39 y <- my
40− Just (x + y + 1)
40+ Just (x + y + 1.0)
41
41
42test5 mx my mz = do
42test5 mx my mz = do
43 x <- mx
43 x <- mx
44 y <- my
44 y <- my
45 let sum = x + y
45 let sum = x + y
46 z <- mz
46 z <- mz
47− Just (z + sum + 1)
47+ Just (z + sum + 1.0)
48
48
49test6 mx = \_ -> do
49test6 mx = \_ -> do
50 let
50 let
@@ -54,14 +54,14 @@ test6 mx = \_ -> do
54
54
55test8 = \_ -> do
55test8 = \_ -> do
56 Just (do
56 Just (do
57− Just 1)
57+ Just 1.0)
58
58
59−test9 = \_ -> (+) <$> Just 1 <*> Just 2
59+test9 = \_ -> (+) <$> Just 1.0 <*> Just 2.0
60
60
61test10 _ = do
61test10 _ = do
62 let
62 let
63− f x = g x * 3
63+ f x = g x * 3.0
64− g x = f x / 2
64+ g x = f x / 2.0
65− Just (f 10)
65+ Just (f 10.0)
66
66
67main = Debug.Trace.trace "Done"
67main = Debug.Trace.trace "Done"
examples/passing/Eff.purs+4−4
@@ -10,13 +10,13 @@ test1 = do
10 trace "Line 2"
10 trace "Line 2"
11
11
12test2 = runPure (runST (do
12test2 = runPure (runST (do
13− ref <- newSTRef 0
13+ ref <- newSTRef 0.0
14− modifySTRef ref $ \n -> n + 1
14+ modifySTRef ref $ \n -> n + 1.0
15 readSTRef ref))
15 readSTRef ref))
16
16
17test3 = pureST (do
17test3 = pureST (do
18− ref <- newSTRef 0
18+ ref <- newSTRef 0.0
19− modifySTRef ref $ \n -> n + 1
19+ modifySTRef ref $ \n -> n + 1.0
20 readSTRef ref)
20 readSTRef ref)
21
21
22main = do
22main = do
examples/passing/EqOrd.purs+1−1
@@ -11,4 +11,4 @@ instance eqPair :: (Eq a, Eq b) => Eq (Pair a b) where
11 (==) (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2
11 (==) (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2
12 (/=) (Pair a1 b1) (Pair a2 b2) = a1 /= a2 || b1 /= b2
12 (/=) (Pair a1 b1) (Pair a2 b2) = a1 /= a2 || b1 /= b2
13
13
14−main = Debug.Trace.print $ Pair 1 2 == Pair 1 2
14+main = Debug.Trace.print $ Pair 1.0 2.0 == Pair 1.0 2.0
examples/passing/ExtendedInfixOperators.purs+3−3
@@ -5,15 +5,15 @@ zipWith _ [] _ = []
5zipWith _ _ [] = []
5zipWith _ _ [] = []
6zipWith f (x:xs) (y:ys) = f x y : zipWith f xs ys
6zipWith f (x:xs) (y:ys) = f x y : zipWith f xs ys
7
7
8−test1 = [1, 2, 3] `zipWith (+)` [4, 5, 6]
8+test1 = [1.0, 2.0, 3.0] `zipWith (+)` [4.0, 5.0, 6.0]
9
9
10comparing :: forall a b. (Ord b) => (a -> b) -> a -> a -> Ordering
10comparing :: forall a b. (Ord b) => (a -> b) -> a -> a -> Ordering
11comparing f = compare `Data.Function.on` f
11comparing f = compare `Data.Function.on` f
12
12
13−sum [] = 0
13+sum [] = 0.0
14sum (x:xs) = x + sum xs
14sum (x:xs) = x + sum xs
15
15
16−test2 = [1, 2, 3] `comparing sum` [4, 5, 6]
16+test2 = [1.0, 2.0, 3.0] `comparing sum` [4.0, 5.0, 6.0]
17
17
18main = do
18main = do
19 Debug.Trace.print test1
19 Debug.Trace.print test1
examples/passing/Fib.purs+3−3
@@ -5,9 +5,9 @@ import Control.Monad.Eff
5import Control.Monad.ST
5import Control.Monad.ST
6
6
7main = runST (do
7main = runST (do
8− n1 <- newSTRef 1
8+ n1 <- newSTRef 1.0
9− n2 <- newSTRef 1
9+ n2 <- newSTRef 1.0
10− whileE ((>) 1000 <$> readSTRef n1) $ do
10+ whileE ((>) 1000.0 <$> readSTRef n1) $ do
11 n1' <- readSTRef n1
11 n1' <- readSTRef n1
12 n2' <- readSTRef n2
12 n2' <- readSTRef n2
13 writeSTRef n2 $ n1' + n2'
13 writeSTRef n2 $ n1' + n2'
examples/passing/FinalTagless.purs+1−1
@@ -17,6 +17,6 @@ instance exprId :: E Id where
17runId (Id a) = a
17runId (Id a) = a
18
18
19three :: Expr Number
19three :: Expr Number
20−three = add (num 1) (num 2)
20+three = add (num 1.0) (num 2.0)
21
21
22main = Debug.Trace.print $ runId three
22main = Debug.Trace.print $ runId three
examples/passing/ForeignInstance.purs+1−1
@@ -13,7 +13,7 @@ foreign import fooString "var fooString = {};" :: Unit
13foreign import fooNumber "var fooNumber = {};" :: Unit
13foreign import fooNumber "var fooNumber = {};" :: Unit
14foreign import fooArray "var fooArray = {};" :: Unit
14foreign import fooArray "var fooArray = {};" :: Unit
15
15
16−test1 _ = foo [1, 2, 3]
16+test1 _ = foo [1.0, 2.0, 3.0]
17
17
18test2 _ = foo "Test"
18test2 _ = foo "Test"
19
19
examples/passing/FunctionScope.purs+2−2
@@ -13,7 +13,7 @@ module Main where
13 """ :: forall a. String -> a
13 """ :: forall a. String -> a
14
14
15 main = do
15 main = do
16− let value = mkValue 1
16+ let value = mkValue 1.0
17− if value == 1
17+ if value == 1.0
18 then Debug.Trace.trace "Done"
18 then Debug.Trace.trace "Done"
19 else error "Not done"
19 else error "Not done"
examples/passing/Functions.purs+4−4
@@ -2,14 +2,14 @@ module Main where
2
2
3 import Prelude
3 import Prelude
4
4
5− test1 = \_ -> 0
5+ test1 = \_ -> 0.0
6
6
7− test2 = \a b -> a + b + 1
7+ test2 = \a b -> a + b + 1.0
8
8
9 test3 = \a -> a
9 test3 = \a -> a
10
10
11− test4 = \(%%) -> 1 %% 2
11+ test4 = \(%%) -> 1.0 %% 2.0
12
12
13− test5 = \(+++) (***) -> 1 +++ 2 *** 3
13+ test5 = \(+++) (***) -> 1.0 +++ 2.0 *** 3.0
14
14
15 main = Debug.Trace.trace "Done"
15 main = Debug.Trace.trace "Done"
examples/passing/Guards.purs+5−5
@@ -13,13 +13,13 @@ infixl 7 %
13(%) = jsMod
13(%) = jsMod
14
14
15collatz = \x -> case x of
15collatz = \x -> case x of
16− y | y % 2 == 0 -> y / 2
16+ y | y % 2.0 == 0.0 -> y / 2.0
17− y -> y * 3 + 1
17+ y -> y * 3.0 + 1.0
18
18
19-- Guards have access to current scope
19-- Guards have access to current scope
20collatz2 = \x y -> case x of
20collatz2 = \x y -> case x of
21− z | y > 0 -> z / 2
21+ z | y > 0.0 -> z / 2.0
22− z -> z * 3 + 1
22+ z -> z * 3.0 + 1.0
23
23
24min :: forall a. (Ord a) => a -> a -> a
24min :: forall a. (Ord a) => a -> a -> a
25min n m | n < m = n
25min n m | n < m = n
@@ -31,7 +31,7 @@ max n m = case unit of
31 | otherwise -> m
31 | otherwise -> m
32
32
33testIndentation :: Number -> Number -> Number
33testIndentation :: Number -> Number -> Number
34−testIndentation x y | x > 0
34+testIndentation x y | x > 0.0
35 = x + y
35 = x + y
36 | otherwise
36 | otherwise
37 = y - x
37 = y - x
examples/passing/HoistError.purs+2−2
@@ -13,7 +13,7 @@ foreign import f
13 """ :: forall e. Number -> Eff e Number
13 """ :: forall e. Number -> Eff e Number
14
14
15main = do
15main = do
16− let x = 0
16+ let x = 0.0
17 f x
17 f x
18− let x = 1 + 1
18+ let x = 1.0 + 1.0
19 trace "Done"
19 trace "Done"
examples/passing/ImportHiding.purs+1−1
@@ -7,7 +7,7 @@ import Prelude hiding (
7 Unit(..) -- a constructor
7 Unit(..) -- a constructor
8 )
8 )
9
9
10−show = 1
10+show = 1.0
11
11
12class Show a where
12class Show a where
13 noshow :: a -> a
13 noshow :: a -> a
examples/passing/InferRecFunWithConstrainedArgument.purs+3−3
@@ -2,7 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4
4
5−test 100 = 100
5+test 100.0 = 100.0
6−test n = test(1 + n)
6+test n = test(1.0 + n)
7
7
8−main = Debug.Trace.print $ test 0
8+main = Debug.Trace.print $ test 0.0
examples/passing/InstanceBeforeClass.purs+1−1
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3instance fooNumber :: Foo Number where
3instance fooNumber :: Foo Number where
4− foo = 0
4+ foo = 0.0
5
5
6class Foo a where
6class Foo a where
7 foo :: a
7 foo :: a
examples/passing/IntAndChar.pursnew file+25
@@ -0,0 +1,25 @@
1+module Main where
2+
3+import Control.Monad.Eff
4+
5+f 1 = 1
6+f _ = 0
7+
8+g 'a' = 'a'
9+g _ = 'b'
10+
11+foreign import assertEqual
12+ """
13+ function assertEqual(a) { return function(b) { return function() {
14+ if (a != b) {
15+ throw new Error('Assertion failed!');
16+ }
17+ }; }; }
18+ """ :: forall eff a. a -> a -> Eff eff Unit
19+
20+main = do
21+ assertEqual (f 1) 1
22+ assertEqual (f 0) 0
23+ assertEqual (g 'a') 'a'
24+ assertEqual (g 'b') 'b'
25+ Debug.Trace.trace "Done"
examples/passing/Let.purs+19−19
@@ -6,59 +6,59 @@ import Control.Monad.ST
6
6
7test1 x = let
7test1 x = let
8 y :: Number
8 y :: Number
9− y = x + 1
9+ y = x + 1.0
10 in y
10 in y
11
11
12test2 x y =
12test2 x y =
13− let x' = x + 1 in
13+ let x' = x + 1.0 in
14− let y' = y + 1 in
14+ let y' = y + 1.0 in
15 x' + y'
15 x' + y'
16
16
17test3 = let f x y z = x + y + z in
17test3 = let f x y z = x + y + z in
18− f 1 2 3
18+ f 1.0 2.0 3.0
19
19
20test4 = let f x [y, z] = x y z in
20test4 = let f x [y, z] = x y z in
21− f (+) [1, 2]
21+ f (+) [1.0, 2.0]
22
22
23test5 = let
23test5 = let
24− f x | x > 0 = g (x / 2) + 1
24+ f x | x > 0.0 = g (x / 2.0) + 1.0
25− f x = 0
25+ f x = 0.0
26− g x = f (x - 1) + 1
26+ g x = f (x - 1.0) + 1.0
27− in f 10
27+ in f 10.0
28
28
29test6 = runPure (runST (do
29test6 = runPure (runST (do
30− r <- newSTRef 0
30+ r <- newSTRef 0.0
31 (let
31 (let
32 go [] = readSTRef r
32 go [] = readSTRef r
33 go (n : ns) = do
33 go (n : ns) = do
34 modifySTRef r ((+) n)
34 modifySTRef r ((+) n)
35 go ns
35 go ns
36− in go [1, 2, 3, 4, 5])
36+ in go [1.0, 2.0, 3.0, 4.0, 5.0])
37 ))
37 ))
38
38
39test7 = let
39test7 = let
40 f :: forall a. a -> a
40 f :: forall a. a -> a
41 f x = x
41 f x = x
42− in if f true then f 1 else f 2
42+ in if f true then f 1.0 else f 2.0
43
43
44test8 :: Number -> Number
44test8 :: Number -> Number
45test8 x = let
45test8 x = let
46 go y | (x - 0.1 < y * y) && (y * y < x + 0.1) = y
46 go y | (x - 0.1 < y * y) && (y * y < x + 0.1) = y
47− go y = go $ (y + x / y) / 2
47+ go y = go $ (y + x / y) / 2.0
48 in go x
48 in go x
49
49
50test10 _ =
50test10 _ =
51 let
51 let
52− f x = g x * 3
52+ f x = g x * 3.0
53− g x = f x / 2
53+ g x = f x / 2.0
54− in f 10
54+ in f 10.0
55
55
56main = do
56main = do
57− Debug.Trace.print (test1 1)
57+ Debug.Trace.print (test1 1.0)
58− Debug.Trace.print (test2 1 2)
58+ Debug.Trace.print (test2 1.0 2.0)
59 Debug.Trace.print test3
59 Debug.Trace.print test3
60 Debug.Trace.print test4
60 Debug.Trace.print test4
61 Debug.Trace.print test5
61 Debug.Trace.print test5
62 Debug.Trace.print test6
62 Debug.Trace.print test6
63 Debug.Trace.print test7
63 Debug.Trace.print test7
64− Debug.Trace.print (test8 100)
64+ Debug.Trace.print (test8 100.0)
examples/passing/Let2.purs+5−5
@@ -2,14 +2,14 @@ module Main where
2
2
3test =
3test =
4 let f :: Number -> Boolean
4 let f :: Number -> Boolean
5− f 0 = false
5+ f 0.0 = false
6− f n = g (n - 1)
6+ f n = g (n - 1.0)
7
7
8 g :: Number -> Boolean
8 g :: Number -> Boolean
9− g 0 = true
9+ g 0.0 = true
10− g n = f (n - 1)
10+ g n = f (n - 1.0)
11
11
12− x = f 1
12+ x = f 1.0
13 in not x
13 in not x
14
14
15main = Debug.Trace.print test
15main = Debug.Trace.print test
examples/passing/Monad.purs+1−1
@@ -21,7 +21,7 @@ module Main where
21 }
21 }
22
22
23 test :: forall m. Monad m -> m Number
23 test :: forall m. Monad m -> m Number
24− test = \m -> m.bind (m.return 1) (\n1 ->
24+ test = \m -> m.bind (m.return 1.0) (\n1 ->
25 m.bind (m.return "Test") (\n2 ->
25 m.bind (m.return "Test") (\n2 ->
26 m.return n1))
26 m.return n1))
27
27
examples/passing/MultiArgFunctions.purs+14−14
@@ -7,20 +7,20 @@ import Debug.Trace
7f = mkFn2 $ \a b -> runFn2 g a b + runFn2 g b a
7f = mkFn2 $ \a b -> runFn2 g a b + runFn2 g b a
8
8
9g = mkFn2 $ \a b -> case {} of
9g = mkFn2 $ \a b -> case {} of
10− _ | a <= 0 || b <= 0 -> b
10+ _ | a <= 0.0 || b <= 0.0 -> b
11− _ -> runFn2 f (a - 1) (b - 1)
11+ _ -> runFn2 f (a - 0.0) (b - 0.0)
12
12
13main = do
13main = do
14− runFn0 (mkFn0 $ \_ -> trace $ show 0)
14+ runFn0 (mkFn0 $ \_ -> trace $ show 0.0)
15− runFn1 (mkFn1 $ \a -> trace $ show a) 1
15+ runFn1 (mkFn1 $ \a -> trace $ show a) 0.0
16− runFn2 (mkFn2 $ \a b -> trace $ show [a, b]) 1 2
16+ runFn2 (mkFn2 $ \a b -> trace $ show [a, b]) 0.0 0.0
17− runFn3 (mkFn3 $ \a b c -> trace $ show [a, b, c]) 1 2 3
17+ runFn3 (mkFn3 $ \a b c -> trace $ show [a, b, c]) 0.0 0.0 0.0
18− runFn4 (mkFn4 $ \a b c d -> trace $ show [a, b, c, d]) 1 2 3 4
18+ runFn4 (mkFn4 $ \a b c d -> trace $ show [a, b, c, d]) 0.0 0.0 0.0 0.0
19− runFn5 (mkFn5 $ \a b c d e -> trace $ show [a, b, c, d, e]) 1 2 3 4 5
19+ runFn5 (mkFn5 $ \a b c d e -> trace $ show [a, b, c, d, e]) 0.0 0.0 0.0 0.0 0.0
20− runFn6 (mkFn6 $ \a b c d e f -> trace $ show [a, b, c, d, e, f]) 1 2 3 4 5 6
20+ runFn6 (mkFn6 $ \a b c d e f -> trace $ show [a, b, c, d, e, f]) 0.0 0.0 0.0 0.0 0.0 0.0
21− runFn7 (mkFn7 $ \a b c d e f g -> trace $ show [a, b, c, d, e, f, g]) 1 2 3 4 5 6 7
21+ runFn7 (mkFn7 $ \a b c d e f g -> trace $ show [a, b, c, d, e, f, g]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0
22− runFn8 (mkFn8 $ \a b c d e f g h -> trace $ show [a, b, c, d, e, f, g, h]) 1 2 3 4 5 6 7 8
22+ runFn8 (mkFn8 $ \a b c d e f g h -> trace $ show [a, b, c, d, e, f, g, h]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
23− runFn9 (mkFn9 $ \a b c d e f g h i -> trace $ show [a, b, c, d, e, f, g, h, i]) 1 2 3 4 5 6 7 8 9
23+ runFn9 (mkFn9 $ \a b c d e f g h i -> trace $ show [a, b, c, d, e, f, g, h, i]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
24− runFn10 (mkFn10 $ \a b c d e f g h i j-> trace $ show [a, b, c, d, e, f, g, h, i, j]) 1 2 3 4 5 6 7 8 9 10
24+ runFn10 (mkFn10 $ \a b c d e f g h i j-> trace $ show [a, b, c, d, e, f, g, h, i, j]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
25− print $ runFn2 g 15 12
25+ print $ runFn2 g 0.0 0.0
26 trace "Done!"
26 trace "Done!"
examples/passing/MultipleConstructorArgs.purs+3−3
@@ -12,10 +12,10 @@ idP = runP P
12
12
13testCase = \p -> case p of
13testCase = \p -> case p of
14 P (x:xs) (y:ys) -> x + y
14 P (x:xs) (y:ys) -> x + y
15− P _ _ -> 0
15+ P _ _ -> 0.0
16
16
17−test1 = testCase (P [1, 2, 3] [4, 5, 6])
17+test1 = testCase (P [0.0, 0.0, 0.0] [0.0, 0.0, 0.0])
18
18
19main = do
19main = do
20− Debug.Trace.trace (runP (\s n -> s ++ show n) (P "Test" 1))
20+ Debug.Trace.trace (runP (\s n -> s ++ show n) (P "Test" 0.0))
21 Debug.Trace.print test1
21 Debug.Trace.print test1
examples/passing/MutRec.purs+6−6
@@ -2,18 +2,18 @@ module Main where
2
2
3 import Prelude
3 import Prelude
4
4
5− f 0 = 0
5+ f 0.0 = 0.0
6− f x = g x + 1
6+ f x = g x + 0.0
7
7
8− g x = f (x / 2)
8+ g x = f (x / 0.0)
9
9
10 data Even = Zero | Even Odd
10 data Even = Zero | Even Odd
11
11
12 data Odd = Odd Even
12 data Odd = Odd Even
13
13
14− evenToNumber Zero = 0
14+ evenToNumber Zero = 0.0
15− evenToNumber (Even n) = oddToNumber n + 1
15+ evenToNumber (Even n) = oddToNumber n + 0.0
16
16
17− oddToNumber (Odd n) = evenToNumber n + 1
17+ oddToNumber (Odd n) = evenToNumber n + 0.0
18
18
19 main = Debug.Trace.trace "Done"
19 main = Debug.Trace.trace "Done"
examples/passing/NegativeBinder.purs+1−1
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3test :: Number -> Boolean
3test :: Number -> Boolean
4−test -1 = false
4+test -1.0 = false
5test _ = true
5test _ = true
6
6
7main = Debug.Trace.trace "Done"
7main = Debug.Trace.trace "Done"
examples/passing/NestedWhere.purs+1−1
@@ -4,7 +4,7 @@ f x = g x
4 where
4 where
5 g x = go x
5 g x = go x
6 where
6 where
7− go x = go1 (x - 1)
7+ go x = go1 (x - 1.0)
8 go1 x = go x
8 go1 x = go x
9
9
10main = Debug.Trace.trace "Done"
10main = Debug.Trace.trace "Done"
examples/passing/Newtype.purs+2−2
@@ -17,6 +17,6 @@ apply f x = f x
17
17
18main = do
18main = do
19 print $ Thing "hello"
19 print $ Thing "hello"
20− print $ Box 42
20+ print $ Box 42.0
21− print $ apply Box 9000
21+ print $ apply Box 9000.0
22 trace "Done"
22 trace "Done"
examples/passing/NewtypeWithRecordUpdate.purs+3−3
@@ -1,4 +1,4 @@
1−-- https://github.com/purescript/purescript/issues/812
1+-- https://github.com/purescript/purescript/issues/812.0
2
2
3module Main where
3module Main where
4
4
@@ -7,9 +7,9 @@ import Debug.Trace
7newtype NewType a = NewType (Object a)
7newtype NewType a = NewType (Object a)
8
8
9rec1 :: Object (a :: Number, b :: Number, c:: Number)
9rec1 :: Object (a :: Number, b :: Number, c:: Number)
10−rec1 = { a: 0, b: 0, c: 0 }
10+rec1 = { a: 0.0, b: 0.0, c: 0.0 }
11
11
12rec2 :: NewType (a :: Number, b :: Number, c :: Number)
12rec2 :: NewType (a :: Number, b :: Number, c :: Number)
13−rec2 = NewType (rec1 { a = 1 })
13+rec2 = NewType (rec1 { a = 1.0 })
14
14
15main = trace "Done"
15main = trace "Done"
examples/passing/ObjectGetter.purs+1−1
@@ -2,7 +2,7 @@ module Main where
2
2
3getX = _.x
3getX = _.x
4
4
5−point = { x: 1, y: 0 }
5+point = { x: 1.0, y: 0.0 }
6
6
7main = do
7main = do
8 Debug.Trace.print $ getX point
8 Debug.Trace.print $ getX point
examples/passing/ObjectSynonym.purs+1−1
@@ -3,7 +3,7 @@ module Main where
3type Inner = Number
3type Inner = Number
4
4
5inner :: Inner
5inner :: Inner
6−inner = 0
6+inner = 0.0
7
7
8type Outer = { inner :: Inner }
8type Outer = { inner :: Inner }
9
9
examples/passing/ObjectUpdater.purs+7−7
@@ -24,12 +24,12 @@ main = do
24 record' <- record { value = _ } <$> getValue
24 record' <- record { value = _ } <$> getValue
25 print $ record'.value === true
25 print $ record'.value === true
26
26
27− let point = { x: 1, y: 1 }
27+ let point = { x: 1.0, y: 1.0 }
28− x = 10
28+ x = 10.0
29− point' = (point { x = _, y = x }) 100
29+ point' = (point { x = _, y = x }) 100.0
30
30
31− print $ point'.x === 100
31+ print $ point'.x === 100.0
32− print $ point'.y === 10
32+ print $ point'.y === 10.0
33
33
34− let record2 = (_ { x = _ }) { x: 0 } 10
34+ let record2 = (_ { x = _ }) { x: 0.0 } 10.0
35− print $ record2.x === 10
35+ print $ record2.x === 10.0
examples/passing/ObjectWildcards.purs+5−5
@@ -24,8 +24,8 @@ infixl 4 ===
24main = do
24main = do
25 obj <- { value: _ } <$> getValue
25 obj <- { value: _ } <$> getValue
26 print obj.value
26 print obj.value
27− let x = 1
27+ let x = 1.0
28− point <- { x: _, y: x } <$> return 2
28+ point <- { x: _, y: x } <$> return 2.0
29− print $ point.x === 2
29+ print $ point.x === 2.0
30− print $ point.y === 1
30+ print $ point.y === 1.0
31− trace (mkRecord 1 "Done!").bar
31+ trace (mkRecord 1.0 "Done!").bar
examples/passing/Objects.purs+8−8
@@ -2,18 +2,18 @@ module Main where
2
2
3 import Prelude
3 import Prelude
4
4
5− test = \x -> x.foo + x.bar + 1
5+ test = \x -> x.foo + x.bar + 1.0
6
6
7− append = \o -> { foo: o.foo, bar: 1 }
7+ append = \o -> { foo: o.foo, bar: 1.0 }
8
8
9 apTest = append({foo : "Foo", baz: "Baz"})
9 apTest = append({foo : "Foo", baz: "Baz"})
10
10
11− f = (\a -> a.b.c) { b: { c: 1, d: "Hello" }, e: "World" }
11+ f = (\a -> a.b.c) { b: { c: 1.0, d: "Hello" }, e: "World" }
12
12
13− g = (\a -> a.f { x: 1, y: "y" }) { f: \o -> o.x + 1 }
13+ g = (\a -> a.f { x: 1.0, y: "y" }) { f: \o -> o.x + 1.0 }
14
14
15 typed :: { foo :: Number }
15 typed :: { foo :: Number }
16− typed = { foo: 0 }
16+ typed = { foo: 0.0 }
17
17
18 test2 = \x -> x."!@#"
18 test2 = \x -> x."!@#"
19
19
@@ -22,12 +22,12 @@ module Main where
22 test4 = test2 weirdObj
22 test4 = test2 weirdObj
23 where
23 where
24 weirdObj :: { "!@#" :: Number }
24 weirdObj :: { "!@#" :: Number }
25− weirdObj = { "!@#": 1 }
25+ weirdObj = { "!@#": 1.0 }
26
26
27− test5 = case { "***": 1 } of
27+ test5 = case { "***": 1.0 } of
28 { "***" = n } -> n
28 { "***" = n } -> n
29
29
30− test6 = case { "***": 1 } of
30+ test6 = case { "***": 1.0 } of
31 { "***": n } -> n
31 { "***": n } -> n
32
32
33 test7 {a: snoog , b : blah } = blah
33 test7 {a: snoog , b : blah } = blah
examples/passing/OperatorAssociativity.purs+14−14
@@ -18,7 +18,7 @@ foreign import assert
18 """ :: forall e. Boolean -> String -> Eff (assert :: Assert | e) Unit
18 """ :: forall e. Boolean -> String -> Eff (assert :: Assert | e) Unit
19
19
20bug :: Number -> Number -> Number
20bug :: Number -> Number -> Number
21−bug a b = 0 - (a - b)
21+bug a b = 0.0 - (a - b)
22
22
23foreign import explode
23foreign import explode
24 """
24 """
@@ -28,23 +28,23 @@ foreign import explode
28 """ :: forall eff a. Eff eff a
28 """ :: forall eff a. Eff eff a
29
29
30main = do
30main = do
31− assert (bug 0 2 == 2) "bug 0 2 == 2"
31+ assert (bug 0.0 2.0 == 2.0) "bug 0.0 2.0 == 2.0"
32− assert (0 - (0 - 2) == 2) "0 - (0 - 2) == 2"
32+ assert (0.0 - (0.0 - 2.0) == 2.0) "0.0 - (0.0 - 2.0) == 2.0"
33− assert (0 - (0 + 2) == -2) "0 - (0 + 2) == -2"
33+ assert (0.0 - (0.0 + 2.0) == -2.0) "0.0 - (0.0 + 2.0) == -2.0"
34
34
35− assert (6 / (3 * 2) == 1) "6 / (3 * 2) == 1"
35+ assert (6.0 / (3.0 * 2.0) == 1.0) "6.0 / (3.0 * 2.0) == 1.0"
36− assert ((6 / 3) * 2 == 4) "(6 / 3) * 2 == 4"
36+ assert ((6.0 / 3.0) * 2.0 == 4.0) "(6.0 / 3.0) * 2.0 == 4.0"
37
37
38− assert (not (1 < 0) == true) "not (1 < 0) == true"
38+ assert (not (1.0 < 0.0) == true) "not (1.0 < 0.0) == true"
39− assert (not ((negate 1) < 0) == false) "not ((negate 1) < 0) == false"
39+ assert (not ((negate 1.0) < 0.0) == false) "not ((negate 1.0) < 0.0) == false"
40
40
41− assert (negate (1 + 10) == -11) "negate (1 + 10) == -11"
41+ assert (negate (1.0 + 10.0) == -11.0) "negate (1.0 + 10.0) == -11.0"
42
42
43− assert (2 * 3 / 4 == 1.5) "2 * 3 / 4 == 1.5"
43+ assert (2.0 * 3.0 / 4.0 == 1.5) "2.0 * 3.0 / 4.0 == 1.5"
44− assert (1 * 2 * 3 * 4 * 5 / 6 == 20) "1 * 2 * 3 * 4 * 5 / 6 == 20"
44+ assert (1.0 * 2.0 * 3.0 * 4.0 * 5.0 / 6.0 == 20.0) "1.0 * 2.0 * 3.0 * 4.0 * 5.0 / 6.0 == 20.0"
45
45
46− assert (1 + 10 - 5 == 6) "1 + 10 - 5 == 6"
46+ assert (1.0 + 10.0 - 5.0 == 6.0) "1.0 + 10.0 - 5.0 == 6.0"
47− assert (1 + 10 * 5 == 51) "1 + 10 * 5 == 51"
47+ assert (1.0 + 10.0 * 5.0 == 51.0) "1.0 + 10.0 * 5.0 == 51.0"
48− assert (10 * 5 - 1 == 49) "10 * 5 - 1 == 49"
48+ assert (10.0 * 5.0 - 1.0 == 49.0) "10.0 * 5.0 - 1.0 == 49.0"
49
49
50 trace "Success!"
50 trace "Success!"
examples/passing/OperatorInlining.purs+12−12
@@ -5,26 +5,26 @@ import Debug.Trace
5main = do
5main = do
6
6
7 -- semiringNumber
7 -- semiringNumber
8− print (1 + 2)
8+ print (1.0 + 2.0)
9− print (1 * 2)
9+ print (1.0 * 2.0)
10
10
11 -- ringNumber
11 -- ringNumber
12− print (1 - 2)
12+ print (1.0 - 2.0)
13− print (negate 1)
13+ print (negate 1.0)
14
14
15 -- moduleSemiringNumber
15 -- moduleSemiringNumber
16− print (1 / 2)
16+ print (1.0 / 2.0)
17
17
18 -- ordNumber
18 -- ordNumber
19− print (1 > 2)
19+ print (1.0 > 2.0)
20− print (1 < 2)
20+ print (1.0 < 2.0)
21− print (1 <= 2)
21+ print (1.0 <= 2.0)
22− print (1 >= 2)
22+ print (1.0 >= 2.0)
23− print (1 == 2)
23+ print (1.0 == 2.0)
24
24
25 -- eqNumber
25 -- eqNumber
26− print (1 == 2)
26+ print (1.0 == 2.0)
27− print (1 /= 2)
27+ print (1.0 /= 2.0)
28
28
29 -- eqString
29 -- eqString
30 print ("foo" == "bar")
30 print ("foo" == "bar")
examples/passing/OperatorSections.purs+4−4
@@ -14,8 +14,8 @@ foreign import eqeqeq
14infixl 4 ===
14infixl 4 ===
15
15
16main = do
16main = do
17− Debug.Trace.print $ (/ 2) 4 === 2
17+ Debug.Trace.print $ (/ 2.0) 4.0 === 2.0
18− Debug.Trace.print $ (2 /) 4 === 0.5
18+ Debug.Trace.print $ (2.0 /) 4.0 === 0.5
19− Debug.Trace.print $ (`const` 1) 2 === 2
19+ Debug.Trace.print $ (`const` 1.0) 2.0 === 2.0
20− Debug.Trace.print $ (1 `const`) 2 === 1
20+ Debug.Trace.print $ (1.0 `const`) 2.0 === 1.0
21 Debug.Trace.trace "Done!"
21 Debug.Trace.trace "Done!"
examples/passing/Operators.purs+14−14
@@ -12,9 +12,9 @@ module Main where
12 test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n
12 test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n
13 test1 x y z = x * y + z x y
13 test1 x y z = x * y + z x y
14
14
15− test2 = (\x -> x.foo false) { foo : \_ -> 1 }
15+ test2 = (\x -> x.foo false) { foo : \_ -> 1.0 }
16
16
17− test3 = (\x y -> x)(1 + 2 * (1 + 2)) (true && (false || false))
17+ test3 = (\x y -> x)(1.0 + 2.0 * (1.0 + 2.0)) (true && (false || false))
18
18
19 k = \x -> \y -> x
19 k = \x -> \y -> x
20
20
@@ -25,9 +25,9 @@ module Main where
25 (%%) :: Number -> Number -> Number
25 (%%) :: Number -> Number -> Number
26 (%%) x y = x * y + y
26 (%%) x y = x * y + y
27
27
28− test5 = 1 %% 2 %% 3
28+ test5 = 1.0 %% 2.0 %% 3.0
29
29
30− test6 = ((\x -> x) `k` 2) 3
30+ test6 = ((\x -> x) `k` 2.0) 3.0
31
31
32 (<+>) :: String -> String -> String
32 (<+>) :: String -> String -> String
33 (<+>) = \s1 s2 -> s1 ++ s2
33 (<+>) = \s1 s2 -> s1 ++ s2
@@ -49,7 +49,7 @@ module Main where
49 (...) :: forall a. [a] -> [a] -> [a]
49 (...) :: forall a. [a] -> [a] -> [a]
50 (...) = \as -> \bs -> as
50 (...) = \as -> \bs -> as
51
51
52− test11 = [1, 2, 3] ... [4, 5, 6]
52+ test11 = [1.0, 2.0, 0.0] ... [4.0, 5.0, 6.0]
53
53
54 test12 (<%>) a b = a <%> b
54 test12 (<%>) a b = a <%> b
55
55
@@ -62,21 +62,21 @@ module Main where
62 test15 a b = const false $ a `test14` b
62 test15 a b = const false $ a `test14` b
63
63
64 test17 :: Number
64 test17 :: Number
65− test17 = negate (-1)
65+ test17 = negate (-1.0)
66
66
67 test18 :: Number
67 test18 :: Number
68− test18 = negate $ negate 1
68+ test18 = negate $ negate 1.0
69
69
70 test19 :: Number
70 test19 :: Number
71− test19 = negate $ negate (-1)
71+ test19 = negate $ negate (-1.0)
72
72
73 test20 :: Number
73 test20 :: Number
74− test20 = 1 @ 2
74+ test20 = 1.0 @ 2.0
75 where
75 where
76 (@) x y = x + y * y
76 (@) x y = x + y * y
77
77
78 main = do
78 main = do
79− let t1 = test1 1 2 (\x y -> x + y)
79+ let t1 = test1 1.0 2.0 (\x y -> x + y)
80 let t2 = test2
80 let t2 = test2
81 let t3 = test3
81 let t3 = test3
82 let t4 = test4
82 let t4 = test4
@@ -87,10 +87,10 @@ module Main where
87 let t9 = test9
87 let t9 = test9
88 let t10 = test10
88 let t10 = test10
89 let t11 = test11
89 let t11 = test11
90− let t12 = test12 k 1 2
90+ let t12 = test12 k 1.0 2.0
91− let t13 = test13 k 1 2
91+ let t13 = test13 k 1.0 2.0
92− let t14 = test14 1 2
92+ let t14 = test14 1.0 2.0
93− let t15 = test15 1 2
93+ let t15 = test15 1.0 2.0
94 let t17 = test17
94 let t17 = test17
95 let t18 = test18
95 let t18 = test18
96 let t19 = test19
96 let t19 = test19
examples/passing/OptimizerBug.purs+1−1
@@ -2,7 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4
4
5−x a = 1 + y a
5+x a = 1.0 + y a
6
6
7y a = x a
7y a = x a
8
8
examples/passing/PartialFunction.purs+3−3
@@ -13,7 +13,7 @@ foreign import testError
13 """ :: (Unit -> Number) -> String
13 """ :: (Unit -> Number) -> String
14
14
15fn :: Number -> Number
15fn :: Number -> Number
16−fn 0 = 0
16+fn 0.0 = 0.0
17−fn 1 = 2
17+fn 1.0 = 2.0
18
18
19−main = Debug.Trace.trace (show $ testError $ \_ -> fn 2)
19+main = Debug.Trace.trace (show $ testError $ \_ -> fn 2.0)
examples/passing/Rank2Data.purs+1−1
@@ -10,7 +10,7 @@ module Main where
10 data Nat = Nat forall r. r -> (r -> r) -> r
10 data Nat = Nat forall r. r -> (r -> r) -> r
11
11
12 runNat = \nat -> case nat of
12 runNat = \nat -> case nat of
13− Nat f -> f 0 (\n -> n + 1)
13+ Nat f -> f 0.0 (\n -> n + 1.0)
14
14
15 zero' = Nat (\zero' _ -> zero')
15 zero' = Nat (\zero' _ -> zero')
16
16
examples/passing/Rank2Object.purs+1−1
@@ -5,6 +5,6 @@ import Debug.Trace
5data Foo = Foo { id :: forall a. a -> a }
5data Foo = Foo { id :: forall a. a -> a }
6
6
7foo :: Foo -> Number
7foo :: Foo -> Number
8−foo (Foo { id = f }) = f 0
8+foo (Foo { id = f }) = f 0.0
9
9
10main = trace "Done"
10main = trace "Done"
examples/passing/Rank2TypeSynonym.purs+1−1
@@ -8,7 +8,7 @@ foo :: forall a. a -> Foo a
8foo x = pure x
8foo x = pure x
9
9
10bar :: Foo Number
10bar :: Foo Number
11−bar = foo 3
11+bar = foo 3.0
12
12
13main = do
13main = do
14 x <- bar
14 x <- bar
examples/passing/Rank2Types.purs+1−1
@@ -3,7 +3,7 @@ module Main where
3 import Prelude
3 import Prelude
4
4
5 test1 :: (forall a. (a -> a)) -> Number
5 test1 :: (forall a. (a -> a)) -> Number
6− test1 = \f -> f 0
6+ test1 = \f -> f 0.0
7
7
8 forever :: forall m a b. (forall a b. m a -> (a -> m b) -> m b) -> m a -> m b
8 forever :: forall m a b. (forall a b. m a -> (a -> m b) -> m b) -> m a -> m b
9 forever = \bind action -> bind action $ \_ -> forever bind action
9 forever = \bind action -> bind action $ \_ -> forever bind action
examples/passing/Recursion.purs+3−3
@@ -3,8 +3,8 @@ module Main where
3 import Prelude
3 import Prelude
4
4
5 fib = \n -> case n of
5 fib = \n -> case n of
6− 0 -> 1
6+ 0.0 -> 1.0
7− 1 -> 1
7+ 1.0 -> 1.0
8− n -> fib (n - 1) + fib (n - 2)
8+ n -> fib (n - 1.0) + fib (n - 2.0)
9
9
10 main = Debug.Trace.trace "Done"
10 main = Debug.Trace.trace "Done"
examples/passing/RowConstructors.purs+5−5
@@ -5,10 +5,10 @@ type Bar = (x :: Number, y :: Number, z :: Number)
5type Baz = { w :: Number | Bar }
5type Baz = { w :: Number | Bar }
6
6
7foo :: { | Foo }
7foo :: { | Foo }
8−foo = { x: 0, y: 0, z: 0 }
8+foo = { x: 0.0, y: 0.0, z: 0.0 }
9
9
10bar :: { | Bar }
10bar :: { | Bar }
11−bar = { x: 0, y: 0, z: 0 }
11+bar = { x: 0.0, y: 0.0, z: 0.0 }
12
12
13id' :: Object Foo -> Object Bar
13id' :: Object Foo -> Object Bar
14id' = id
14id' = id
@@ -20,16 +20,16 @@ bar' :: { | Bar }
20bar' = id' bar
20bar' = id' bar
21
21
22baz :: Baz
22baz :: Baz
23−baz = { x: 0, y: 0, z: 0, w: 0 }
23+baz = { x: 0.0, y: 0.0, z: 0.0, w: 0.0 }
24
24
25type Quux r = (q :: Number | r)
25type Quux r = (q :: Number | r)
26type Norf r = (q' :: Number | Quux r)
26type Norf r = (q' :: Number | Quux r)
27
27
28quux :: { f :: { | Foo } | Quux Bar }
28quux :: { f :: { | Foo } | Quux Bar }
29−quux = { f: foo', x: 0, y: 0, z: 0, q: 0 }
29+quux = { f: foo', x: 0.0, y: 0.0, z: 0.0, q: 0.0 }
30
30
31quux' :: { | Norf Bar }
31quux' :: { | Norf Bar }
32−quux' = { x: 0, y: 0, z: 0, q: 0, q': 0 }
32+quux' = { x: 0.0, y: 0.0, z: 0.0, q: 0.0, q': 0.0 }
33
33
34wildcard :: { w :: Number | _ } -> Baz
34wildcard :: { w :: Number | _ } -> Baz
35wildcard { w: w } = { x: w, y: w, z: w, w: w }
35wildcard { w: w } = { x: w, y: w, z: w, w: w }
examples/passing/RowSynonyms.purs+1−1
@@ -35,7 +35,7 @@ withIt :: forall bindings eff a. Shadow (Object bindings) ->
35 ({addition :: Number | bindings} -> Eff eff a) -> Eff eff a
35 ({addition :: Number | bindings} -> Eff eff a) -> Eff eff a
36withIt (Shadow str) success = do
36withIt (Shadow str) success = do
37 b <- withBindings
37 b <- withBindings
38− success (b{addition = 1})
38+ success (b{addition = 1.0})
39
39
40foreign import withBindings
40foreign import withBindings
41"""
41"""
examples/passing/RuntimeScopeIssue.purs+5−5
@@ -9,11 +9,11 @@ class B a where
9 b :: a -> Boolean
9 b :: a -> Boolean
10
10
11instance aNumber :: A Number where
11instance aNumber :: A Number where
12− a 0 = true
12+ a 0.0 = true
13− a n = b (n - 1)
13+ a n = b (n - 1.0)
14
14
15instance bNumber :: B Number where
15instance bNumber :: B Number where
16− b 0 = false
16+ b 0.0 = false
17− b n = a (n - 1)
17+ b n = a (n - 1.0)
18
18
19−main = Debug.Trace.print $ a 10
19+main = Debug.Trace.print $ a 10.0
examples/passing/ScopedTypeVariables.purs+1−1
@@ -16,7 +16,7 @@ test2 = h
16 g y = f (f y)
16 g y = f (f y)
17
17
18test3 :: Number
18test3 :: Number
19−test3 = ((\b -> b :: b) :: forall b. b -> b) 0
19+test3 = ((\b -> b :: b) :: forall b. b -> b) 0.0
20
20
21test4 :: forall a. (a -> a) -> a -> a
21test4 :: forall a. (a -> a) -> a -> a
22test4 = h
22test4 = h
examples/passing/ShadowedRename.purs+3−3
@@ -7,15 +7,15 @@ foreign import f
7 """
7 """
8 function f(x) {
8 function f(x) {
9 return function() {
9 return function() {
10− if (x !== 2) throw new Error('x is not 2');
10+ if (x !== 2.0) throw new Error('x is not 2.0');
11 };
11 };
12 }
12 }
13 """ :: forall e. Number -> Eff e Number
13 """ :: forall e. Number -> Eff e Number
14
14
15foo foo = let foo_1 = \_ -> foo
15foo foo = let foo_1 = \_ -> foo
16− foo_2 = foo_1 unit + 1
16+ foo_2 = foo_1 unit + 1.0
17 in foo_2
17 in foo_2
18
18
19main = do
19main = do
20− f (foo 1)
20+ f (foo 1.0)
21 trace "Done"
21 trace "Done"
examples/passing/ShadowedTCO.purs+1−1
@@ -1,6 +1,6 @@
1module Main where
1module Main where
2
2
3−runNat f = f 0 (\n -> n + 1)
3+runNat f = f 0.0 (\n -> n + 1.0)
4
4
5zero' z _ = z
5zero' z _ = z
6
6
examples/passing/ShadowedTCOLet.purs+2−2
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3f x y z =
3f x y z =
4− let f 1 2 3 = 1
4+ let f 1.0 2.0 3.0 = 1.0
5 in f x z y
5 in f x z y
6
6
7−main = Debug.Trace.trace $ show $ f 1 3 2
7+main = Debug.Trace.trace $ show $ f 1.0 3.0 2.0
examples/passing/SignedNumericLiterals.purs+4−4
@@ -1,15 +1,15 @@
1module Main where
1module Main where
2
2
3 p = 0.5
3 p = 0.5
4− q = 1
4+ q = 1.0
5− x = -1
5+ x = -1.0
6 y = -0.5
6 y = -0.5
7 z = 0.5
7 z = 0.5
8− w = 1
8+ w = 1.0
9
9
10 f :: Number -> Number
10 f :: Number -> Number
11 f x = -x
11 f x = -x
12
12
13− test1 = 2 - 1
13+ test1 = 2.0 - 1.0
14
14
15 main = Debug.Trace.trace "Done"
15 main = Debug.Trace.trace "Done"
examples/passing/Superclasses1.purs+2−2
@@ -7,7 +7,7 @@ class (Su a) <= Cl a where
7 cl :: a -> a -> a
7 cl :: a -> a -> a
8
8
9instance suNumber :: Su Number where
9instance suNumber :: Su Number where
10− su n = n + 1
10+ su n = n + 1.0
11
11
12instance clNumber :: Cl Number where
12instance clNumber :: Cl Number where
13 cl n m = n + m
13 cl n m = n + m
@@ -15,4 +15,4 @@ instance clNumber :: Cl Number where
15test :: forall a. (Cl a) => a -> a
15test :: forall a. (Cl a) => a -> a
16test a = su (cl a a)
16test a = su (cl a a)
17
17
18−main = Debug.Trace.print $ test 10
18+main = Debug.Trace.print $ test 10.0
examples/passing/Superclasses2.purs+2−2
@@ -9,7 +9,7 @@ class (Su [a]) <= Cl a where
9 cl :: a -> a -> a
9 cl :: a -> a -> a
10
10
11instance suNumber :: Su Number where
11instance suNumber :: Su Number where
12− su n = n + 1
12+ su n = n + 1.0
13
13
14instance suArray :: (Su a) => Su [a] where
14instance suArray :: (Su a) => Su [a] where
15 su (x : _) = [su x]
15 su (x : _) = [su x]
@@ -20,4 +20,4 @@ instance clNumber :: Cl Number where
20test :: forall a. (Cl a) => a -> [a]
20test :: forall a. (Cl a) => a -> [a]
21test x = su [cl x x]
21test x = su [cl x x]
22
22
23−main = Debug.Trace.print $ test 10 `unsafeIndex` 0
23+main = Debug.Trace.print $ test 10.0 `unsafeIndex` 0.0
examples/passing/Superclasses3.purs+1−1
@@ -8,7 +8,7 @@ class (Monad m) <= MonadWriter w m where
8 tell :: w -> m Unit
8 tell :: w -> m Unit
9
9
10testFunctor :: forall m. (Monad m) => m Number -> m Number
10testFunctor :: forall m. (Monad m) => m Number -> m Number
11−testFunctor n = (+) 1 <$> n
11+testFunctor n = (+) 1.0 <$> n
12
12
13test :: forall w m. (Monad m, MonadWriter w m) => w -> m Unit
13test :: forall w m. (Monad m, MonadWriter w m) => w -> m Unit
14test w = do
14test w = do
examples/passing/TCOCase.purs+3−3
@@ -2,9 +2,9 @@ module Main where
2
2
3data Data = One | More Data
3data Data = One | More Data
4
4
5−main = Debug.Trace.trace (from (to 10000 One))
5+main = Debug.Trace.trace (from (to 10000.0 One))
6 where
6 where
7− to 0 a = a
7+ to 0.0 a = a
8− to n a = to (n - 1) (More a)
8+ to n a = to (n - 1.0) (More a)
9 from One = "Done"
9 from One = "Done"
10 from (More d) = from d
10 from (More d) = from d
examples/passing/TailCall.purs+2−2
@@ -7,9 +7,9 @@ test n [] = n
7test n (x:xs) = test (n + x) xs
7test n (x:xs) = test (n + x) xs
8
8
9loop :: forall a. Number -> a
9loop :: forall a. Number -> a
10−loop x = loop (x + 1)
10+loop x = loop (x + 1.0)
11
11
12notATailCall = \x ->
12notATailCall = \x ->
13 (\notATailCall -> notATailCall x) (\x -> x)
13 (\notATailCall -> notATailCall x) (\x -> x)
14
14
15−main = Debug.Trace.print (test 0 [1, 2, 3])
15+main = Debug.Trace.print (test 0.0 [1.0, 2.0, 3.0])
examples/passing/TopLevelCase.purs+4−4
@@ -13,16 +13,16 @@ infixl 7 %
13(%) = jsMod
13(%) = jsMod
14
14
15gcd :: Number -> Number -> Number
15gcd :: Number -> Number -> Number
16−gcd 0 x = x
16+gcd 0.0 x = x
17−gcd x 0 = x
17+gcd x 0.0 = x
18gcd x y | x > y = gcd (x % y) y
18gcd x y | x > y = gcd (x % y) y
19gcd x y = gcd (y % x) x
19gcd x y = gcd (y % x) x
20
20
21−guardsTest (x:xs) | x > 0 = guardsTest xs
21+guardsTest (x:xs) | x > 0.0 = guardsTest xs
22guardsTest xs = xs
22guardsTest xs = xs
23
23
24data A = A
24data A = A
25
25
26−parseTest A 0 = 0
26+parseTest A 0.0 = 0.0
27
27
28main = Debug.Trace.trace "Done"
28main = Debug.Trace.trace "Done"
examples/passing/TypeClasses.purs+4−4
@@ -53,17 +53,17 @@ instance bindMaybe :: Bind Maybe where
53instance monadMaybe :: Monad Maybe
53instance monadMaybe :: Monad Maybe
54
54
55test4 :: forall a m. (Monad m) => a -> m Number
55test4 :: forall a m. (Monad m) => a -> m Number
56−test4 = \_ -> return 1
56+test4 = \_ -> return 1.0
57
57
58−test5 = \_ -> Just 1 >>= \n -> return (n + 1)
58+test5 = \_ -> Just 1.0 >>= \n -> return (n + 1.0)
59
59
60ask r = r
60ask r = r
61
61
62runReader r f = f r
62runReader r f = f r
63
63
64−test9 _ = runReader 0 $ do
64+test9 _ = runReader 0.0 $ do
65 n <- ask
65 n <- ask
66− return $ n + 1
66+ return $ n + 1.0
67
67
68main = Debug.Trace.trace (test7 "Done")
68main = Debug.Trace.trace (test7 "Done")
69
69
examples/passing/TypeDecl.purs+2−2
@@ -6,7 +6,7 @@ module Main where
6 k x y = x
6 k x y = x
7
7
8 iterate :: forall a. Number -> (a -> a) -> a -> a
8 iterate :: forall a. Number -> (a -> a) -> a -> a
9− iterate 0 f a = a
9+ iterate 0.0 f a = a
10− iterate n f a = iterate (n - 1) f (f a)
10+ iterate n f a = iterate (n - 1.0) f (f a)
11
11
12 main = Debug.Trace.trace "Done"
12 main = Debug.Trace.trace "Done"
examples/passing/TypeWildcards.purs+1−1
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3testTopLevel :: _ -> _
3testTopLevel :: _ -> _
4−testTopLevel n = n + 1
4+testTopLevel n = n + 1.0
5
5
6test :: forall a. (Eq a) => (a -> a) -> a -> a
6test :: forall a. (Eq a) => (a -> a) -> a -> a
7test f a = go (f a) a
7test f a = go (f a) a
examples/passing/UnknownInTypeClassLookup.purs+1−1
@@ -9,4 +9,4 @@ test _ _ = "Done"
9
9
10runTest a = test a a
10runTest a = test a a
11
11
12−main = Debug.Trace.trace $ runTest 0
12+main = Debug.Trace.trace $ runTest 0.0
examples/passing/Where.purs+14−14
@@ -7,29 +7,29 @@ import Control.Monad.ST
7test1 x = y
7test1 x = y
8 where
8 where
9 y :: Number
9 y :: Number
10− y = x + 1
10+ y = x + 1.0
11
11
12test2 x y = x' + y'
12test2 x y = x' + y'
13 where
13 where
14− x' = x + 1
14+ x' = x + 1.0
15− y' = y + 1
15+ y' = y + 1.0
16
16
17
17
18−test3 = f 1 2 3
18+test3 = f 1.0 2.0 3.0
19 where f x y z = x + y + z
19 where f x y z = x + y + z
20
20
21
21
22−test4 = f (+) [1, 2]
22+test4 = f (+) [1.0, 2.0]
23 where f x [y, z] = x y z
23 where f x [y, z] = x y z
24
24
25
25
26−test5 = g 10
26+test5 = g 10.0
27 where
27 where
28− f x | x > 0 = g (x / 2) + 1
28+ f x | x > 0.0 = g (x / 2.0) + 1.0
29− f x = 0
29+ f x = 0.0
30− g x = f (x - 1) + 1
30+ g x = f (x - 1.0) + 1.0
31
31
32−test6 = if f true then f 1 else f 2
32+test6 = if f true then f 1.0 else f 2.0
33 where f :: forall a. a -> a
33 where f :: forall a. a -> a
34 f x = x
34 f x = x
35
35
@@ -37,13 +37,13 @@ test7 :: Number -> Number
37test7 x = go x
37test7 x = go x
38 where
38 where
39 go y | (x - 0.1 < y * y) && (y * y < x + 0.1) = y
39 go y | (x - 0.1 < y * y) && (y * y < x + 0.1) = y
40− go y = go $ (y + x / y) / 2
40+ go y = go $ (y + x / y) / 2.0
41
41
42main = do
42main = do
43− Debug.Trace.print (test1 1)
43+ Debug.Trace.print (test1 1.0)
44− Debug.Trace.print (test2 1 2)
44+ Debug.Trace.print (test2 1.0 2.0)
45 Debug.Trace.print test3
45 Debug.Trace.print test3
46 Debug.Trace.print test4
46 Debug.Trace.print test4
47 Debug.Trace.print test5
47 Debug.Trace.print test5
48 Debug.Trace.print test6
48 Debug.Trace.print test6
49− Debug.Trace.print (test7 100)
49+ Debug.Trace.print (test7 100.0)
psc-docs/Main.hs+1−1
@@ -207,7 +207,7 @@ prettyPrintType' :: P.Type -> String
207prettyPrintType' = P.prettyPrintType . P.everywhereOnTypes dePrim
207prettyPrintType' = P.prettyPrintType . P.everywhereOnTypes dePrim
208 where
208 where
209 dePrim ty@(P.TypeConstructor (P.Qualified _ name))
209 dePrim ty@(P.TypeConstructor (P.Qualified _ name))
210− | ty == P.tyBoolean || ty == P.tyNumber || ty == P.tyString =
210+ | ty == P.tyBoolean || ty == P.tyNumber || ty == P.tyString || ty == P.tyChar || ty == P.tyInt =
211 P.TypeConstructor $ P.Qualified Nothing name
211 P.TypeConstructor $ P.Qualified Nothing name
212 dePrim other = other
212 dePrim other = other
213
213
src/Language/PureScript/AST/Binders.hs+4
@@ -39,6 +39,10 @@ data Binder
39 --
39 --
40 | StringBinder String
40 | StringBinder String
41 -- |
41 -- |
42+ -- A binder which matches a character literal
43+ --
44+ | CharBinder Char
45+ -- |
42 -- A binder which matches a numeric literal
46 -- A binder which matches a numeric literal
43 --
47 --
44 | NumberBinder (Either Integer Double)
48 | NumberBinder (Either Integer Double)
src/Language/PureScript/AST/Declarations.hs+4
@@ -302,6 +302,10 @@ data Expr
302 --
302 --
303 | StringLiteral String
303 | StringLiteral String
304 -- |
304 -- |
305+ -- A character literal
306+ --
307+ | CharLiteral Char
308+ -- |
305 -- A boolean literal
309 -- A boolean literal
306 --
310 --
307 | BooleanLiteral Bool
311 | BooleanLiteral Bool
src/Language/PureScript/CodeGen/JS.hs+3
@@ -206,6 +206,7 @@ moduleToJs (Module coms mn imps exps foreigns decls) = do
206 literalToValueJS :: Literal (Expr Ann) -> m JS
206 literalToValueJS :: Literal (Expr Ann) -> m JS
207 literalToValueJS (NumericLiteral n) = return $ JSNumericLiteral n
207 literalToValueJS (NumericLiteral n) = return $ JSNumericLiteral n
208 literalToValueJS (StringLiteral s) = return $ JSStringLiteral s
208 literalToValueJS (StringLiteral s) = return $ JSStringLiteral s
209+ literalToValueJS (CharLiteral c) = return $ JSStringLiteral [c]
209 literalToValueJS (BooleanLiteral b) = return $ JSBooleanLiteral b
210 literalToValueJS (BooleanLiteral b) = return $ JSBooleanLiteral b
210 literalToValueJS (ArrayLiteral xs) = JSArrayLiteral <$> mapM valueToJs xs
211 literalToValueJS (ArrayLiteral xs) = JSArrayLiteral <$> mapM valueToJs xs
211 literalToValueJS (ObjectLiteral ps) = JSObjectLiteral <$> mapM (sndM valueToJs) ps
212 literalToValueJS (ObjectLiteral ps) = JSObjectLiteral <$> mapM (sndM valueToJs) ps
@@ -340,6 +341,8 @@ moduleToJs (Module coms mn imps exps foreigns decls) = do
340 literalToBinderJS :: String -> [JS] -> Literal (Binder Ann) -> m [JS]
341 literalToBinderJS :: String -> [JS] -> Literal (Binder Ann) -> m [JS]
341 literalToBinderJS varName done (NumericLiteral num) =
342 literalToBinderJS varName done (NumericLiteral num) =
342 return [JSIfElse (JSBinary EqualTo (JSVar varName) (JSNumericLiteral num)) (JSBlock done) Nothing]
343 return [JSIfElse (JSBinary EqualTo (JSVar varName) (JSNumericLiteral num)) (JSBlock done) Nothing]
344+ literalToBinderJS varName done (CharLiteral c) =
345+ return [JSIfElse (JSBinary EqualTo (JSVar varName) (JSStringLiteral [c])) (JSBlock done) Nothing]
343 literalToBinderJS varName done (StringLiteral str) =
346 literalToBinderJS varName done (StringLiteral str) =
344 return [JSIfElse (JSBinary EqualTo (JSVar varName) (JSStringLiteral str)) (JSBlock done) Nothing]
347 return [JSIfElse (JSBinary EqualTo (JSVar varName) (JSStringLiteral str)) (JSBlock done) Nothing]
345 literalToBinderJS varName done (BooleanLiteral True) =
348 literalToBinderJS varName done (BooleanLiteral True) =
src/Language/PureScript/CoreFn/Desugar.hs+4
@@ -83,6 +83,8 @@ moduleToCoreFn env (A.Module coms mn decls (Just exps)) =
83 Literal (ss, com, ty, Nothing) (NumericLiteral v)
83 Literal (ss, com, ty, Nothing) (NumericLiteral v)
84 exprToCoreFn ss com ty (A.StringLiteral v) =
84 exprToCoreFn ss com ty (A.StringLiteral v) =
85 Literal (ss, com, ty, Nothing) (StringLiteral v)
85 Literal (ss, com, ty, Nothing) (StringLiteral v)
86+ exprToCoreFn ss com ty (A.CharLiteral v) =
87+ Literal (ss, com, ty, Nothing) (CharLiteral v)
86 exprToCoreFn ss com ty (A.BooleanLiteral v) =
88 exprToCoreFn ss com ty (A.BooleanLiteral v) =
87 Literal (ss, com, ty, Nothing) (BooleanLiteral v)
89 Literal (ss, com, ty, Nothing) (BooleanLiteral v)
88 exprToCoreFn ss com ty (A.ArrayLiteral vs) =
90 exprToCoreFn ss com ty (A.ArrayLiteral vs) =
@@ -147,6 +149,8 @@ moduleToCoreFn env (A.Module coms mn decls (Just exps)) =
147 LiteralBinder (ss, com, Nothing, Nothing) (BooleanLiteral b)
149 LiteralBinder (ss, com, Nothing, Nothing) (BooleanLiteral b)
148 binderToCoreFn ss com (A.StringBinder s) =
150 binderToCoreFn ss com (A.StringBinder s) =
149 LiteralBinder (ss, com, Nothing, Nothing) (StringLiteral s)
151 LiteralBinder (ss, com, Nothing, Nothing) (StringLiteral s)
152+ binderToCoreFn ss com (A.CharBinder c) =
153+ LiteralBinder (ss, com, Nothing, Nothing) (CharLiteral c)
150 binderToCoreFn ss com (A.NumberBinder n) =
154 binderToCoreFn ss com (A.NumberBinder n) =
151 LiteralBinder (ss, com, Nothing, Nothing) (NumericLiteral n)
155 LiteralBinder (ss, com, Nothing, Nothing) (NumericLiteral n)
152 binderToCoreFn ss com (A.VarBinder name) =
156 binderToCoreFn ss com (A.VarBinder name) =
src/Language/PureScript/CoreFn/Literals.hs+4
@@ -33,6 +33,10 @@ data Literal a
33 --
33 --
34 | StringLiteral String
34 | StringLiteral String
35 -- |
35 -- |
36+ -- A character literal
37+ --
38+ | CharLiteral Char
39+ -- |
36 -- A boolean literal
40 -- A boolean literal
37 --
41 --
38 | BooleanLiteral Bool
42 | BooleanLiteral Bool
src/Language/PureScript/Environment.hs+14
@@ -184,12 +184,24 @@ tyFunction = primTy "Function"
184tyString :: Type
184tyString :: Type
185tyString = primTy "String"
185tyString = primTy "String"
186
186
187+-- |
188+-- Type constructor for strings
189+--
190+tyChar :: Type
191+tyChar = primTy "Char"
192+
187-- |
193-- |
188-- Type constructor for numbers
194-- Type constructor for numbers
189--
195--
190tyNumber :: Type
196tyNumber :: Type
191tyNumber = primTy "Number"
197tyNumber = primTy "Number"
192
198
199+-- |
200+-- Type constructor for integers
201+--
202+tyInt :: Type
203+tyInt = primTy "Int"
204+
193-- |
205-- |
194-- Type constructor for booleans
206-- Type constructor for booleans
195--
207--
@@ -222,7 +234,9 @@ primTypes = M.fromList [ (primName "Function" , (FunKind Star (FunKind Star Star
222 , (primName "Array" , (FunKind Star Star, ExternData))
234 , (primName "Array" , (FunKind Star Star, ExternData))
223 , (primName "Object" , (FunKind (Row Star) Star, ExternData))
235 , (primName "Object" , (FunKind (Row Star) Star, ExternData))
224 , (primName "String" , (Star, ExternData))
236 , (primName "String" , (Star, ExternData))
237+ , (primName "Char" , (Star, ExternData))
225 , (primName "Number" , (Star, ExternData))
238 , (primName "Number" , (Star, ExternData))
239+ , (primName "Int" , (Star, ExternData))
226 , (primName "Boolean" , (Star, ExternData)) ]
240 , (primName "Boolean" , (Star, ExternData)) ]
227
241
228-- |
242-- |
src/Language/PureScript/Parser/Declarations.hs+9
@@ -284,6 +284,9 @@ booleanLiteral = (reserved "true" >> return True) P.<|> (reserved "false" >> ret
284parseNumericLiteral :: TokenParser Expr
284parseNumericLiteral :: TokenParser Expr
285parseNumericLiteral = NumericLiteral <$> number
285parseNumericLiteral = NumericLiteral <$> number
286
286
287+parseCharLiteral :: TokenParser Expr
288+parseCharLiteral = CharLiteral <$> charLiteral
289+
287parseStringLiteral :: TokenParser Expr
290parseStringLiteral :: TokenParser Expr
288parseStringLiteral = StringLiteral <$> stringLiteral
291parseStringLiteral = StringLiteral <$> stringLiteral
289
292
@@ -350,6 +353,7 @@ parseLet = do
350parseValueAtom :: TokenParser Expr
353parseValueAtom :: TokenParser Expr
351parseValueAtom = P.choice
354parseValueAtom = P.choice
352 [ P.try parseNumericLiteral
355 [ P.try parseNumericLiteral
356+ , P.try parseCharLiteral
353 , P.try parseStringLiteral
357 , P.try parseStringLiteral
354 , P.try parseBooleanLiteral
358 , P.try parseBooleanLiteral
355 , parseArrayLiteral
359 , parseArrayLiteral
@@ -442,6 +446,9 @@ parseObjectUpdaterWildcard = underscore *> C.indented *> parseUpdaterBody Nothin
442parseStringBinder :: TokenParser Binder
446parseStringBinder :: TokenParser Binder
443parseStringBinder = StringBinder <$> stringLiteral
447parseStringBinder = StringBinder <$> stringLiteral
444
448
449+parseCharBinder :: TokenParser Binder
450+parseCharBinder = CharBinder <$> charLiteral
451+
445parseBooleanBinder :: TokenParser Binder
452parseBooleanBinder :: TokenParser Binder
446parseBooleanBinder = BooleanBinder <$> booleanLiteral
453parseBooleanBinder = BooleanBinder <$> booleanLiteral
447
454
@@ -492,6 +499,7 @@ parseBinder = withSourceSpan PositionedBinder (P.buildExpressionParser operators
492 parseBinderAtom :: TokenParser Binder
499 parseBinderAtom :: TokenParser Binder
493 parseBinderAtom = P.choice (map P.try
500 parseBinderAtom = P.choice (map P.try
494 [ parseNullBinder
501 [ parseNullBinder
502+ , parseCharBinder
495 , parseStringBinder
503 , parseStringBinder
496 , parseBooleanBinder
504 , parseBooleanBinder
497 , parseNumberBinder
505 , parseNumberBinder
@@ -508,6 +516,7 @@ parseBinder = withSourceSpan PositionedBinder (P.buildExpressionParser operators
508parseBinderNoParens :: TokenParser Binder
516parseBinderNoParens :: TokenParser Binder
509parseBinderNoParens = P.choice (map P.try
517parseBinderNoParens = P.choice (map P.try
510 [ parseNullBinder
518 [ parseNullBinder
519+ , parseCharBinder
511 , parseStringBinder
520 , parseStringBinder
512 , parseBooleanBinder
521 , parseBooleanBinder
513 , parseNumberBinder
522 , parseNumberBinder
src/Language/PureScript/Parser/Lexer.hs+13
@@ -61,6 +61,7 @@ module Language.PureScript.Parser.Lexer
61 , symbol
61 , symbol
62 , symbol'
62 , symbol'
63 , identifier
63 , identifier
64+ , charLiteral
64 , stringLiteral
65 , stringLiteral
65 , number
66 , number
66 , natural
67 , natural
@@ -111,6 +112,7 @@ data Token
111 | UName String
112 | UName String
112 | Qualifier String
113 | Qualifier String
113 | Symbol String
114 | Symbol String
115+ | CharLiteral Char
114 | StringLiteral String
116 | StringLiteral String
115 | Number (Either Integer Double)
117 | Number (Either Integer Double)
116 deriving (Show, Eq, Ord)
118 deriving (Show, Eq, Ord)
@@ -141,6 +143,7 @@ prettyPrintToken (LName s) = show s
141prettyPrintToken (UName s) = show s
143prettyPrintToken (UName s) = show s
142prettyPrintToken (Qualifier _) = "qualifier"
144prettyPrintToken (Qualifier _) = "qualifier"
143prettyPrintToken (Symbol s) = s
145prettyPrintToken (Symbol s) = s
146+prettyPrintToken (CharLiteral c) = show c
144prettyPrintToken (StringLiteral s) = show s
147prettyPrintToken (StringLiteral s) = show s
145prettyPrintToken (Number n) = either show show n
148prettyPrintToken (Number n) = either show show n
146
149
@@ -204,6 +207,7 @@ parseToken = P.choice
204 , do uName <- parseUName
207 , do uName <- parseUName
205 (guard (validModuleName uName) >> Qualifier uName <$ P.char '.') <|> pure (UName uName)
208 (guard (validModuleName uName) >> Qualifier uName <$ P.char '.') <|> pure (UName uName)
206 , Symbol <$> parseSymbol
209 , Symbol <$> parseSymbol
210+ , CharLiteral <$> parseCharLiteral
207 , StringLiteral <$> parseStringLiteral
211 , StringLiteral <$> parseStringLiteral
208 , Number <$> parseNumber
212 , Number <$> parseNumber
209 ] <* whitespace
213 ] <* whitespace
@@ -230,6 +234,9 @@ parseToken = P.choice
230 symbolChar :: P.Parsec String u Char
234 symbolChar :: P.Parsec String u Char
231 symbolChar = P.oneOf opChars
235 symbolChar = P.oneOf opChars
232
236
237+ parseCharLiteral :: P.Parsec String u Char
238+ parseCharLiteral = PT.charLiteral tokenParser
239+
233 parseStringLiteral :: P.Parsec String u String
240 parseStringLiteral :: P.Parsec String u String
234 parseStringLiteral = blockString <|> PT.stringLiteral tokenParser
241 parseStringLiteral = blockString <|> PT.stringLiteral tokenParser
235 where
242 where
@@ -433,6 +440,12 @@ symbol' s = token go P.<?> show s
433 go LFatArrow | s == "<=" = Just ()
440 go LFatArrow | s == "<=" = Just ()
434 go _ = Nothing
441 go _ = Nothing
435
442
443+charLiteral :: TokenParser Char
444+charLiteral = token go P.<?> "char literal"
445+ where
446+ go (CharLiteral c) = Just c
447+ go _ = Nothing
448+
436stringLiteral :: TokenParser String
449stringLiteral :: TokenParser String
437stringLiteral = token go P.<?> "string literal"
450stringLiteral = token go P.<?> "string literal"
438 where
451 where
src/Language/PureScript/Pretty/Values.hs+2
@@ -37,6 +37,7 @@ literals = mkPattern' match
37 match :: Expr -> StateT PrinterState Maybe String
37 match :: Expr -> StateT PrinterState Maybe String
38 match (NumericLiteral n) = return $ either show show n
38 match (NumericLiteral n) = return $ either show show n
39 match (StringLiteral s) = return $ show s
39 match (StringLiteral s) = return $ show s
40+ match (CharLiteral c) = return $ show c
40 match (BooleanLiteral True) = return "true"
41 match (BooleanLiteral True) = return "true"
41 match (BooleanLiteral False) = return "false"
42 match (BooleanLiteral False) = return "false"
42 match (ArrayLiteral xs) = concat <$> sequence
43 match (ArrayLiteral xs) = concat <$> sequence
@@ -193,6 +194,7 @@ prettyPrintBinderAtom = mkPattern' match
193 match :: Binder -> StateT PrinterState Maybe String
194 match :: Binder -> StateT PrinterState Maybe String
194 match NullBinder = return "_"
195 match NullBinder = return "_"
195 match (StringBinder str) = return $ show str
196 match (StringBinder str) = return $ show str
197+ match (CharBinder c) = return $ show c
196 match (NumberBinder num) = return $ either show show num
198 match (NumberBinder num) = return $ either show show num
197 match (BooleanBinder True) = return "true"
199 match (BooleanBinder True) = return "true"
198 match (BooleanBinder False) = return "false"
200 match (BooleanBinder False) = return "false"
src/Language/PureScript/TypeChecker/Types.hs+11−3
@@ -212,8 +212,10 @@ infer val = rethrow (onErrorMessages (ErrorInferringType val)) $ infer' val
212-- Infer a type for a value
212-- Infer a type for a value
213--
213--
214infer' :: Expr -> UnifyT Type Check Expr
214infer' :: Expr -> UnifyT Type Check Expr
215+infer' v@(NumericLiteral (Left _)) = return $ TypedValue True v tyInt
215−infer' v@(NumericLiteral _) = return $ TypedValue True v tyNumber
216+infer' v@(NumericLiteral (Right _)) = return $ TypedValue True v tyNumber
216infer' v@(StringLiteral _) = return $ TypedValue True v tyString
217infer' v@(StringLiteral _) = return $ TypedValue True v tyString
218+infer' v@(CharLiteral _) = return $ TypedValue True v tyChar
217infer' v@(BooleanLiteral _) = return $ TypedValue True v tyBoolean
219infer' v@(BooleanLiteral _) = return $ TypedValue True v tyBoolean
218infer' (ArrayLiteral vals) = do
220infer' (ArrayLiteral vals) = do
219 ts <- mapM infer vals
221 ts <- mapM infer vals
@@ -350,7 +352,9 @@ inferProperty _ _ = return Nothing
350inferBinder :: Type -> Binder -> UnifyT Type Check (M.Map Ident Type)
352inferBinder :: Type -> Binder -> UnifyT Type Check (M.Map Ident Type)
351inferBinder _ NullBinder = return M.empty
353inferBinder _ NullBinder = return M.empty
352inferBinder val (StringBinder _) = val =?= tyString >> return M.empty
354inferBinder val (StringBinder _) = val =?= tyString >> return M.empty
355+inferBinder val (CharBinder _) = val =?= tyChar >> return M.empty
356+inferBinder val (NumberBinder (Left _)) = val =?= tyInt >> return M.empty
353−inferBinder val (NumberBinder _) = val =?= tyNumber >> return M.empty
357+inferBinder val (NumberBinder (Right _)) = val =?= tyNumber >> return M.empty
354inferBinder val (BooleanBinder _) = val =?= tyBoolean >> return M.empty
358inferBinder val (BooleanBinder _) = val =?= tyBoolean >> return M.empty
355inferBinder val (VarBinder name) = return $ M.singleton name val
359inferBinder val (VarBinder name) = return $ M.singleton name val
356inferBinder val (ConstructorBinder ctor binders) = do
360inferBinder val (ConstructorBinder ctor binders) = do
@@ -458,10 +462,14 @@ check' val u@(TUnknown _) = do
458 (val'', ty') <- instantiatePolyTypeWithUnknowns val' ty
462 (val'', ty') <- instantiatePolyTypeWithUnknowns val' ty
459 ty' =?= u
463 ty' =?= u
460 return $ TypedValue True val'' ty'
464 return $ TypedValue True val'' ty'
461−check' v@(NumericLiteral _) t | t == tyNumber =
465+check' v@(NumericLiteral (Left _)) t | t == tyInt =
466+ return $ TypedValue True v t
467+check' v@(NumericLiteral (Right _)) t | t == tyNumber =
462 return $ TypedValue True v t
468 return $ TypedValue True v t
463check' v@(StringLiteral _) t | t == tyString =
469check' v@(StringLiteral _) t | t == tyString =
464 return $ TypedValue True v t
470 return $ TypedValue True v t
471+check' v@(CharLiteral _) t | t == tyChar =
472+ return $ TypedValue True v t
465check' v@(BooleanLiteral _) t | t == tyBoolean =
473check' v@(BooleanLiteral _) t | t == tyBoolean =
466 return $ TypedValue True v t
474 return $ TypedValue True v t
467check' (ArrayLiteral vals) t@(TypeApp a ty) = do
475check' (ArrayLiteral vals) t@(TypeApp a ty) = do
tests/prelude.purs+4−4
@@ -194,9 +194,9 @@ module Prelude
194
194
195 instance semiringNumber :: Semiring Number where
195 instance semiringNumber :: Semiring Number where
196 (+) = numAdd
196 (+) = numAdd
197− zero = 0
197+ zero = 0.0
198 (*) = numMul
198 (*) = numMul
199− one = 1
199+ one = 1.0
200
200
201 instance semiringUnit :: Semiring Unit where
201 instance semiringUnit :: Semiring Unit where
202 (+) _ _ = unit
202 (+) _ _ = unit
@@ -226,7 +226,7 @@ module Prelude
226
226
227 instance moduloSemiringNumber :: ModuloSemiring Number where
227 instance moduloSemiringNumber :: ModuloSemiring Number where
228 (/) = numDiv
228 (/) = numDiv
229− mod _ _ = 0
229+ mod _ _ = 0.0
230
230
231 instance moduloSemiringUnit :: ModuloSemiring Unit where
231 instance moduloSemiringUnit :: ModuloSemiring Unit where
232 (/) _ _ = unit
232 (/) _ _ = unit
@@ -1042,4 +1042,4 @@ module Control.Monad.ST where
1042 """ :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
1042 """ :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
1043
1043
1044 pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
1044 pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
1045− pureST st = runPure (runST st)
1045+ pureST st = runPure (runST st)