git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update prelude to use Haskell named (JS reserved keywords)
commitdb2b0ef0ecff05578c0ae832b0330f9a77348dfa authorPhil Freeman <paf31@cantab.net> dateThu 6 Feb 2014, 15:21 (13 years ago) parentd71ddee
2 files changed+32−32
libraries/prelude/prelude.purs+21−21 libraries/prelude/tests/Eff.purs+11−11
libraries/prelude/prelude.purs+21−21
@@ -9,8 +9,8 @@ module Prelude where
99 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
1010 flip f b a = f a b
1111
12− konst :: forall a b. a -> b -> a
13− konst a _ = a
12+ const :: forall a b. a -> b -> a
13+ const a _ = a
1414
1515 infixr 9 >>>
1616 infixr 9 <<<
@@ -82,15 +82,15 @@ module Prelude where
8282 (<|>) :: forall a. f a -> f a -> f a
8383
8484 class Monad m where
85− ret :: forall a. a -> m a
85+ return :: forall a. a -> m a
8686 (>>=) :: forall a b. m a -> (a -> m b) -> m b
8787
8888 instance (Monad m) => Applicative m where
89− pure = ret
89+ pure = return
9090 (<*>) f a = do
9191 f' <- f
9292 a' <- a
93− ret (f' a')
93+ return (f' a')
9494
9595 infixl 7 *
9696 infixl 7 /
@@ -362,7 +362,7 @@ module Monoid where
362362 class Monoid m where
363363 mempty :: m
364364 (<>) :: m -> m -> m
365−
365+
366366 instance Monoid String where
367367 mempty = ""
368368 (<>) = (++)
@@ -377,18 +377,18 @@ module Monad where
377377 import Arrays
378378
379379 replicateM :: forall m a. (Monad m) => Number -> m a -> m [a]
380− replicateM 0 _ = ret []
380+ replicateM 0 _ = return []
381381 replicateM n m = do
382382 a <- m
383383 as <- replicateM (n - 1) m
384− ret (a : as)
384+ return (a : as)
385385
386386 mapM :: forall m a b. (Monad m) => (a -> m b) -> [a] -> m [b]
387− mapM _ [] = ret []
387+ mapM _ [] = return []
388388 mapM f (a:as) = do
389389 b <- f a
390390 bs <- mapM f as
391− ret (b : bs)
391+ return (b : bs)
392392
393393 infixr 1 >=>
394394 infixr 1 <=<
@@ -397,16 +397,16 @@ module Monad where
397397 (>=>) f g a = do
398398 b <- f a
399399 g b
400−
401− (<=<) :: forall m a b c. (Monad m) => (b -> m c) -> (a -> m b) -> a -> m c
400+
401+ (<=<) :: forall m a b c. (Monad m) => (b -> m c) -> (a -> m b) -> a -> m c
402402 (<=<) = flip (>=>)
403403
404404 sequence :: forall m a. (Monad m) => [m a] -> m [a]
405− sequence [] = ret []
405+ sequence [] = return []
406406 sequence (m:ms) = do
407407 a <- m
408408 as <- sequence ms
409− ret (a : as)
409+ return (a : as)
410410
411411 join :: forall m a. (Monad m) => m (m a) -> m a
412412 join mm = do
@@ -414,12 +414,12 @@ module Monad where
414414 m
415415
416416 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
418418 foldM f a (b:bs) = f a b >>= \a' -> foldM f a' bs
419419
420420 when :: forall m. (Monad m) => Boolean -> m {} -> m {}
421421 when true m = m
422− when false _ = ret {}
422+ when false _ = return {}
423423
424424module Maybe where
425425
@@ -435,7 +435,7 @@ module Maybe where
435435 fromMaybe a = maybe a (Prelude.id :: forall a. a -> a)
436436
437437 instance Prelude.Monad Maybe where
438− ret = Just
438+ return = Just
439439 (>>=) m f = maybe Nothing f m
440440
441441module Either where
@@ -447,7 +447,7 @@ module Either where
447447 either _ g (Right b) = g b
448448
449449 instance Prelude.Monad (Either e) where
450− ret = Right
450+ return = Right
451451 (>>=) = either (\e _ -> Left e) (\a f -> f a)
452452
453453module Arrays where
@@ -604,7 +604,7 @@ module Arrays where
604604 show (x:xs) = show x ++ " : " ++ show xs
605605
606606 instance Prelude.Monad [] where
607− ret = singleton
607+ return = singleton
608608 (>>=) = concatMap
609609
610610 instance Prelude.Alternative [] where
@@ -886,7 +886,7 @@ module Eff where
886886 \}" :: forall a. Pure a -> a
887887
888888 instance Prelude.Monad (Eff e) where
889− ret = retEff
889+ return = retEff
890890 (>>=) = bindEff
891891
892892 foreign import untilE "function untilE(f) {\
@@ -906,7 +906,7 @@ module Eff where
906906 \ };\
907907 \ };\
908908 \}" :: forall e. Eff e Boolean -> Eff e {} -> Eff e {}
909−
909+
910910 foreign import forE "function forE(lo) {\
911911 \ return function(hi) {\
912912 \ return function(f) {\
libraries/prelude/tests/Eff.purs+11−11
@@ -5,27 +5,27 @@ import Eff
55import Errors
66import Trace
77import Global
8−
9−test1 n = runPure (catchError (\s -> ret 0) $ do
10− case {} of
8+
9+test1 n = runPure (catchError (\s -> return 0) $ do
10+ case {} of
1111 _ | n > 10 -> do
12− throwError "Error!"
13− _ -> ret n)
12+ throwError "Error!"
13+ _ -> return n)
1414
1515test2 = do
1616 trace "Hello World"
1717 throwError "Error!"
1818
19−test3 n = catchError (\s -> ret 0) $ do
20− case {} of
19+test3 n = catchError (\s -> return 0) $ do
20+ case {} of
2121 _ | n > 10 -> do
2222 trace "n > 10"
23− throwError "Error!"
24− _ -> ret n
23+ throwError "Error!"
24+ _ -> return n
2525
2626test4 = do
2727 trace "Hello World!"
28− ret 0
28+ return 0
2929
3030test5 = do
3131 trace "Hello World!"
@@ -52,7 +52,7 @@ test9 _ = do
5252 n <- readSTRef r
5353 trace $ "Count " ++ show n
5454 modifySTRef r $ (+) 1
55− ret false
55+ return false
5656
5757module Main where
5858