git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #221 from garyb/master

Prelude improvements

commit4d8ab7a9ac66f03d3dd90329f70a26804c222bd9 authorPhil Freeman <paf31@cantab.net> dateFri 21 Feb 2014, 10:43 (13 years ago) parent4bb08dfd562273
71 files changed+167−201
examples/failing/Arrays.purs+1−1 examples/failing/LocalVars.purs−8 examples/failing/PatternScope.purs−12 examples/failing/Shadowed.purs−14 examples/failing/SkolemEscape2.purs+2−2 examples/passing/Applicative.purs+1−1 examples/passing/ArrayType.purs+1−1 examples/passing/Arrays.purs+4−4 examples/passing/Auto.purs+1−1 examples/passing/BindersInFunctions.purs+3−3 examples/passing/Church.purs+1−1 examples/passing/Collatz.purs+3−3 examples/passing/Conditional.purs+1−1 examples/passing/Cons.purs+2−2 examples/passing/Console.purs+2−2 examples/passing/DataAndType.purs+1−1 examples/passing/DataImport.purs+1−1 examples/passing/Do.purs+1−1 examples/passing/Dollar.purs+1−1 examples/passing/DottedModules.purs+1−1 examples/passing/Eff.purs+7−7 examples/passing/ExternData.purs+1−1 examples/passing/ExternRaw.purs+1−1 examples/passing/FFI.purs+1−1 examples/passing/FunctionScope.purs+2−2 examples/passing/Functions.purs+1−1 examples/passing/Functions2.purs+2−2 examples/passing/Guards.purs+1−1 examples/passing/Import.purs+1−1 examples/passing/InferRecFunWithConstrainedArgument.purs+1−1 examples/passing/JSReserved.purs+2−2 examples/passing/Let.purs+4−4 examples/passing/List.purs+3−3 examples/passing/Match.purs+1−1 examples/passing/Math.purs+2−2 examples/passing/Maybe.purs+2−2 examples/passing/Module.purs+1−1 examples/passing/ModuleDeps.purs+1−1 examples/passing/Monad.purs+1−1 examples/passing/MultipleConstructorArgs.purs+5−5 examples/passing/MutRec.purs+1−1 examples/passing/NamedPatterns.purs+1−1 examples/passing/Nested.purs+1−1 examples/passing/NestedTypeSynonyms.purs+1−1 examples/passing/ObjectSynonym.purs+1−1 examples/passing/ObjectUpdate.purs+1−1 examples/passing/Objects.purs+1−1 examples/passing/OneConstructor.purs+1−1 examples/passing/Operators.purs+3−3 examples/passing/OptimizerBug.purs+1−1 examples/passing/Patterns.purs+1−1 examples/passing/Person.purs+1−1 examples/passing/Rank2Data.purs+1−1 examples/passing/Rank2Types.purs+1−1 examples/passing/Recursion.purs+1−1 examples/passing/RedefinedFixity.purs+1−1 examples/passing/RuntimeScopeIssue.purs+1−1 examples/passing/STArray.purs+4−4 examples/passing/TailCall.purs+1−1 examples/passing/Tick.purs+1−1 examples/passing/TopLevelCase.purs+1−1 examples/passing/TypeClasses.purs+1−1 examples/passing/TypeClassesInOrder.purs+1−1 examples/passing/TypeClassesWithOverlappingTypeVariables.purs+2−2 examples/passing/TypeDecl.purs+1−1 examples/passing/TypeSynonyms.purs+3−2 examples/passing/iota.purs+1−1 examples/passing/s.purs+1−1 prelude/prelude.purs+62−63 src/Language/PureScript/CodeGen/Optimize.hs+1−1 src/Language/PureScript/TypeChecker/Types.hs+1−1
examples/failing/Arrays.purs+1−1
@@ -1,4 +1,4 @@
1−module Arrays where
1+module Data.Array where
22
33 import Prelude
44
examples/failing/LocalVars.pursdeleted−8
@@ -1,8 +0,0 @@
1−module LocalVars where
2−
3− import Prelude
4−
5− bad = \x -> {
6− x = x + 1;
7− return x;
8− }
examples/failing/PatternScope.pursdeleted−12
@@ -1,12 +0,0 @@
1−module PatternScope where
2−
3− import Prelude
4−
5− -- Pattern scope doesn't leak
6− foobar = \x -> {
7− var y = case x of
8− z | z % 2 == 0 -> 1
9− _ -> 2;
10− return z;
11− }
12−
examples/failing/Shadowed.pursdeleted−14
@@ -1,14 +0,0 @@
1−module Shadowed where
2−
3−import Prelude
4−
5−a = [1, 2]
6−
7−foo = {
8− var x = a !! 0;
9− var a = 0;
10−
11− a = a + 1;
12−
13− return x + a;
14− }
examples/failing/SkolemEscape2.purs+2−2
@@ -1,8 +1,8 @@
11module SkolemEscape where
22
33import Prelude
4−import Eff
5−import ST
4+import Control.Monad.Eff
5+import Control.Monad.ST
66
77test _ = do
88 r <- runST (newSTRef 0)
examples/passing/Applicative.purs+1−1
@@ -13,4 +13,4 @@ instance Applicative Maybe where
1313
1414module Main where
1515
16−main = Trace.trace "Done"
16+main = Debug.Trace.trace "Done"
examples/passing/ArrayType.purs+1−1
@@ -14,4 +14,4 @@ instance Functor [] where
1414
1515module Main where
1616
17−main = Trace.trace "Done"
17+main = Debug.Trace.trace "Done"
examples/passing/Arrays.purs+4−4
@@ -1,4 +1,4 @@
1−module ArraysTests where
1+module Data.ArrayTests where
22
33import Prelude
44
@@ -23,12 +23,12 @@ test4 = \arr -> case arr of
2323
2424module Main where
2525
26−import Arrays
26+import Data.Array
2727import Prelude
2828
2929main = do
3030 let x = [3,2,1]
3131 let y = sort x
3232 if x == [3,2,1]
33− then Trace.trace "Done"
34− else Errors.throwError "Not done"
33+ then Debug.Trace.trace "Done"
34+ else Control.Monad.Error.throwError "Not done"
examples/passing/Auto.purs+1−1
@@ -12,4 +12,4 @@ module Auto where
1212
1313module Main where
1414
15−main = Trace.trace "Done"
15+main = Debug.Trace.trace "Done"
examples/passing/BindersInFunctions.purs+3−3
@@ -1,12 +1,12 @@
11module Main where
22
33import Prelude
4−import Arrays
4+import Data.Array
55
66tails = map (\(_:xs) -> xs)
77
88main =
99 let ts = tails [[1, 2, 3], [4, 5], [6]] in
1010 if ts == [[2, 3], [5], []]
11− then Trace.trace "Done"
12− else Errors.throwError "Incorrect result from 'tails'."
11+ then Debug.Trace.trace "Done"
12+ else Control.Monad.Error.throwError "Incorrect result from 'tails'."
examples/passing/Church.purs+1−1
@@ -15,4 +15,4 @@ module Church where
1515
1616module Main where
1717
18−main = Trace.trace "Done"
18+main = Debug.Trace.trace "Done"
examples/passing/Collatz.purs+3−3
@@ -1,8 +1,8 @@
11module Main where
22
33import Prelude
4−import Eff
5−import ST
4+import Control.Monad.Eff
5+import Control.Monad.ST
66
77collatz :: Number -> Number
88collatz n = runPure (runST (do
@@ -15,4 +15,4 @@ collatz n = runPure (runST (do
1515 return $ m == 1
1616 readSTRef count))
1717
18−main = Trace.print $ collatz 1
18+main = Debug.Trace.print $ collatz 1
examples/passing/Conditional.purs+1−1
@@ -6,4 +6,4 @@ module Conditional where
66
77module Main where
88
9−main = Trace.trace "Done"
9+main = Debug.Trace.trace "Done"
examples/passing/Cons.purs+2−2
@@ -1,7 +1,7 @@
11module Cons where
22
33 import Prelude
4− import Arrays
4+ import Data.Array
55
66 test1 = \xs -> 1 : xs
77
@@ -9,4 +9,4 @@ module Cons where
99
1010module Main where
1111
12−main = Trace.trace "Done"
12+main = Debug.Trace.trace "Done"
examples/passing/Console.purs+2−2
@@ -1,8 +1,8 @@
11module Main where
22
33import Prelude
4−import Eff
5−import Trace
4+import Control.Monad.Eff
5+import Debug.Trace
66
77replicateM_ :: forall m a. (Monad m) => Number -> m a -> m {}
88replicateM_ 0 _ = return {}
examples/passing/DataAndType.purs+1−1
@@ -6,4 +6,4 @@ type B = A
66
77module Main where
88
9−main = Trace.trace "Done"
9+main = Debug.Trace.trace "Done"
examples/passing/DataImport.purs+1−1
@@ -10,4 +10,4 @@ unTest (Test s) = s
1010
1111main = do
1212 let x = unTest (Test "Done")
13− Trace.trace x
13+ Debug.Trace.trace x
examples/passing/Do.purs+1−1
@@ -46,4 +46,4 @@ test9 = \_ -> (+) <$> Just 1 <*> Just 2
4646
4747module Main where
4848
49−main = Trace.trace "Done"
49+main = Debug.Trace.trace "Done"
examples/passing/Dollar.purs+1−1
@@ -13,4 +13,4 @@ test2 x = id id $ id x
1313
1414module Main where
1515
16−main = Trace.trace "Done"
16+main = Debug.Trace.trace "Done"
examples/passing/DottedModules.purs+1−1
@@ -17,4 +17,4 @@ module Main where
1717
1818 unwrap (Text x) = x
1919
20− main = Trace.print $ foo $ unwrap x
20+ main = Debug.Trace.print $ foo $ unwrap x
examples/passing/Eff.purs+7−7
@@ -1,10 +1,10 @@
11module TestEff where
22
33import Prelude
4−import Eff
5−import ST
6−import Errors
7−import Trace
4+import Control.Monad.Eff
5+import Control.Monad.ST
6+import Control.Monad.Error
7+import Debug.Trace
88
99test1 = catchError (\s -> return 0) $ do
1010 trace "Testing"
@@ -18,10 +18,10 @@ test2 = runPure (runST (do
1818module Main where
1919
2020import Prelude
21−import Eff
21+import Control.Monad.Eff
2222import TestEff
2323
2424main = do
2525 n <- test1
26− Trace.print n
27− Trace.print test2
26+ Debug.Trace.print n
27+ Debug.Trace.print test2
examples/passing/ExternData.purs+1−1
@@ -16,4 +16,4 @@ module ExternData where
1616
1717module Main where
1818
19−main = Trace.trace "Done"
19+main = Debug.Trace.trace "Done"
examples/passing/ExternRaw.purs+1−1
@@ -12,4 +12,4 @@ foreign import concat "function concat(xs) { \
1212
1313module Main where
1414
15−main = Trace.trace "Done"
15+main = Debug.Trace.trace "Done"
examples/passing/FFI.purs+1−1
@@ -13,4 +13,4 @@ baz _ = foo "test"
1313
1414module Main where
1515
16−main = Trace.trace "Done"
16+main = Debug.Trace.trace "Done"
examples/passing/FunctionScope.purs+2−2
@@ -13,5 +13,5 @@ module Main where
1313 main = do
1414 let value = mkValue 1
1515 if value == 1
16− then Trace.trace "Done"
17− else Errors.throwError "Not done"
16+ then Debug.Trace.trace "Done"
17+ else Control.Monad.Error.throwError "Not done"
examples/passing/Functions.purs+1−1
@@ -14,4 +14,4 @@ module Functions where
1414
1515module Main where
1616
17−main = Trace.trace "Done"
17+main = Debug.Trace.trace "Done"
examples/passing/Functions2.purs+2−2
@@ -13,5 +13,5 @@ module Main where
1313 main = do
1414 let value = test "Done" {}
1515 if value == "Done"
16− then Trace.trace "Done"
17− else Errors.throwError "Not done"
16+ then Debug.Trace.trace "Done"
17+ else Control.Monad.Error.throwError "Not done"
examples/passing/Guards.purs+1−1
@@ -13,4 +13,4 @@ module Guards where
1313
1414module Main where
1515
16−main = Trace.trace "Done"
16+main = Debug.Trace.trace "Done"
examples/passing/Import.purs+1−1
@@ -13,4 +13,4 @@ module M2 where
1313
1414module Main where
1515
16−main = Trace.trace "Done"
16+main = Debug.Trace.trace "Done"
examples/passing/InferRecFunWithConstrainedArgument.purs+1−1
@@ -5,4 +5,4 @@ import Prelude
55test 100 = 100
66test n = test(1 + n)
77
8−main = Trace.print $ test 0
8+main = Debug.Trace.print $ test 0
examples/passing/JSReserved.purs+2−2
@@ -12,10 +12,10 @@ module JSReserved where
1212module Main where
1313
1414 import Prelude
15− import Arrays
15+ import Data.Array
1616 import JSReserved
1717
18− main = Trace.print [ yield
18+ main = Debug.Trace.print [ yield
1919 , member
2020 , this 1
2121 , public 1 ]
examples/passing/Let.purs+4−4
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Eff
4+import Control.Monad.Eff
55
66test1 x = let y = x + 1 in y
77
@@ -13,6 +13,6 @@ test2 x y =
1313test3 x = let 1 = x in 2
1414
1515main = do
16− Trace.print (test1 1)
17− Trace.print (test2 1 2)
18− Trace.print (test3 1)
16+ Debug.Trace.print (test1 1)
17+ Debug.Trace.print (test2 1 2)
18+ Debug.Trace.print (test3 1)
examples/passing/List.purs+3−3
@@ -1,10 +1,10 @@
11module Main where
22
33import Prelude
4−import Eff
5−import Arrays
4+import Control.Monad.Eff
5+import Data.Array
66import Global
77
88main = do
99 let test1 = concat [1, 2, 3] [4, 5, 6]
10− Trace.print test1
10+ Debug.Trace.print test1
examples/passing/Match.purs+1−1
@@ -6,4 +6,4 @@ module Match where
66
77module Main where
88
9−main = Trace.trace "Done"
9+main = Debug.Trace.trace "Done"
examples/passing/Math.purs+2−2
@@ -1,8 +1,8 @@
11module Main where
22
33 import Prelude
4− import Trace
5− import Eff
4+ import Debug.Trace
5+ import Control.Monad.Eff
66
77 main = do
88 print $ Math.sin 0
examples/passing/Maybe.purs+2−2
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Maybe
4+import Data.Maybe
55import Global
66
77main = do
@@ -9,4 +9,4 @@ main = do
99 a <- Just 1
1010 b <- Just 2
1111 return (a + b)
12− Trace.print test1
12+ Debug.Trace.print test1
examples/passing/Module.purs+1−1
@@ -25,4 +25,4 @@ module M2 where
2525
2626module Main where
2727
28−main = Trace.trace "Done"
28+main = Debug.Trace.trace "Done"
examples/passing/ModuleDeps.purs+1−1
@@ -14,4 +14,4 @@ baz = 1
1414
1515module Main where
1616
17−main = Trace.trace "Done"
17+main = Debug.Trace.trace "Done"
examples/passing/Monad.purs+1−1
@@ -29,4 +29,4 @@ module MonadTest where
2929
3030module Main where
3131
32−main = Trace.trace "Done"
32+main = Debug.Trace.trace "Done"
examples/passing/MultipleConstructorArgs.purs+5−5
@@ -1,6 +1,6 @@
11module MultipleConstructorArgs where
22
3−import Arrays
3+import Data.Array
44
55data P a b = P a b
66
@@ -20,9 +20,9 @@ module Main where
2020import Prelude
2121import MultipleConstructorArgs
2222import Global
23−import Eff
24−import Arrays
23+import Control.Monad.Eff
24+import Data.Array
2525
2626main = do
27− Trace.trace (runP (\s n -> s ++ show n) (P "Test" 1))
28− Trace.print test1
27+ Debug.Trace.trace (runP (\s n -> s ++ show n) (P "Test" 1))
28+ Debug.Trace.print test1
examples/passing/MutRec.purs+1−1
@@ -18,4 +18,4 @@ module MutRec where
1818
1919module Main where
2020
21−main = Trace.trace "Done"
21+main = Debug.Trace.trace "Done"
examples/passing/NamedPatterns.purs+1−1
@@ -6,4 +6,4 @@ module NamedPatterns where
66
77module Main where
88
9−main = Trace.trace "Done"
9+main = Debug.Trace.trace "Done"
examples/passing/Nested.purs+1−1
@@ -6,4 +6,4 @@ module Nested where
66
77module Main where
88
9−main = Trace.trace "Done"
9+main = Debug.Trace.trace "Done"
examples/passing/NestedTypeSynonyms.purs+1−1
@@ -10,4 +10,4 @@ module Main where
1010
1111 import Prelude
1212
13− main = Trace.print (NestedTypeSynonyms.fn "Done")
13+ main = Debug.Trace.print (NestedTypeSynonyms.fn "Done")
examples/passing/ObjectSynonym.purs+1−1
@@ -12,4 +12,4 @@ outer = { inner: inner }
1212
1313module Main where
1414
15−main = Trace.trace "Done"
15+main = Debug.Trace.trace "Done"
examples/passing/ObjectUpdate.purs+1−1
@@ -17,4 +17,4 @@ module ObjectUpdate where
1717
1818module Main where
1919
20−main = Trace.trace "Done"
20+main = Debug.Trace.trace "Done"
examples/passing/Objects.purs+1−1
@@ -17,4 +17,4 @@ module Objects where
1717
1818module Main where
1919
20−main = Trace.trace "Done"
20+main = Debug.Trace.trace "Done"
examples/passing/OneConstructor.purs+1−1
@@ -6,4 +6,4 @@ one (One a) = a
66
77module Main where
88
9−main = Trace.trace "Done"
9+main = Debug.Trace.trace "Done"
examples/passing/Operators.purs+3−3
@@ -60,10 +60,10 @@ import Operators1
6060import Operators2
6161
6262import Prelude
63−import Eff
64−import Trace
63+import Control.Monad.Eff
64+import Debug.Trace
6565import Global
66−import Arrays
66+import Data.Array
6767
6868main =
6969 print [ show $ test1 1 2 $ \x y -> x + y
examples/passing/OptimizerBug.purs+1−1
@@ -8,4 +8,4 @@ y a = x a
88
99module Main where
1010
11−main = Trace.trace "Done"
11+main = Debug.Trace.trace "Done"
examples/passing/Patterns.purs+1−1
@@ -27,4 +27,4 @@ module Patterns where
2727
2828module Main where
2929
30−main = Trace.trace "Done"
30+main = Debug.Trace.trace "Done"
examples/passing/Person.purs+1−1
@@ -12,4 +12,4 @@ module Person where
1212
1313module Main where
1414
15−main = Trace.trace "Done"
15+main = Debug.Trace.trace "Done"
examples/passing/Rank2Data.purs+1−1
@@ -28,4 +28,4 @@ module Rank2Data where
2828
2929module Main where
3030
31−main = Trace.trace "Done"
31+main = Debug.Trace.trace "Done"
examples/passing/Rank2Types.purs+1−1
@@ -22,4 +22,4 @@ module Rank2Types where
2222
2323module Main where
2424
25−main = Trace.trace "Done"
25+main = Debug.Trace.trace "Done"
examples/passing/Recursion.purs+1−1
@@ -9,4 +9,4 @@ module Recursion where
99
1010module Main where
1111
12−main = Trace.trace "Done"
12+main = Debug.Trace.trace "Done"
examples/passing/RedefinedFixity.purs+1−1
@@ -15,4 +15,4 @@ import M2
1515
1616module Main where
1717
18−main = Trace.trace "Done"
18+main = Debug.Trace.trace "Done"
examples/passing/RuntimeScopeIssue.purs+1−1
@@ -22,4 +22,4 @@ import RuntimeScopeIssue
2222
2323import Prelude
2424
25−main = Trace.print $ a 10
25+main = Debug.Trace.print $ a 10
examples/passing/STArray.purs+4−4
@@ -1,9 +1,9 @@
11module Main where
22
33import Prelude
4−import Eff
5−import ST
6−import Arrays
4+import Control.Monad.Eff
5+import Control.Monad.ST
6+import Data.Array
77
88test = runSTArray (do
99 a <- newSTArray 2 0
@@ -20,4 +20,4 @@ fromTo lo hi = runSTArray (do
2020 arr <- newSTArray (hi - lo + 1) 0
2121 fromTo' lo hi 0 arr)
2222
23−main = Trace.print $ runPure (fromTo 10 20)
23+main = Debug.Trace.print $ runPure (fromTo 10 20)
examples/passing/TailCall.purs+1−1
@@ -17,4 +17,4 @@ module Main where
1717import Prelude
1818import TailCall
1919
20−main = Trace.print (test 0 [1, 2, 3])
20+main = Debug.Trace.print (test 0 [1, 2, 3])
examples/passing/Tick.purs+1−1
@@ -4,4 +4,4 @@ test' x = x
44
55module Main where
66
7−main = Trace.trace "Done"
7+main = Debug.Trace.trace "Done"
examples/passing/TopLevelCase.purs+1−1
@@ -17,4 +17,4 @@ module TopLevelCase where
1717
1818module Main where
1919
20−main = Trace.trace "Done"
20+main = Debug.Trace.trace "Done"
examples/passing/TypeClasses.purs+1−1
@@ -65,5 +65,5 @@ module Main where
6565import Prelude
6666import TypeClasses
6767
68−main = Trace.trace (test7 "Done")
68+main = Debug.Trace.trace (test7 "Done")
6969
examples/passing/TypeClassesInOrder.purs+1−1
@@ -8,4 +8,4 @@ class Foo a where
88instance Foo String where
99 foo s = s
1010
11−main = Trace.trace $ foo "Done"
11+main = Debug.Trace.trace $ foo "Done"
examples/passing/TypeClassesWithOverlappingTypeVariables.purs+2−2
@@ -1,10 +1,10 @@
11module Main where
22
33 import Prelude
4− import Either
4+ import Data.Either
55
66 instance Prelude.Functor (Either a) where
77 (<$>) _ (Left x) = Left x
88 (<$>) f (Right y) = Right (f y)
99
10− main = Trace.trace "Done"
10+ main = Debug.Trace.trace "Done"
examples/passing/TypeDecl.purs+1−1
@@ -11,4 +11,4 @@ module TypeDecl where
1111
1212module Main where
1313
14−main = Trace.trace "Done"
14+main = Debug.Trace.trace "Done"
examples/passing/TypeSynonyms.purs+3−2
@@ -22,7 +22,8 @@ module TypeSynonyms where
2222 test1 :: forall a b c. Lens (Pair (Pair a b) c) a
2323 test1 = composeLenses fst fst
2424
25− import Arrays
25+ import Data.Array ((:))
26+ import Data.Array.Unsafe
2627
2728 headLens :: forall a. Lens [a] a
2829 headLens =
@@ -36,4 +37,4 @@ module TypeSynonyms where
3637
3738module Main where
3839
39−main = Trace.trace "Done"
40+main = Debug.Trace.trace "Done"
examples/passing/iota.purs+1−1
@@ -8,4 +8,4 @@ module Iota where
88
99module Main where
1010
11−main = Trace.trace "Done"
11+main = Debug.Trace.trace "Done"
examples/passing/s.purs+1−1
@@ -4,4 +4,4 @@ module S where
44
55module Main where
66
7−main = Trace.trace "Done"
7+main = Debug.Trace.trace "Done"
prelude/prelude.purs+62−63
@@ -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
src/Language/PureScript/CodeGen/Optimize.hs+1−1
@@ -316,7 +316,7 @@ magicDo' = everywhere (mkT undo) . everywhere' (mkT convert)
316316 isEffFunc _ _ = False
317317 -- Module names
318318 prelude = ModuleName [ProperName "Prelude"]
319− effModule = ModuleName [ProperName "Eff"]
319+ effModule = ModuleName [ProperName "Control", ProperName "Monad", ProperName "Eff"]
320320 -- The name of the type class dictionary for the Monad Eff instance
321321 Right (Ident effDictName) = mkDictionaryValueName
322322 effModule
src/Language/PureScript/TypeChecker/Types.hs+1−1
@@ -208,7 +208,7 @@ typesOf mainModuleName moduleName vals = do
208208 -- If --main is enabled, need to check that `main` has type Eff eff a for some eff, a
209209 when (Just moduleName == mainModuleName && fst e == Ident "main") $ do
210210 [eff, a] <- replicateM 2 fresh
211− ty =?= TypeApp (TypeApp (TypeConstructor (Qualified (Just (ModuleName [ProperName "Eff"])) (ProperName "Eff"))) eff) a
211+ ty =?= TypeApp (TypeApp (TypeConstructor (Qualified (Just (ModuleName [ProperName "Control", ProperName "Monad", ProperName "Eff"])) (ProperName "Eff"))) eff) a
212212 -- Make sure unification variables do not escape
213213 escapeCheck val ty
214214 return triple