git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update prelude to use Haskell named (JS reserved keywords)
db2b0efPhil Freeman
libraries/prelude/prelude.purs+21−21
@@ -9,8 +9,8 @@ module Prelude where
9 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
9 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
10 flip f b a = f a b
10 flip f b a = f a b
11
11
12− konst :: forall a b. a -> b -> a
12+ const :: forall a b. a -> b -> a
13− konst a _ = a
13+ const a _ = a
14
14
15 infixr 9 >>>
15 infixr 9 >>>
16 infixr 9 <<<
16 infixr 9 <<<
@@ -82,15 +82,15 @@ module Prelude where
82 (<|>) :: forall a. f a -> f a -> f a
82 (<|>) :: forall a. f a -> f a -> f a
83
83
84 class Monad m where
84 class Monad m where
85− ret :: forall a. a -> m a
85+ return :: forall a. a -> m a
86 (>>=) :: forall a b. m a -> (a -> m b) -> m b
86 (>>=) :: forall a b. m a -> (a -> m b) -> m b
87
87
88 instance (Monad m) => Applicative m where
88 instance (Monad m) => Applicative m where
89− pure = ret
89+ pure = return
90 (<*>) f a = do
90 (<*>) f a = do
91 f' <- f
91 f' <- f
92 a' <- a
92 a' <- a
93− ret (f' a')
93+ return (f' a')
94
94
95 infixl 7 *
95 infixl 7 *
96 infixl 7 /
96 infixl 7 /
@@ -362,7 +362,7 @@ module Monoid where
362 class Monoid m where
362 class Monoid m where
363 mempty :: m
363 mempty :: m
364 (<>) :: m -> m -> m
364 (<>) :: m -> m -> m
365−
365+
366 instance Monoid String where
366 instance Monoid String where
367 mempty = ""
367 mempty = ""
368 (<>) = (++)
368 (<>) = (++)
@@ -377,18 +377,18 @@ module Monad where
377 import Arrays
377 import Arrays
378
378
379 replicateM :: forall m a. (Monad m) => Number -> m a -> m [a]
379 replicateM :: forall m a. (Monad m) => Number -> m a -> m [a]
380− replicateM 0 _ = ret []
380+ replicateM 0 _ = return []
381 replicateM n m = do
381 replicateM n m = do
382 a <- m
382 a <- m
383 as <- replicateM (n - 1) m
383 as <- replicateM (n - 1) m
384− ret (a : as)
384+ return (a : as)
385
385
386 mapM :: forall m a b. (Monad m) => (a -> m b) -> [a] -> m [b]
386 mapM :: forall m a b. (Monad m) => (a -> m b) -> [a] -> m [b]
387− mapM _ [] = ret []
387+ mapM _ [] = return []
388 mapM f (a:as) = do
388 mapM f (a:as) = do
389 b <- f a
389 b <- f a
390 bs <- mapM f as
390 bs <- mapM f as
391− ret (b : bs)
391+ return (b : bs)
392
392
393 infixr 1 >=>
393 infixr 1 >=>
394 infixr 1 <=<
394 infixr 1 <=<
@@ -397,16 +397,16 @@ module Monad where
397 (>=>) f g a = do
397 (>=>) f g a = do
398 b <- f a
398 b <- f a
399 g b
399 g b
400−
400+
401− (<=<) :: forall m a b c. (Monad m) => (b -> m c) -> (a -> m b) -> a -> m c
401+ (<=<) :: forall m a b c. (Monad m) => (b -> m c) -> (a -> m b) -> a -> m c
402 (<=<) = flip (>=>)
402 (<=<) = flip (>=>)
403
403
404 sequence :: forall m a. (Monad m) => [m a] -> m [a]
404 sequence :: forall m a. (Monad m) => [m a] -> m [a]
405− sequence [] = ret []
405+ sequence [] = return []
406 sequence (m:ms) = do
406 sequence (m:ms) = do
407 a <- m
407 a <- m
408 as <- sequence ms
408 as <- sequence ms
409− ret (a : as)
409+ return (a : as)
410
410
411 join :: forall m a. (Monad m) => m (m a) -> m a
411 join :: forall m a. (Monad m) => m (m a) -> m a
412 join mm = do
412 join mm = do
@@ -414,12 +414,12 @@ module Monad where
414 m
414 m
415
415
416 foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> [b] -> m a
416 foldM :: forall m a b. (Monad m) => (a -> b -> m a) -> a -> [b] -> m a
417− foldM _ a [] = ret a
417+ foldM _ a [] = return a
418 foldM f a (b:bs) = f a b >>= \a' -> foldM f a' bs
418 foldM f a (b:bs) = f a b >>= \a' -> foldM f a' bs
419
419
420 when :: forall m. (Monad m) => Boolean -> m {} -> m {}
420 when :: forall m. (Monad m) => Boolean -> m {} -> m {}
421 when true m = m
421 when true m = m
422− when false _ = ret {}
422+ when false _ = return {}
423
423
424module Maybe where
424module Maybe where
425
425
@@ -435,7 +435,7 @@ module Maybe where
435 fromMaybe a = maybe a (Prelude.id :: forall a. a -> a)
435 fromMaybe a = maybe a (Prelude.id :: forall a. a -> a)
436
436
437 instance Prelude.Monad Maybe where
437 instance Prelude.Monad Maybe where
438− ret = Just
438+ return = Just
439 (>>=) m f = maybe Nothing f m
439 (>>=) m f = maybe Nothing f m
440
440
441module Either where
441module Either where
@@ -447,7 +447,7 @@ module Either where
447 either _ g (Right b) = g b
447 either _ g (Right b) = g b
448
448
449 instance Prelude.Monad (Either e) where
449 instance Prelude.Monad (Either e) where
450− ret = Right
450+ return = Right
451 (>>=) = either (\e _ -> Left e) (\a f -> f a)
451 (>>=) = either (\e _ -> Left e) (\a f -> f a)
452
452
453module Arrays where
453module Arrays where
@@ -604,7 +604,7 @@ module Arrays where
604 show (x:xs) = show x ++ " : " ++ show xs
604 show (x:xs) = show x ++ " : " ++ show xs
605
605
606 instance Prelude.Monad [] where
606 instance Prelude.Monad [] where
607− ret = singleton
607+ return = singleton
608 (>>=) = concatMap
608 (>>=) = concatMap
609
609
610 instance Prelude.Alternative [] where
610 instance Prelude.Alternative [] where
@@ -886,7 +886,7 @@ module Eff where
886 \}" :: forall a. Pure a -> a
886 \}" :: forall a. Pure a -> a
887
887
888 instance Prelude.Monad (Eff e) where
888 instance Prelude.Monad (Eff e) where
889− ret = retEff
889+ return = retEff
890 (>>=) = bindEff
890 (>>=) = bindEff
891
891
892 foreign import untilE "function untilE(f) {\
892 foreign import untilE "function untilE(f) {\
@@ -906,7 +906,7 @@ module Eff where
906 \ };\
906 \ };\
907 \ };\
907 \ };\
908 \}" :: forall e. Eff e Boolean -> Eff e {} -> Eff e {}
908 \}" :: forall e. Eff e Boolean -> Eff e {} -> Eff e {}
909−
909+
910 foreign import forE "function forE(lo) {\
910 foreign import forE "function forE(lo) {\
911 \ return function(hi) {\
911 \ return function(hi) {\
912 \ return function(f) {\
912 \ return function(f) {\
libraries/prelude/tests/Eff.purs+11−11
@@ -5,27 +5,27 @@ import Eff
5import Errors
5import Errors
6import Trace
6import Trace
7import Global
7import Global
8−
8+
9−test1 n = runPure (catchError (\s -> ret 0) $ do
9+test1 n = runPure (catchError (\s -> return 0) $ do
10− case {} of
10+ case {} of
11 _ | n > 10 -> do
11 _ | n > 10 -> do
12− throwError "Error!"
12+ throwError "Error!"
13− _ -> ret n)
13+ _ -> return n)
14
14
15test2 = do
15test2 = do
16 trace "Hello World"
16 trace "Hello World"
17 throwError "Error!"
17 throwError "Error!"
18
18
19−test3 n = catchError (\s -> ret 0) $ do
19+test3 n = catchError (\s -> return 0) $ do
20− case {} of
20+ case {} of
21 _ | n > 10 -> do
21 _ | n > 10 -> do
22 trace "n > 10"
22 trace "n > 10"
23− throwError "Error!"
23+ throwError "Error!"
24− _ -> ret n
24+ _ -> return n
25
25
26test4 = do
26test4 = do
27 trace "Hello World!"
27 trace "Hello World!"
28− ret 0
28+ return 0
29
29
30test5 = do
30test5 = do
31 trace "Hello World!"
31 trace "Hello World!"
@@ -52,7 +52,7 @@ test9 _ = do
52 n <- readSTRef r
52 n <- readSTRef r
53 trace $ "Count " ++ show n
53 trace $ "Count " ++ show n
54 modifySTRef r $ (+) 1
54 modifySTRef r $ (+) 1
55− ret false
55+ return false
56
56
57module Main where
57module Main where
58
58