@@ -162,17 +162,14 @@ module Prelude where
162 -- Referential equality
162 -- Referential equality
163 data Ref a = Ref a
163 data Ref a = Ref a
165− foreign import refEq "function refEq(r1) {\
165+ liftRef :: forall a b. (a -> a -> b) -> Ref a -> Ref a -> b
166− \ return function(r2) {\
166+ liftRef f (Ref x) (Ref y) = f x y
167− \ return r1.values[0] === r2.values[0];\
167+
169− \}" :: forall a. Ref a -> Ref a -> Boolean
168+ refEq :: forall a. Ref a -> Ref a -> Boolean
170−
169+ refEq = liftRef unsafeRefEq
171− foreign import refIneq "function refIneq(r1) {\
170+
172− \ return function(r2) {\
173− \ return r1.values[0] !== r2.values[0];\
175− \}" :: forall a. Ref a -> Ref a -> Boolean
171+ refIneq :: forall a. Ref a -> Ref a -> Boolean
172+ refIneq = liftRef unsafeRefIneq
177 foreign import unsafeRefEq "function unsafeRefEq(r1) {\
174 foreign import unsafeRefEq "function unsafeRefEq(r1) {\
178 \ return function(r2) {\
175 \ return function(r2) {\
@@ -356,7 +353,7 @@ module Prelude where
357 \}" :: String -> String -> String
354 \}" :: String -> String -> String
359−module Monoid where
356+module Data.Monoid where
361 import Prelude
358 import Prelude
@@ -372,16 +369,16 @@ module Monoid where
373 instance Monoid [a] where
370 instance Monoid [a] where
374 mempty = []
371 mempty = []
375− (<>) = Arrays.concat
372+ (<>) = Data.Array.concat
377 mconcat :: forall m. (Monoid m) => [m] -> m
374 mconcat :: forall m. (Monoid m) => [m] -> m
378 mconcat [] = mempty
375 mconcat [] = mempty
379 mconcat (m:ms) = m <> mconcat ms
376 mconcat (m:ms) = m <> mconcat ms
381−module Monad where
378+module Control.Monad where
383 import Prelude
380 import Prelude
384− import Arrays
381+ import Data.Array
386 replicateM :: forall m a. (Monad m) => Number -> m a -> m [a]
383 replicateM :: forall m a. (Monad m) => Number -> m a -> m [a]
387 replicateM 0 _ = return []
384 replicateM 0 _ = return []
@@ -428,7 +425,7 @@ module Monad where
428 when true m = m
425 when true m = m
429 when false _ = return {}
426 when false _ = return {}
431−module Maybe where
428+module Data.Maybe where
433 import Prelude
430 import Prelude
@@ -458,7 +455,7 @@ module Maybe where
458 show (Just x) = "Just " ++ (show x)
455 show (Just x) = "Just " ++ (show x)
459 show Nothing = "Nothing"
456 show Nothing = "Nothing"
461−module Either where
458+module Data.Either where
463 import Prelude
460 import Prelude
@@ -485,24 +482,18 @@ module Either where
485 show (Left x) = "Left " ++ (show x)
482 show (Left x) = "Left " ++ (show x)
486 show (Right y) = "Right " ++ (show y)
483 show (Right y) = "Right " ++ (show y)
488−module Arrays where
485+module Data.Array where
490 import Prelude
487 import Prelude
491− import Maybe
488+ import Data.Maybe
493− head :: forall a. [a] -> a
490+ head :: forall a. [a] -> Maybe a
496− headSafe :: forall a. [a] -> Maybe a
497− headSafe (x : _) = Just x
491+ head (x : _) = Just x
498− headSafe _ = Nothing
492+ head _ = Nothing
500− tail :: forall a. [a] -> [a]
494+ tail :: forall a. [a] -> Maybe [a]
503− tailSafe :: forall a. [a] -> Maybe [a]
504− tailSafe (_ : xs) = Just xs
495+ tail (_ : xs) = Just xs
505− tailSafe _ = Nothing
496+ tail _ = Nothing
507 map :: forall a b. (a -> b) -> [a] -> [b]
498 map :: forall a b. (a -> b) -> [a] -> [b]
508 map _ [] = []
499 map _ [] = []
@@ -647,11 +638,19 @@ module Arrays where
647 instance Prelude.Alternative [] where
638 instance Prelude.Alternative [] where
648 empty = []
639 empty = []
649 (<|>) = concat
640 (<|>) = concat
642+module Data.Array.Unsafe where
644+ head :: forall a. [a] -> a
647+ tail :: forall a. [a] -> [a]
651−module Tuples where
650+module Data.Tuple where
653 import Prelude
652 import Prelude
654− import Arrays
653+ import Data.Array
656 data Tuple a b = Tuple a b
655 data Tuple a b = Tuple a b
@@ -672,7 +671,7 @@ module Tuples where
672 Tuple as bs -> Tuple (a : as) (b : bs)
671 Tuple as bs -> Tuple (a : as) (b : bs)
673 unzip [] = Tuple [] []
672 unzip [] = Tuple [] []
675−module String where
674+module Data.String where
677 foreign import lengthS "function lengthS(s) {\
676 foreign import lengthS "function lengthS(s) {\
678 \ return s.length;\
677 \ return s.length;\
@@ -752,7 +751,7 @@ module String where
752 \ return s.trim();\
751 \ return s.trim();\
753 \}" :: String -> String
752 \}" :: String -> String
755−module Regex where
754+module Data.String.Regex where
757 foreign import data Regex :: *
756 foreign import data Regex :: *
@@ -907,7 +906,7 @@ module Math where
907 foreign import sqrt1_2 "var sqrt1_2 = Math.SQRT1_2;" :: Number
906 foreign import sqrt1_2 "var sqrt1_2 = Math.SQRT1_2;" :: Number
908 foreign import sqrt2 "var sqrt2 = Math.SQRT2;" :: Number
907 foreign import sqrt2 "var sqrt2 = Math.SQRT2;" :: Number
910−module Eff where
909+module Control.Monad.Eff where
912 foreign import data Eff :: # ! -> * -> *
911 foreign import data Eff :: # ! -> * -> *
@@ -936,29 +935,29 @@ module Eff where
936 (>>=) = bindEff
935 (>>=) = bindEff
938 foreign import untilE "function untilE(f) {\
937 foreign import untilE "function untilE(f) {\
939− \ return function() {\
938+ \ return function() {\
940− \ while (!f()) { }\
939+ \ while (!f()) { }\
941− \ return {};\
940+ \ return {};\
943 \}" :: forall e. Eff e Boolean -> Eff e {}
942 \}" :: forall e. Eff e Boolean -> Eff e {}
945 foreign import whileE "function whileE(f) {\
944 foreign import whileE "function whileE(f) {\
946− \ return function(a) {\
945+ \ return function(a) {\
947− \ return function() {\
946+ \ return function() {\
948− \ while (f()) {\
947+ \ while (f()) {\
951− \ return {};\
950+ \ return {};\
954 \}" :: forall e a. Eff e Boolean -> Eff e a -> Eff e {}
953 \}" :: forall e a. Eff e Boolean -> Eff e a -> Eff e {}
956 foreign import forE "function forE(lo) {\
955 foreign import forE "function forE(lo) {\
957− \ return function(hi) {\
956+ \ return function(hi) {\
958− \ return function(f) {\
957+ \ return function(f) {\
959− \ return function() {\
958+ \ return function() {\
960− \ for (var i = lo; i < hi; i++) {\
959+ \ for (var i = lo; i < hi; i++) {\
961− \ f(i)();\
960+ \ f(i)();\
@@ -967,9 +966,9 @@ module Eff where
969 foreign import foreachE "function foreachE(as) {\
968 foreign import foreachE "function foreachE(as) {\
970− \ return function(f) {\
969+ \ return function(f) {\
971− \ for (var i = 0; i < as.length; i++) {\
970+ \ for (var i = 0; i < as.length; i++) {\
972− \ f(as[i])();\
971+ \ f(as[i])();\
975 \}" :: forall e a. [a] -> (a -> Eff e {}) -> Eff e {}
974 \}" :: forall e a. [a] -> (a -> Eff e {}) -> Eff e {}
@@ -977,7 +976,7 @@ module Eff where
978module Random where
977module Random where
980− import Eff
979+ import Control.Monad.Eff
982 foreign import data Random :: !
981 foreign import data Random :: !
@@ -985,9 +984,9 @@ module Random where
985 \ return Math.random();\
984 \ return Math.random();\
986 \}" :: forall e. Eff (random :: Random | e) Number
985 \}" :: forall e. Eff (random :: Random | e) Number
988−module Errors where
987+module Control.Monad.Error where
990− import Eff
989+ import Control.Monad.Eff
992 foreign import data Error :: * -> !
991 foreign import data Error :: * -> !
@@ -1009,9 +1008,9 @@ module Errors where
1010 \}" :: forall e r a. (e -> Eff r a) -> Eff (err :: Error e | r) a -> Eff r a
1009 \}" :: forall e r a. (e -> Eff r a) -> Eff (err :: Error e | r) a -> Eff r a
1012−module IORef where
1011+module Data.IORef where
1014− import Eff
1013+ import Control.Monad.Eff
1016 foreign import data Ref :: !
1015 foreign import data Ref :: !
@@ -1052,10 +1051,10 @@ module IORef where
1052 \ return f;\
1051 \ return f;\
1053 \}" :: forall eff a. Eff (ref :: Ref | eff) a -> Eff eff a
1052 \}" :: forall eff a. Eff (ref :: Ref | eff) a -> Eff eff a
1055−module Trace where
1054+module Debug.Trace where
1057 import Prelude
1056 import Prelude
1058− import Eff
1057+ import Control.Monad.Eff
1060 foreign import data Trace :: !
1059 foreign import data Trace :: !
@@ -1069,9 +1068,9 @@ module Trace where
1069 print :: forall a r. (Prelude.Show a) => a -> Eff (trace :: Trace | r) {}
1068 print :: forall a r. (Prelude.Show a) => a -> Eff (trace :: Trace | r) {}
1070 print o = trace (show o)
1069 print o = trace (show o)
1072−module ST where
1071+module Control.Monad.ST where
1074− import Eff
1073+ import Control.Monad.Eff
1076 foreign import data ST :: * -> !
1075 foreign import data ST :: * -> !
@@ -1145,9 +1144,9 @@ module ST where
1145 \ return f;\
1144 \ return f;\
1146 \}" :: forall a r. (forall h. Eff (st :: ST h | r) (STArray h a)) -> Eff r [a]
1145 \}" :: forall a r. (forall h. Eff (st :: ST h | r) (STArray h a)) -> Eff r [a]
1148−module Enum where
1147+module Data.Enum where
1150− import Maybe
1149+ import Data.Maybe
1152 class Enum a where
1151 class Enum a where
1153 toEnum :: Number -> Maybe a
1152 toEnum :: Number -> Maybe a