@@ -162,17 +162,14 @@ module Prelude where
162162 -- Referential equality
163163 data Ref a = Ref a
164164
165− foreign import refEq "function refEq(r1) {\
166− \ return function(r2) {\
167− \ return r1.values[0] === r2.values[0];\
168− \ };\
169− \}" :: forall a. Ref a -> Ref a -> Boolean
170−
171− foreign import refIneq "function refIneq(r1) {\
172− \ return function(r2) {\
173− \ return r1.values[0] !== r2.values[0];\
174− \ };\
175− \}" :: forall a. Ref a -> Ref a -> Boolean
165+ liftRef :: forall a b. (a -> a -> b) -> Ref a -> Ref a -> b
166+ liftRef f (Ref x) (Ref y) = f x y
167+
168+ refEq :: forall a. Ref a -> Ref a -> Boolean
169+ refEq = liftRef unsafeRefEq
170+
171+ refIneq :: forall a. Ref a -> Ref a -> Boolean
172+ refIneq = liftRef unsafeRefIneq
176173
177174 foreign import unsafeRefEq "function unsafeRefEq(r1) {\
178175 \ return function(r2) {\
@@ -356,7 +353,7 @@ module Prelude where
356353 \ };\
357354 \}" :: String -> String -> String
358355
359−module Monoid where
356+module Data.Monoid where
360357
361358 import Prelude
362359
@@ -372,16 +369,16 @@ module Monoid where
372369
373370 instance Monoid [a] where
374371 mempty = []
375− (<>) = Arrays.concat
372+ (<>) = Data.Array.concat
376373
377374 mconcat :: forall m. (Monoid m) => [m] -> m
378375 mconcat [] = mempty
379376 mconcat (m:ms) = m <> mconcat ms
380377
381−module Monad where
378+module Control.Monad where
382379
383380 import Prelude
384− import Arrays
381+ import Data.Array
385382
386383 replicateM :: forall m a. (Monad m) => Number -> m a -> m [a]
387384 replicateM 0 _ = return []
@@ -428,7 +425,7 @@ module Monad where
428425 when true m = m
429426 when false _ = return {}
430427
431−module Maybe where
428+module Data.Maybe where
432429
433430 import Prelude
434431
@@ -458,7 +455,7 @@ module Maybe where
458455 show (Just x) = "Just " ++ (show x)
459456 show Nothing = "Nothing"
460457
461−module Either where
458+module Data.Either where
462459
463460 import Prelude
464461
@@ -485,24 +482,18 @@ module Either where
485482 show (Left x) = "Left " ++ (show x)
486483 show (Right y) = "Right " ++ (show y)
487484
488−module Arrays where
485+module Data.Array where
489486
490487 import Prelude
491− import Maybe
488+ import Data.Maybe
492489
493− head :: forall a. [a] -> a
494− head (x : _) = x
495−
496− headSafe :: forall a. [a] -> Maybe a
497− headSafe (x : _) = Just x
498− headSafe _ = Nothing
490+ head :: forall a. [a] -> Maybe a
491+ head (x : _) = Just x
492+ head _ = Nothing
499493
500− tail :: forall a. [a] -> [a]
501− tail (_ : xs) = xs
502−
503− tailSafe :: forall a. [a] -> Maybe [a]
504− tailSafe (_ : xs) = Just xs
505− tailSafe _ = Nothing
494+ tail :: forall a. [a] -> Maybe [a]
495+ tail (_ : xs) = Just xs
496+ tail _ = Nothing
506497
507498 map :: forall a b. (a -> b) -> [a] -> [b]
508499 map _ [] = []
@@ -647,11 +638,19 @@ module Arrays where
647638 instance Prelude.Alternative [] where
648639 empty = []
649640 (<|>) = concat
641+
642+module Data.Array.Unsafe where
650643
651−module Tuples where
644+ head :: forall a. [a] -> a
645+ head (x : _) = x
646+
647+ tail :: forall a. [a] -> [a]
648+ tail (_ : xs) = xs
649+
650+module Data.Tuple where
652651
653652 import Prelude
654− import Arrays
653+ import Data.Array
655654
656655 data Tuple a b = Tuple a b
657656
@@ -672,7 +671,7 @@ module Tuples where
672671 Tuple as bs -> Tuple (a : as) (b : bs)
673672 unzip [] = Tuple [] []
674673
675−module String where
674+module Data.String where
676675
677676 foreign import lengthS "function lengthS(s) {\
678677 \ return s.length;\
@@ -752,7 +751,7 @@ module String where
752751 \ return s.trim();\
753752 \}" :: String -> String
754753
755−module Regex where
754+module Data.String.Regex where
756755
757756 foreign import data Regex :: *
758757
@@ -907,7 +906,7 @@ module Math where
907906 foreign import sqrt1_2 "var sqrt1_2 = Math.SQRT1_2;" :: Number
908907 foreign import sqrt2 "var sqrt2 = Math.SQRT2;" :: Number
909908
910−module Eff where
909+module Control.Monad.Eff where
911910
912911 foreign import data Eff :: # ! -> * -> *
913912
@@ -936,29 +935,29 @@ module Eff where
936935 (>>=) = bindEff
937936
938937 foreign import untilE "function untilE(f) {\
939− \ return function() {\
940− \ while (!f()) { }\
941− \ return {};\
942− \ };\
938+ \ return function() {\
939+ \ while (!f()) { }\
940+ \ return {};\
941+ \ };\
943942 \}" :: forall e. Eff e Boolean -> Eff e {}
944943
945944 foreign import whileE "function whileE(f) {\
946− \ return function(a) {\
947− \ return function() {\
948− \ while (f()) {\
945+ \ return function(a) {\
946+ \ return function() {\
947+ \ while (f()) {\
949948 \ a();\
950949 \ }\
951− \ return {};\
950+ \ return {};\
952951 \ };\
953952 \ };\
954953 \}" :: forall e a. Eff e Boolean -> Eff e a -> Eff e {}
955954
956955 foreign import forE "function forE(lo) {\
957− \ return function(hi) {\
958− \ return function(f) {\
959− \ return function() {\
960− \ for (var i = lo; i < hi; i++) {\
961− \ f(i)();\
956+ \ return function(hi) {\
957+ \ return function(f) {\
958+ \ return function() {\
959+ \ for (var i = lo; i < hi; i++) {\
960+ \ f(i)();\
962961 \ }\
963962 \ };\
964963 \ };\
@@ -967,9 +966,9 @@ module Eff where
967966
968967
969968 foreign import foreachE "function foreachE(as) {\
970− \ return function(f) {\
971− \ for (var i = 0; i < as.length; i++) {\
972− \ f(as[i])();\
969+ \ return function(f) {\
970+ \ for (var i = 0; i < as.length; i++) {\
971+ \ f(as[i])();\
973972 \ }\
974973 \ };\
975974 \}" :: forall e a. [a] -> (a -> Eff e {}) -> Eff e {}
@@ -977,7 +976,7 @@ module Eff where
977976
978977module Random where
979978
980− import Eff
979+ import Control.Monad.Eff
981980
982981 foreign import data Random :: !
983982
@@ -985,9 +984,9 @@ module Random where
985984 \ return Math.random();\
986985 \}" :: forall e. Eff (random :: Random | e) Number
987986
988−module Errors where
987+module Control.Monad.Error where
989988
990− import Eff
989+ import Control.Monad.Eff
991990
992991 foreign import data Error :: * -> !
993992
@@ -1009,9 +1008,9 @@ module Errors where
10091008 \ };\
10101009 \}" :: forall e r a. (e -> Eff r a) -> Eff (err :: Error e | r) a -> Eff r a
10111010
1012−module IORef where
1011+module Data.IORef where
10131012
1014− import Eff
1013+ import Control.Monad.Eff
10151014
10161015 foreign import data Ref :: !
10171016
@@ -1052,10 +1051,10 @@ module IORef where
10521051 \ return f;\
10531052 \}" :: forall eff a. Eff (ref :: Ref | eff) a -> Eff eff a
10541053
1055−module Trace where
1054+module Debug.Trace where
10561055
10571056 import Prelude
1058− import Eff
1057+ import Control.Monad.Eff
10591058
10601059 foreign import data Trace :: !
10611060
@@ -1069,9 +1068,9 @@ module Trace where
10691068 print :: forall a r. (Prelude.Show a) => a -> Eff (trace :: Trace | r) {}
10701069 print o = trace (show o)
10711070
1072−module ST where
1071+module Control.Monad.ST where
10731072
1074− import Eff
1073+ import Control.Monad.Eff
10751074
10761075 foreign import data ST :: * -> !
10771076
@@ -1145,9 +1144,9 @@ module ST where
11451144 \ return f;\
11461145 \}" :: forall a r. (forall h. Eff (st :: ST h | r) (STArray h a)) -> Eff r [a]
11471146
1148−module Enum where
1147+module Data.Enum where
11491148
1150− import Maybe
1149+ import Data.Maybe
11511150
11521151 class Enum a where
11531152 toEnum :: Number -> Maybe a