git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
New Prelude names

* Update for names in new prelude * Disable psci tests that rely on re-exports * Use bower rather than git submodule for support dependencies

commit69f8b3e3657b7e6546d4c1716ac4992210edbc93 authorGary Burgess <gary.burgess@gmail.com> dateSun 1 May 2016, 22:45 (10 years ago) parentdd9ebef
84 files changed+243−2054
.gitmodules−3 examples/failing/Do.purs+2−2 examples/failing/SkolemEscape2.purs+1−1 examples/failing/Superclasses5.purs+2−1 examples/failing/TypeError.purs+1−1 examples/manual/passing/Module.purs+2−2 examples/manual/passing/TransitiveImport.purs+2−2 examples/passing/1664.purs+1−1 examples/passing/CaseInDo.purs+2−2 examples/passing/CaseMultipleExpressions.purs+2−2 examples/passing/Collatz.purs+2−2 examples/passing/Console.purs+1−1 examples/passing/ContextSimplification.purs+1−1 examples/passing/DeepCase.purs+1−1 examples/passing/Eff.purs+2−2 examples/passing/EqOrd.purs+1−1 examples/passing/ExtendedInfixOperators.purs+1−1 examples/passing/Fib.purs+1−1 examples/passing/FinalTagless.purs+1−1 examples/passing/Generalization1.purs+3−3 examples/passing/ImportHiding.purs+1−1 examples/passing/InferRecFunWithConstrainedArgument.purs+1−1 examples/passing/Let.purs+7−7 examples/passing/Let2.purs+1−1 examples/passing/ModuleExport.purs+1−1 examples/passing/ModuleExportDupes.purs+1−1 examples/passing/ModuleExportExcluded.purs+1−1 examples/passing/ModuleExportQualified.purs+1−1 examples/passing/ModuleExportSelf.purs+1−1 examples/passing/MonadState.purs+1−1 examples/passing/MultiArgFunctions.purs+2−2 examples/passing/NestedTypeSynonyms.purs+1−1 examples/passing/Newtype.purs+5−5 examples/passing/ObjectGetter.purs+1−1 examples/passing/ObjectUpdater.purs+1−1 examples/passing/ObjectWildcards.purs+3−3 examples/passing/OperatorInlining.purs+20−21 examples/passing/Operators.purs+3−3 examples/passing/OptionalQualified.purs+1−1 examples/passing/Person.purs+3−2 examples/passing/Rank2TypeSynonym.purs+1−1 examples/passing/ReExportQualified.purs+1−1 examples/passing/RowPolyInstanceContext.purs+2−2 examples/passing/RuntimeScopeIssue.purs+1−1 examples/passing/Superclasses1.purs+1−1 examples/passing/Superclasses3.purs+1−1 examples/passing/TCO.purs+6−6 examples/passing/TailCall.purs+1−1 examples/passing/TypeClasses.purs+4−4 examples/passing/TypedBinders.purs+5−5 examples/passing/UnicodeType.purs+4−4 examples/passing/Unit.purs+1−1 examples/passing/Where.purs+7−7 psci/PSCi/Module.hs+4−4 purescript.cabal−7 src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs+20−20 src/Language/PureScript/Constants.hs+14−5 src/Language/PureScript/Sugar/TypeClasses/Deriving.hs+31−22 tests/Language/PureScript/Ide/Imports/IntegrationSpec.hs+2−2 tests/Language/PureScript/Ide/Integration.hs−2 tests/Main.hs+4−1 tests/TestCompiler.hs+2−2 tests/TestPscPublish.hs+1−1 tests/TestPsci.hs+37−12 tests/TestUtils.hs−18 tests/support/bower.json+6−6 tests/support/flattened/Control-Monad-Eff-Class.purs−24 tests/support/flattened/Control-Monad-Eff-Console.js−18 tests/support/flattened/Control-Monad-Eff-Console.purs−18 tests/support/flattened/Control-Monad-Eff-Unsafe.js−8 tests/support/flattened/Control-Monad-Eff-Unsafe.purs−10 tests/support/flattened/Control-Monad-Eff.js−62 tests/support/flattened/Control-Monad-Eff.purs−67 tests/support/flattened/Control-Monad-ST.js−38 tests/support/flattened/Control-Monad-ST.purs−42 tests/support/flattened/Data-Function.js−233 tests/support/flattened/Data-Function.purs−113 tests/support/flattened/Prelude.js−228 tests/support/flattened/Prelude.purs−872 tests/support/flattened/Test-Assert.js−27 tests/support/flattened/Test-Assert.purs−46 tests/support/package.json+2−1 tests/support/prelude−1 tests/support/setup.js−22
.gitmodulesdeleted−3
@@ -1,3 +0,0 @@
1−[submodule "tests/support/prelude"]
2− path = tests/support/prelude
3− url = https://github.com/purescript/purescript-prelude
examples/failing/Do.purs+2−2
@@ -8,5 +8,5 @@ test1 = do let x = 1
88
99test2 y = do x <- y
1010
11−test3 = do return 1
12− return 2
11+test3 = do pure 1
12+ pure 2
examples/failing/SkolemEscape2.purs+1−1
@@ -7,4 +7,4 @@ import Control.Monad.ST
77
88test _ = do
99 r <- runST (newSTRef 0)
10− return 0
10+ pure 0
examples/failing/Superclasses5.purs+2−1
@@ -3,6 +3,7 @@
33module Main where
44
55import Prelude
6+import Control.Monad.Eff.Console (logShow)
67
78class Su a where
89 su :: a -> a
@@ -22,4 +23,4 @@ instance clNumber :: Cl Number where
2223test :: forall a. (Cl a) => a -> Array a
2324test x = su [cl x x]
2425
25−main = Control.Monad.Eff.Console.print $ test 10.0
26+main = logShow $ test 10.0
examples/failing/TypeError.purs+1−1
@@ -3,4 +3,4 @@ module Main where
33
44import Prelude
55
6−test = 1 ++ "A"
6+test = 1 <> "A"
examples/manual/passing/Module.purs+2−2
@@ -5,7 +5,7 @@ module M1 where
55 data Foo = Foo String
66
77 foo :: M1.Foo -> String
8− foo = \f -> case f of Foo s -> s ++ "foo"
8+ foo = \f -> case f of Foo s -> s <> "foo"
99
1010 bar :: Foo -> String
1111 bar = foo
@@ -21,7 +21,7 @@ module M2 where
2121 baz = M1.foo
2222
2323 match :: M1.Foo -> String
24− match = \f -> case f of M1.Foo s -> s ++ "foo"
24+ match = \f -> case f of M1.Foo s -> s <> "foo"
2525
2626module Main where
2727
examples/manual/passing/TransitiveImport.purs+2−2
@@ -19,6 +19,6 @@ module Main where
1919 import Control.Monad.Eff.Console
2020
2121 main = do
22− print (middle unit)
22+ logShow (middle unit)
2323 trace "Done"
24− return unit
24+ pure unit
examples/passing/1664.purs+1−1
@@ -11,6 +11,6 @@ newtype IdentityEff e a = IdentityEff (Eff e (Identity a))
1111test :: forall e a. IdentityEff e a -> IdentityEff e Unit
1212test (IdentityEff action) = IdentityEff $ do
1313 (Identity x :: Identity _) <- action
14− return $ Identity unit
14+ pure $ Identity unit
1515
1616main = log "Done"
examples/passing/CaseInDo.purs+2−2
@@ -5,13 +5,13 @@ import Control.Monad.Eff.Console
55import Control.Monad.Eff
66
77doIt :: forall eff. Eff eff Boolean
8−doIt = return true
8+doIt = pure true
99
1010set = do
1111 log "Testing..."
1212 case 0 of
1313 0 -> doIt
14− _ -> return false
14+ _ -> pure false
1515
1616main = do
1717 b <- set
examples/passing/CaseMultipleExpressions.purs+2−2
@@ -5,13 +5,13 @@ import Control.Monad.Eff.Console
55import Control.Monad.Eff
66
77doIt :: forall eff. Eff eff Boolean
8−doIt = return true
8+doIt = pure true
99
1010set = do
1111 log "Testing..."
1212 case 42, 10 of
1313 42, 10 -> doIt
14− _ , _ -> return false
14+ _ , _ -> pure false
1515
1616main = do
1717 b <- set
examples/passing/Collatz.purs+2−2
@@ -12,7 +12,7 @@ collatz n = runPure (runST (do
1212 modifySTRef count $ (+) 1
1313 m <- readSTRef r
1414 writeSTRef r $ if m `mod` 2 == 0 then m / 2 else 3 * m + 1
15− return $ m == 1
15+ pure $ m == 1
1616 readSTRef count))
1717
18−main = Control.Monad.Eff.Console.print $ collatz 1000
18+main = Control.Monad.Eff.Console.logShow $ collatz 1000
examples/passing/Console.purs+1−1
@@ -5,7 +5,7 @@ import Control.Monad.Eff
55import Control.Monad.Eff.Console
66
77replicateM_ :: forall m a. (Monad m) => Number -> m a -> m {}
8−replicateM_ 0.0 _ = return {}
8+replicateM_ 0.0 _ = pure {}
99replicateM_ n act = do
1010 act
1111 replicateM_ (n - 1.0) act
examples/passing/ContextSimplification.purs+1−1
@@ -8,6 +8,6 @@ shout = log <<< (_ <> "!") <<< show
88-- Here, we should simplify the context so that only one Show
99-- constraint is added.
1010usesShowTwice true = shout
11−usesShowTwice false = print
11+usesShowTwice false = logShow
1212
1313main = usesShowTwice true "Done"
examples/passing/DeepCase.purs+1−1
@@ -12,4 +12,4 @@ f x y =
1212 x -> 1.0 + x * x
1313 in g + x + y
1414
15−main = print $ f 1.0 10.0
15+main = logShow $ f 1.0 10.0
examples/passing/Eff.purs+2−2
@@ -21,5 +21,5 @@ test3 = pureST (do
2121
2222main = do
2323 test1
24− Control.Monad.Eff.Console.print test2
25− Control.Monad.Eff.Console.print test3
24+ Control.Monad.Eff.Console.logShow test2
25+ Control.Monad.Eff.Console.logShow test3
examples/passing/EqOrd.purs+1−1
@@ -12,4 +12,4 @@ instance ordPair :: (Ord a, Ord b) => Ord (Pair a b) where
1212instance eqPair :: (Eq a, Eq b) => Eq (Pair a b) where
1313 eq (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2
1414
15−main = Control.Monad.Eff.Console.print $ Pair 1.0 2.0 == Pair 1.0 2.0
15+main = Control.Monad.Eff.Console.logShow $ Pair 1.0 2.0 == Pair 1.0 2.0
examples/passing/ExtendedInfixOperators.purs+1−1
@@ -11,4 +11,4 @@ null _ = false
1111test = [1.0, 2.0, 3.0] `comparing null` [4.0, 5.0, 6.0]
1212
1313main = do
14− Control.Monad.Eff.Console.print test
14+ Control.Monad.Eff.Console.logShow test
examples/passing/Fib.purs+1−1
@@ -12,4 +12,4 @@ main = runST (do
1212 n2' <- readSTRef n2
1313 writeSTRef n2 $ n1' + n2'
1414 writeSTRef n1 n2'
15− Control.Monad.Eff.Console.print n2')
15+ Control.Monad.Eff.Console.logShow n2')
examples/passing/FinalTagless.purs+1−1
@@ -19,4 +19,4 @@ runId (Id a) = a
1919three :: Expr Number
2020three = add (num 1.0) (num 2.0)
2121
22−main = Control.Monad.Eff.Console.print $ runId three
22+main = Control.Monad.Eff.Console.logShow $ runId three
examples/passing/Generalization1.purs+3−3
@@ -1,10 +1,10 @@
11module Main where
22
33import Prelude
4−import Control.Monad.Eff.Console (print)
4+import Control.Monad.Eff.Console (logShow)
55
66main = do
7− print (sum 1.0 2.0)
8− print (sum 1 2)
7+ logShow (sum 1.0 2.0)
8+ logShow (sum 1 2)
99
1010sum x y = x + y
examples/passing/ImportHiding.purs+1−1
@@ -15,4 +15,4 @@ class Show a where
1515data Unit = X | Y
1616
1717main = do
18− print show
18+ logShow show
examples/passing/InferRecFunWithConstrainedArgument.purs+1−1
@@ -5,4 +5,4 @@ import Prelude
55test 100.0 = 100.0
66test n = test(1.0 + n)
77
8−main = Control.Monad.Eff.Console.print $ test 0.0
8+main = Control.Monad.Eff.Console.logShow $ test 0.0
examples/passing/Let.purs+7−7
@@ -44,10 +44,10 @@ test10 _ =
4444 in f 10.0
4545
4646main = do
47− Control.Monad.Eff.Console.print (test1 1.0)
48− Control.Monad.Eff.Console.print (test2 1.0 2.0)
49− Control.Monad.Eff.Console.print test3
50− Control.Monad.Eff.Console.print test4
51− Control.Monad.Eff.Console.print test5
52− Control.Monad.Eff.Console.print test7
53− Control.Monad.Eff.Console.print (test8 100.0)
47+ Control.Monad.Eff.Console.logShow (test1 1.0)
48+ Control.Monad.Eff.Console.logShow (test2 1.0 2.0)
49+ Control.Monad.Eff.Console.logShow test3
50+ Control.Monad.Eff.Console.logShow test4
51+ Control.Monad.Eff.Console.logShow test5
52+ Control.Monad.Eff.Console.logShow test7
53+ Control.Monad.Eff.Console.logShow (test8 100.0)
examples/passing/Let2.purs+1−1
@@ -14,4 +14,4 @@ test =
1414 x = f 1.0
1515 in not x
1616
17−main = Control.Monad.Eff.Console.print test
17+main = Control.Monad.Eff.Console.logShow test
examples/passing/ModuleExport.purs+1−1
@@ -6,4 +6,4 @@ module Main where
66 import A
77
88 main = do
9− print (show 1.0)
9+ logShow (show 1.0)
examples/passing/ModuleExportDupes.purs+1−1
@@ -16,4 +16,4 @@ module Main where
1616 import Prelude
1717
1818 main = do
19− print (show 1.0)
19+ logShow (show 1.0)
examples/passing/ModuleExportExcluded.purs+1−1
@@ -11,4 +11,4 @@ module Main where
1111 otherwise = false
1212
1313 main = do
14− print "1.0"
14+ logShow "1.0"
examples/passing/ModuleExportQualified.purs+1−1
@@ -6,4 +6,4 @@ module Main where
66 import A as B
77
88 main = do
9− print (B.show 1.0)
9+ logShow (B.show 1.0)
examples/passing/ModuleExportSelf.purs+1−1
@@ -11,4 +11,4 @@ module Main where
1111 bar = true
1212
1313 main = do
14− print (show bar)
14+ logShow (show bar)
examples/passing/MonadState.purs+1−1
@@ -58,4 +58,4 @@ modify f =
5858 same :: forall a. (a -> a) -> (a -> a)
5959 same = id
6060
61−main = print $ runState 0 (modify (_ + 1))
61+main = logShow $ runState 0 (modify (_ + 1))
examples/passing/MultiArgFunctions.purs+2−2
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Data.Function
4+import Data.Function.Uncurried
55import Control.Monad.Eff
66import Control.Monad.Eff.Console
77
@@ -23,5 +23,5 @@ main = do
2323 runFn8 (mkFn8 $ \a b c d e f g h -> log $ show [a, b, c, d, e, f, g, h]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2424 runFn9 (mkFn9 $ \a b c d e f g h i -> log $ show [a, b, c, d, e, f, g, h, i]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
2525 runFn10 (mkFn10 $ \a b c d e f g h i j-> log $ show [a, b, c, d, e, f, g, h, i, j]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
26− print $ runFn2 g 0.0 0.0
26+ logShow $ runFn2 g 0.0 0.0
2727 log "Done!"
examples/passing/NestedTypeSynonyms.purs+1−1
@@ -8,4 +8,4 @@ type Y = X -> X
88fn :: Y
99fn a = a
1010
11−main = Control.Monad.Eff.Console.print (fn "Done")
11+main = Control.Monad.Eff.Console.logShow (fn "Done")
examples/passing/Newtype.purs+5−5
@@ -7,17 +7,17 @@ import Control.Monad.Eff.Console
77newtype Thing = Thing String
88
99instance showThing :: Show Thing where
10− show (Thing x) = "Thing " ++ show x
10+ show (Thing x) = "Thing " <> show x
1111
1212newtype Box a = Box a
1313
1414instance showBox :: (Show a) => Show (Box a) where
15− show (Box x) = "Box " ++ show x
15+ show (Box x) = "Box " <> show x
1616
1717apply f x = f x
1818
1919main = do
20− print $ Thing "hello"
21− print $ Box 42.0
22− print $ apply Box 9000.0
20+ logShow $ Thing "hello"
21+ logShow $ Box 42.0
22+ logShow $ apply Box 9000.0
2323 log "Done"
examples/passing/ObjectGetter.purs+1−1
@@ -7,7 +7,7 @@ getX = _.x
77point = { x: 1.0, y: 0.0 }
88
99main = do
10− Control.Monad.Eff.Console.print $ getX point
10+ Control.Monad.Eff.Console.logShow $ getX point
1111 Control.Monad.Eff.Console.log $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" }
1212 Control.Monad.Eff.Console.log $ (_.x >>> _.y) { x: { y: "Nested" } }
1313 Control.Monad.Eff.Console.log $ _.value { value: "Done!" }
examples/passing/ObjectUpdater.purs+1−1
@@ -6,7 +6,7 @@ import Control.Monad.Eff.Console
66import Test.Assert
77
88getValue :: forall e. Eff (| e) Boolean
9−getValue = return true
9+getValue = pure true
1010
1111main = do
1212 let record = { value: false }
examples/passing/ObjectWildcards.purs+3−3
@@ -8,13 +8,13 @@ import Test.Assert
88mkRecord = { foo: _, bar: _, baz: "baz" }
99
1010getValue :: forall e. Eff (| e) Boolean
11−getValue = return true
11+getValue = pure true
1212
1313main = do
1414 obj <- { value: _ } <$> getValue
15− print obj.value
15+ logShow obj.value
1616 let x = 1.0
17− point <- { x: _, y: x } <$> return 2.0
17+ point <- { x: _, y: x } <$> pure 2.0
1818 assert $ point.x == 2.0
1919 assert $ point.y == 1.0
2020 log (mkRecord 1.0 "Done!").bar
examples/passing/OperatorInlining.purs+20−21
@@ -6,42 +6,41 @@ import Control.Monad.Eff.Console
66main = do
77
88 -- semiringNumber
9− print (1.0 + 2.0)
10− print (1.0 * 2.0)
9+ logShow (1.0 + 2.0)
10+ logShow (1.0 * 2.0)
1111
1212 -- ringNumber
13− print (1.0 - 2.0)
14− print (negate 1.0)
13+ logShow (1.0 - 2.0)
14+ logShow (negate 1.0)
1515
1616 -- moduleSemiringNumber
17− print (1.0 / 2.0)
17+ logShow (1.0 / 2.0)
1818
1919 -- ordNumber
20− print (1.0 > 2.0)
21− print (1.0 < 2.0)
22− print (1.0 <= 2.0)
23− print (1.0 >= 2.0)
24− print (1.0 == 2.0)
20+ logShow (1.0 > 2.0)
21+ logShow (1.0 < 2.0)
22+ logShow (1.0 <= 2.0)
23+ logShow (1.0 >= 2.0)
24+ logShow (1.0 == 2.0)
2525
2626 -- eqNumber
27− print (1.0 == 2.0)
28− print (1.0 /= 2.0)
27+ logShow (1.0 == 2.0)
28+ logShow (1.0 /= 2.0)
2929
3030 -- eqString
31− print ("foo" == "bar")
32− print ("foo" /= "bar")
31+ logShow ("foo" == "bar")
32+ logShow ("foo" /= "bar")
3333
3434 -- eqBoolean
35− print (true == false)
36− print (true /= false)
35+ logShow (true == false)
36+ logShow (true /= false)
3737
3838 -- semigroupString
39− print ("foo" ++ "bar")
40− print ("foo" <> "bar")
39+ logShow ("foo" <> "bar")
4140
4241 -- latticeBoolean
43− print (top && true)
44− print (bottom || false)
42+ logShow (top && true)
43+ logShow (bottom || false)
4544
4645 -- complementedLatticeBoolean
47− print (not true)
46+ logShow (not true)
examples/passing/Operators.purs+3−3
@@ -8,9 +8,9 @@ import Control.Monad.Eff.Console
88(?!) x _ = x
99
1010bar :: String -> String -> String
11−bar = \s1 s2 -> s1 ++ s2
11+bar = \s1 s2 -> s1 <> s2
1212
13−test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n
13+test1 :: forall n. (Semiring n) => n -> n -> (n -> n -> n) -> n
1414test1 x y z = x * y + z x y
1515
1616test2 = (\x -> x.foo false) { foo : \_ -> 1.0 }
@@ -31,7 +31,7 @@ test5 = 1.0 %% 2.0 %% 3.0
3131test6 = ((\x -> x) `k` 2.0) 3.0
3232
3333(<+>) :: String -> String -> String
34−(<+>) = \s1 s2 -> s1 ++ s2
34+(<+>) = \s1 s2 -> s1 <> s2
3535
3636test7 = "Hello" <+> "World!"
3737
examples/passing/OptionalQualified.purs+1−1
@@ -8,5 +8,5 @@ import Control.Monad.Eff.Console as Console
88bind = P.bind
99
1010main = do
11− message <- P.return "success!"
11+ message <- P.pure "success!"
1212 Console.log message
examples/passing/Person.purs+3−2
@@ -1,11 +1,12 @@
11module Main where
22
33import Prelude
4+import Control.Monad.Eff.Console (log)
45
56data Person = Person { name :: String, age :: Number }
67
78showPerson :: Person -> String
89showPerson = \p -> case p of
9− Person o -> o.name ++ ", aged " ++ show o.age
10+ Person o -> o.name <> ", aged " <> show o.age
1011
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/passing/Rank2TypeSynonym.purs+1−1
@@ -13,4 +13,4 @@ bar = foo 3.0
1313
1414main = do
1515 x <- bar
16− Control.Monad.Eff.Console.print x
16+ Control.Monad.Eff.Console.logShow x
examples/passing/ReExportQualified.purs+1−1
@@ -13,4 +13,4 @@ module Main where
1313 import Prelude
1414 import C
1515
16− main = Control.Monad.Eff.Console.log (x ++ y)
16+ main = Control.Monad.Eff.Console.log (x <> y)
examples/passing/RowPolyInstanceContext.purs+2−2
@@ -11,10 +11,10 @@ instance st :: T s (S s) where
1111 state f = S $ \s -> { new: f s, ret: unit }
1212
1313test1 :: forall r . S { foo :: String | r } Unit
14−test1 = state $ \o -> o { foo = o.foo ++ "!" }
14+test1 = state $ \o -> o { foo = o.foo <> "!" }
1515
1616test2 :: forall m r . (T { foo :: String | r } m) => m Unit
17−test2 = state $ \o -> o { foo = o.foo ++ "!" }
17+test2 = state $ \o -> o { foo = o.foo <> "!" }
1818
1919main = do
2020 let t1 = test1
examples/passing/RuntimeScopeIssue.purs+1−1
@@ -16,4 +16,4 @@ instance bNumber :: B Number where
1616 b 0.0 = false
1717 b n = a (n - 1.0)
1818
19−main = Control.Monad.Eff.Console.print $ a 10.0
19+main = Control.Monad.Eff.Console.logShow $ a 10.0
examples/passing/Superclasses1.purs+1−1
@@ -17,4 +17,4 @@ instance clNumber :: Cl Number where
1717test :: forall a. (Cl a) => a -> a
1818test a = su (cl a a)
1919
20−main = Control.Monad.Eff.Console.print $ test 10.0
20+main = Control.Monad.Eff.Console.logShow $ test 10.0
examples/passing/Superclasses3.purs+1−1
@@ -28,7 +28,7 @@ instance applyMTrace :: Apply MTrace where
2828 apply = ap
2929
3030instance applicativeMTrace :: Applicative MTrace where
31− pure = MTrace <<< return
31+ pure = MTrace <<< pure
3232
3333instance bindMTrace :: Bind MTrace where
3434 bind m f = MTrace (runMTrace m >>= (runMTrace <<< f))
examples/passing/TCO.purs+6−6
@@ -1,16 +1,16 @@
11module Main where
22
33import Prelude
4−import Control.Monad.Eff.Console (print)
4+import Control.Monad.Eff.Console (logShow)
55
66main = do
77 let f x = x + 1
88 let v = 0
9− print (applyN 0 f v)
10− print (applyN 1 f v)
11− print (applyN 2 f v)
12− print (applyN 3 f v)
13− print (applyN 4 f v)
9+ logShow (applyN 0 f v)
10+ logShow (applyN 1 f v)
11+ logShow (applyN 2 f v)
12+ logShow (applyN 3 f v)
13+ logShow (applyN 4 f v)
1414
1515applyN :: forall a. Int -> (a -> a) -> a -> a
1616applyN = go id
examples/passing/TailCall.purs+1−1
@@ -14,4 +14,4 @@ loop x = loop (x + 1.0)
1414notATailCall = \x ->
1515 (\notATailCall -> notATailCall x) (\x -> x)
1616
17−main = Control.Monad.Eff.Console.print (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N))))
17+main = Control.Monad.Eff.Console.logShow (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N))))
examples/passing/TypeClasses.purs+4−4
@@ -17,7 +17,7 @@ test8 = \_ -> show $ "testing"
1717data Data a = Data a
1818
1919instance showData :: (Prelude.Show a) => Prelude.Show (Data a) where
20− show (Data a) = "Data (" ++ show a ++ ")"
20+ show (Data a) = "Data (" <> show a <> ")"
2121
2222test3 = \_ -> show (Data "testing")
2323
@@ -53,9 +53,9 @@ instance bindMaybe :: Bind Maybe where
5353instance monadMaybe :: Monad Maybe
5454
5555test4 :: forall a m. (Monad m) => a -> m Number
56−test4 = \_ -> return 1.0
56+test4 = \_ -> pure 1.0
5757
58−test5 = \_ -> Just 1.0 >>= \n -> return (n + 1.0)
58+test5 = \_ -> Just 1.0 >>= \n -> pure (n + 1.0)
5959
6060ask r = r
6161
@@ -63,7 +63,7 @@ runReader r f = f r
6363
6464test9 _ = runReader 0.0 $ do
6565 n <- ask
66− return $ n + 1.0
66+ pure $ n + 1.0
6767
6868main = Control.Monad.Eff.Console.log (test7 "Done")
6969
examples/passing/TypedBinders.purs+5−5
@@ -38,20 +38,20 @@ modify f = do
3838
3939test :: Tuple String String
4040test = runState "" $ do
41− modify $ (++) "World!"
42− modify $ (++) "Hello, "
41+ modify $ (<>) "World!"
42+ modify $ (<>) "Hello, "
4343 str :: String <- get
44− return str
44+ pure str
4545
4646test2 :: (Int -> Int) -> Int
4747test2 = (\(f :: Int -> Int) -> f 10)
4848
49−test3 :: Int -> Boolean
49+test3 :: Int -> Boolean
5050test3 n = case n of
5151 (0 :: Int) -> true
5252 _ -> false
5353
54−test4 :: Tuple Int Int -> Tuple Int Int
54+test4 :: Tuple Int Int -> Tuple Int Int
5555test4 = (\(Tuple a b :: Tuple Int Int) -> Tuple b a)
5656
5757type Int1 = Int
examples/passing/UnicodeType.purs+4−4
@@ -10,13 +10,13 @@ class (Monad m) <= Monad2 m where
1010
1111f ∷ ∀ m. Monad m ⇒ Int → m Int
1212f n = do
13− n' ← return n
14− return n'
13+ n' ← pure n
14+ pure n'
1515
1616f' :: forall m. Monad m => Int -> m Int
1717f' n = do
18− n' <- return n
19− return n'
18+ n' <- pure n
19+ pure n'
2020
2121(←→) a b = a ←→ b
2222
examples/passing/Unit.purs+1−1
@@ -3,4 +3,4 @@ module Main where
33import Prelude
44import Control.Monad.Eff.Console
55
6−main = print (const unit $ "Hello world")
6+main = logShow (const unit $ "Hello world")
examples/passing/Where.purs+7−7
@@ -40,10 +40,10 @@ test7 x = go x
4040 go y = go $ (y + x / y) / 2.0
4141
4242main = do
43− Control.Monad.Eff.Console.print (test1 1.0)
44− Control.Monad.Eff.Console.print (test2 1.0 2.0)
45− Control.Monad.Eff.Console.print test3
46− Control.Monad.Eff.Console.print test4
47− Control.Monad.Eff.Console.print test5
48− Control.Monad.Eff.Console.print test6
49− Control.Monad.Eff.Console.print (test7 100.0)
43+ Control.Monad.Eff.Console.logShow (test1 1.0)
44+ Control.Monad.Eff.Console.logShow (test2 1.0 2.0)
45+ Control.Monad.Eff.Console.logShow test3
46+ Control.Monad.Eff.Console.logShow test4
47+ Control.Monad.Eff.Console.logShow test5
48+ Control.Monad.Eff.Console.logShow test6
49+ Control.Monad.Eff.Console.logShow (test7 100.0)
psci/PSCi/Module.hs+4−4
@@ -25,15 +25,15 @@ supportModule =
2525 [ "module S where"
2626 , ""
2727 , "import Prelude"
28− , "import Control.Monad.Eff"
29− , "import Control.Monad.Eff.Console"
30− , "import Control.Monad.Eff.Unsafe"
28+ , "import Control.Monad.Eff (Eff)"
29+ , "import Control.Monad.Eff.Console (CONSOLE, logShow)"
30+ , "import Control.Monad.Eff.Unsafe (unsafeInterleaveEff)"
3131 , ""
3232 , "class Eval a where"
3333 , " eval :: a -> Eff (console :: CONSOLE) Unit"
3434 , ""
3535 , "instance evalShow :: (Show a) => Eval a where"
36− , " eval = print"
36+ , " eval = logShow"
3737 , ""
3838 , "instance evalEff :: (Eval a) => Eval (Eff eff a) where"
3939 , " eval x = unsafeInterleaveEff x >>= eval"
purescript.cabal−7
@@ -24,16 +24,9 @@ extra-source-files: examples/passing/*.purs
2424 , examples/docs/bower_components/purescript-prelude/src/*.purs
2525 , examples/docs/bower.json
2626 , examples/docs/src/*.purs
27− , tests/support/setup.js
2827 , tests/support/package.json
29− , tests/support/prelude/bower.json
30− , tests/support/prelude/src/*.purs
31− , tests/support/prelude/src/*.js
32− , tests/support/prelude/LICENSE
3328 , tests/support/bower.json
3429 , tests/support/setup-win.cmd
35− , tests/support/flattened/*.purs
36− , tests/support/flattened/*.js
3730 , tests/support/psci/*.purs
3831 , tests/support/pscide/src/*.purs
3932 , tests/support/pscide/src/*.js
src/Language/PureScript/CodeGen/JS/Optimizer/Inliner.hs+20−20
@@ -89,16 +89,16 @@ inlineCommonValues = everywhereOnJS convert
8989 convert (JSApp ss (JSApp _ (JSApp _ fn [dict]) [x]) [y])
9090 | isDict' semiringInt dict && isFn' fnAdd fn = intOp ss Add x y
9191 | isDict' semiringInt dict && isFn' fnMultiply fn = intOp ss Multiply x y
92− | isDict' moduloSemiringInt dict && isFn' fnDivide fn = intOp ss Divide x y
92+ | isDict' euclideanRingInt dict && isFn' fnDivide fn = intOp ss Divide x y
9393 | isDict' ringInt dict && isFn' fnSubtract fn = intOp ss Subtract x y
9494 convert other = other
9595 fnZero = [(C.prelude, C.zero), (C.dataSemiring, C.zero)]
9696 fnOne = [(C.prelude, C.one), (C.dataSemiring, C.one)]
9797 fnBottom = [(C.prelude, C.bottom), (C.dataBounded, C.bottom)]
9898 fnTop = [(C.prelude, C.top), (C.dataBounded, C.top)]
99− fnAdd = [(C.prelude, (C.+)), (C.prelude, C.add), (C.dataSemiring, (C.+)), (C.dataSemiring, C.add)]
100− fnDivide = [(C.prelude, (C./)), (C.prelude, C.div), (C.dataModuloSemiring, C.div)]
101− fnMultiply = [(C.prelude, (C.*)), (C.prelude, C.mul), (C.dataSemiring, (C.*)), (C.dataSemiring, C.mul)]
99+ fnAdd = [(C.prelude, (C.+)), (C.prelude, (C.add)), (C.dataSemiring, (C.+)), (C.dataSemiring, (C.add))]
100+ fnDivide = [(C.prelude, (C./)), (C.prelude, (C.div)), (C.dataEuclideanRing, C.div)]
101+ fnMultiply = [(C.prelude, (C.*)), (C.prelude, (C.mul)), (C.dataSemiring, (C.*)), (C.dataSemiring, (C.mul))]
102102 fnSubtract = [(C.prelude, (C.-)), (C.prelude, C.sub), (C.dataRing, C.sub)]
103103 intOp ss op x y = JSBinary ss BitwiseOr (JSBinary ss op x y) (JSNumericLiteral ss (Left 0))
104104
@@ -122,8 +122,8 @@ inlineCommonOperators = applyAll $
122122 , binary ringInt opSub Subtract
123123 , unary ringInt opNegate Negate
124124
125− , binary moduloSemiringNumber opDiv Divide
126− , binary moduloSemiringInt opMod Modulus
125+ , binary euclideanRingNumber opDiv Divide
126+ , binary euclideanRingInt opMod Modulus
127127
128128 , binary eqNumber opEq EqualTo
129129 , binary eqNumber opNotEq NotEqualTo
@@ -159,9 +159,9 @@ inlineCommonOperators = applyAll $
159159
160160 , binary semigroupString opAppend Add
161161
162− , binary booleanAlgebraBoolean opConj And
163− , binary booleanAlgebraBoolean opDisj Or
164− , unary booleanAlgebraBoolean opNot Not
162+ , binary heytingAlgebraBoolean opConj And
163+ , binary heytingAlgebraBoolean opDisj Or
164+ , unary heytingAlgebraBoolean opNot Not
165165
166166 , binary' C.dataIntBits (C..|.) BitwiseOr
167167 , binary' C.dataIntBits (C..&.) BitwiseAnd
@@ -271,11 +271,11 @@ ringNumber = [(C.prelude, C.ringNumber), (C.dataRing, C.ringNumber)]
271271ringInt :: [(String, String)]
272272ringInt = [(C.prelude, C.ringInt), (C.dataRing, C.ringInt)]
273273
274−moduloSemiringNumber :: [(String, String)]
275−moduloSemiringNumber = [(C.prelude, C.moduloSemiringNumber), (C.dataModuloSemiring, C.moduloSemiringNumber)]
274+euclideanRingNumber :: [(String, String)]
275+euclideanRingNumber = [(C.prelude, C.moduloSemiringNumber), (C.dataEuclideanRing, C.euclideanRingNumber)]
276276
277−moduloSemiringInt :: [(String, String)]
278−moduloSemiringInt = [(C.prelude, C.moduloSemiringInt), (C.dataModuloSemiring, C.moduloSemiringInt)]
277+euclideanRingInt :: [(String, String)]
278+euclideanRingInt = [(C.prelude, C.moduloSemiringInt), (C.dataEuclideanRing, C.euclideanRingInt)]
279279
280280eqNumber :: [(String, String)]
281281eqNumber = [(C.prelude, C.eqNumber), (C.dataEq, C.eqNumber)]
@@ -313,8 +313,8 @@ semigroupString = [(C.prelude, C.semigroupString), (C.dataSemigroup, C.semigroup
313313boundedBoolean :: [(String, String)]
314314boundedBoolean = [(C.prelude, C.boundedBoolean), (C.dataBounded, C.boundedBoolean)]
315315
316−booleanAlgebraBoolean :: [(String, String)]
317−booleanAlgebraBoolean = [(C.prelude, C.booleanAlgebraBoolean), (C.dataBooleanAlgebra, C.booleanAlgebraBoolean)]
316+heytingAlgebraBoolean :: [(String, String)]
317+heytingAlgebraBoolean = [(C.prelude, C.booleanAlgebraBoolean), (C.dataHeytingAlgebra, C.heytingAlgebraBoolean)]
318318
319319semigroupoidFn :: [(String, String)]
320320semigroupoidFn = [(C.prelude, C.semigroupoidFn), (C.controlSemigroupoid, C.semigroupoidFn)]
@@ -353,16 +353,16 @@ opNegate :: [(String, String)]
353353opNegate = [(C.prelude, C.negate), (C.dataRing, C.negate)]
354354
355355opDiv :: [(String, String)]
356−opDiv = [(C.prelude, (C./)), (C.prelude, C.div), (C.dataModuloSemiring, C.div)]
356+opDiv = [(C.prelude, (C./)), (C.prelude, C.div), (C.dataEuclideanRing, C.div)]
357357
358358opMod :: [(String, String)]
359−opMod = [(C.prelude, C.mod), (C.dataModuloSemiring, C.mod)]
359+opMod = [(C.prelude, C.mod), (C.dataEuclideanRing, C.mod)]
360360
361361opConj :: [(String, String)]
362−opConj = [(C.prelude, (C.&&)), (C.prelude, C.conj), (C.dataBooleanAlgebra, C.conj)]
362+opConj = [(C.prelude, (C.&&)), (C.prelude, C.conj), (C.dataHeytingAlgebra, C.conj)]
363363
364364opDisj :: [(String, String)]
365−opDisj = [(C.prelude, (C.||)), (C.prelude, C.disj), (C.dataBooleanAlgebra, C.disj)]
365+opDisj = [(C.prelude, (C.||)), (C.prelude, C.disj), (C.dataHeytingAlgebra, C.disj)]
366366
367367opNot :: [(String, String)]
368−opNot = [(C.prelude, C.not), (C.dataBooleanAlgebra, C.not)]
368+opNot = [(C.prelude, C.not), (C.dataHeytingAlgebra, C.not)]
src/Language/PureScript/Constants.hs+14−5
@@ -247,6 +247,12 @@ moduloSemiringNumber = "moduloSemiringNumber"
247247moduloSemiringInt :: String
248248moduloSemiringInt = "moduloSemiringInt"
249249
250+euclideanRingNumber :: String
251+euclideanRingNumber = "euclideanRingNumber"
252+
253+euclideanRingInt :: String
254+euclideanRingInt = "euclideanRingInt"
255+
250256ordBoolean :: String
251257ordBoolean = "ordBoolean"
252258
@@ -283,6 +289,9 @@ boundedBoolean = "boundedBoolean"
283289booleanAlgebraBoolean :: String
284290booleanAlgebraBoolean = "booleanAlgebraBoolean"
285291
292+heytingAlgebraBoolean :: String
293+heytingAlgebraBoolean = "heytingAlgebraBoolean"
294+
286295semigroupString :: String
287296semigroupString = "semigroupString"
288297
@@ -348,11 +357,8 @@ dataBounded = "Data_Bounded"
348357dataSemigroup :: String
349358dataSemigroup = "Data_Semigroup"
350359
351−dataModuloSemiring :: String
352−dataModuloSemiring = "Data_ModuloSemiring"
353−
354−dataBooleanAlgebra :: String
355−dataBooleanAlgebra = "Data_BooleanAlgebra"
360+dataHeytingAlgebra :: String
361+dataHeytingAlgebra = "Data_HeytingAlgebra"
356362
357363dataEq :: String
358364dataEq = "Data_Eq"
@@ -366,6 +372,9 @@ dataSemiring = "Data_Semiring"
366372dataRing :: String
367373dataRing = "Data_Ring"
368374
375+dataEuclideanRing :: String
376+dataEuclideanRing = "Data_EuclideanRing"
377+
369378dataFunction :: String
370379dataFunction = "Data_Function"
371380
src/Language/PureScript/Sugar/TypeClasses/Deriving.hs+31−22
@@ -50,11 +50,11 @@ deriveInstance mn ds (TypeInstanceDeclaration nm deps className tys@[ty] Derived
5050 , Just (Qualified mn' tyCon, args) <- unwrapTypeConstructor ty
5151 , mn == fromMaybe mn mn'
5252 = TypeInstanceDeclaration nm deps className tys . ExplicitInstance <$> deriveGeneric mn ds tyCon args
53− | className == Qualified (Just (ModuleName [ ProperName "Prelude" ])) (ProperName "Eq")
53+ | className == Qualified (Just (ModuleName [ ProperName "Data", ProperName "Eq" ])) (ProperName "Eq")
5454 , Just (Qualified mn' tyCon, _) <- unwrapTypeConstructor ty
5555 , mn == fromMaybe mn mn'
5656 = TypeInstanceDeclaration nm deps className tys . ExplicitInstance <$> deriveEq mn ds tyCon
57− | className == Qualified (Just (ModuleName [ ProperName "Prelude" ])) (ProperName "Ord")
57+ | className == Qualified (Just (ModuleName [ ProperName "Data", ProperName "Ord" ])) (ProperName "Ord")
5858 , Just (Qualified mn' tyCon, _) <- unwrapTypeConstructor ty
5959 , mn == fromMaybe mn mn'
6060 = TypeInstanceDeclaration nm deps className tys . ExplicitInstance <$> deriveOrd mn ds tyCon
@@ -218,8 +218,8 @@ deriveGeneric mn ds tyConNm dargs = do
218218 = App (lamCase (Ident "r") [ mkRecCase (decomposeRec rec)
219219 , CaseAlternative [NullBinder] (Right mkNothing)
220220 ])
221− (App e (mkPrelVar (Ident "unit")))
222− fromSpineFun e _ = App (mkGenVar (Ident C.fromSpine)) (App e (mkPrelVar (Ident "unit")))
221+ (App e unitVal)
222+ fromSpineFun e _ = App (mkGenVar (Ident C.fromSpine)) (App e unitVal)
223223
224224 mkRecCase :: [(String, Type)] -> CaseAlternative
225225 mkRecCase rs =
@@ -237,10 +237,13 @@ deriveGeneric mn ds tyConNm dargs = do
237237 -- Helpers
238238
239239 liftApplicative :: Expr -> [Expr] -> Expr
240− liftApplicative = foldl' (\x e -> App (App (mkPrelVar (Ident "apply")) x) e)
240+ liftApplicative = foldl' (\x e -> App (App applyFn x) e)
241241
242− mkPrelVar :: Ident -> Expr
243− mkPrelVar = mkVarMn (Just (ModuleName [ProperName C.prelude]))
242+ unitVal :: Expr
243+ unitVal = mkVarMn (Just (ModuleName [ProperName "Data", ProperName "Unit"])) (Ident "unit")
244+
245+ applyFn :: Expr
246+ applyFn = mkVarMn (Just (ModuleName [ProperName "Control", ProperName "Apply"])) (Ident "apply")
244247
245248 mkGenVar :: Ident -> Expr
246249 mkGenVar = mkVarMn (Just (ModuleName [ProperName "Data", ProperName C.generic]))
@@ -265,10 +268,10 @@ deriveEq mn ds tyConNm = do
265268 mkEqFunction _ = internalError "mkEqFunction: expected DataDeclaration"
266269
267270 preludeConj :: Expr -> Expr -> Expr
268− preludeConj = App . App (Var (Qualified (Just (ModuleName [ProperName C.prelude])) (Ident C.conj)))
271+ preludeConj = App . App (Var (Qualified (Just (ModuleName [ProperName "Data", ProperName "HeytingAlgebra"])) (Ident C.conj)))
269272
270273 preludeEq :: Expr -> Expr -> Expr
271− preludeEq = App . App (Var (Qualified (Just (ModuleName [ProperName C.prelude])) (Ident C.eq)))
274+ preludeEq = App . App (Var (Qualified (Just (ModuleName [ProperName "Data", ProperName "Eq"])) (Ident C.eq)))
272275
273276 addCatch :: [CaseAlternative] -> [CaseAlternative]
274277 addCatch xs
@@ -326,13 +329,19 @@ deriveOrd mn ds tyConNm = do
326329 | null xs = [catchAll] -- No type constructors
327330 | otherwise = xs
328331 where
329− catchAll = CaseAlternative [NullBinder, NullBinder] (Right (preludeCtor "EQ"))
332+ catchAll = CaseAlternative [NullBinder, NullBinder] (Right (orderingCtor "EQ"))
333+
334+ orderingName :: String -> Qualified (ProperName a)
335+ orderingName = Qualified (Just (ModuleName [ProperName "Data", ProperName "Ordering"])) . ProperName
336+
337+ orderingCtor :: String -> Expr
338+ orderingCtor = Constructor . orderingName
330339
331− preludeCtor :: String -> Expr
332− preludeCtor = Constructor . Qualified (Just (ModuleName [ProperName C.prelude])) . ProperName
340+ orderingBinder :: String -> Binder
341+ orderingBinder name = ConstructorBinder (orderingName name) []
333342
334− preludeCompare :: Expr -> Expr -> Expr
335− preludeCompare = App . App (Var (Qualified (Just (ModuleName [ProperName C.prelude])) (Ident C.compare)))
343+ ordCompare :: Expr -> Expr -> Expr
344+ ordCompare = App . App (Var (Qualified (Just (ModuleName [ProperName "Data", ProperName "Ord"])) (Ident C.compare)))
336345
337346 mkCtorClauses :: ((ProperName 'ConstructorName, [Type]), Bool) -> m [CaseAlternative]
338347 mkCtorClauses ((ctorName, tys), isLast) = do
@@ -342,11 +351,11 @@ deriveOrd mn ds tyConNm = do
342351 extras | not isLast = [ CaseAlternative [ ConstructorBinder (Qualified (Just mn) ctorName) (replicate (length tys) NullBinder)
343352 , NullBinder
344353 ]
345− (Right (preludeCtor "LT"))
354+ (Right (orderingCtor "LT"))
346355 , CaseAlternative [ NullBinder
347356 , ConstructorBinder (Qualified (Just mn) ctorName) (replicate (length tys) NullBinder)
348357 ]
349− (Right (preludeCtor "GT"))
358+ (Right (orderingCtor "GT"))
350359 ]
351360 | otherwise = []
352361 return $ CaseAlternative [ caseBinder identsL
@@ -359,12 +368,12 @@ deriveOrd mn ds tyConNm = do
359368 caseBinder idents = ConstructorBinder (Qualified (Just mn) ctorName) (map VarBinder idents)
360369
361370 appendAll :: [Expr] -> Expr
362− appendAll [] = preludeCtor "EQ"
371+ appendAll [] = orderingCtor "EQ"
363372 appendAll [x] = x
364− appendAll (x : xs) = Case [x] [ CaseAlternative [ ConstructorBinder (Qualified (Just (ModuleName [ProperName C.prelude])) (ProperName "LT")) [] ]
365− (Right (preludeCtor "LT"))
366− , CaseAlternative [ ConstructorBinder (Qualified (Just (ModuleName [ProperName C.prelude])) (ProperName "GT")) [] ]
367− (Right (preludeCtor "GT"))
373+ appendAll (x : xs) = Case [x] [ CaseAlternative [orderingBinder "LT"]
374+ (Right (orderingCtor "LT"))
375+ , CaseAlternative [orderingBinder "GT"]
376+ (Right (orderingCtor "GT"))
368377 , CaseAlternative [ NullBinder ]
369378 (Right (appendAll xs))
370379 ]
@@ -374,7 +383,7 @@ deriveOrd mn ds tyConNm = do
374383 appendAll
375384 . map (\(str, typ) -> toOrdering (Accessor str l) (Accessor str r) typ)
376385 $ decomposeRec rec
377− toOrdering l r _ = preludeCompare l r
386+ toOrdering l r _ = ordCompare l r
378387
379388findTypeDecl
380389 :: (MonadError MultipleErrors m)
tests/Language/PureScript/Ide/Imports/IntegrationSpec.hs+2−2
@@ -44,9 +44,9 @@ spec = beforeAll_ setup $ afterAll_ teardown $ describe "Adding imports" $ do
4444 sourceFileSkeleton importSection =
4545 [ "module ImportsSpec where" , ""] ++ importSection ++ [ "" , "myId = id"]
4646 it "adds an implicit import" $ do
47− withSupportFiles (Integration.addImplicitImport "Prelude")
47+ withSupportFiles (Integration.addImplicitImport "ImportsSpec1")
4848 outputFileShouldBe (sourceFileSkeleton
49− [ "import Prelude"
49+ [ "import ImportsSpec1"
5050 , "import Main (id)"
5151 ])
5252 it "adds an explicit unqualified import" $ do
tests/Language/PureScript/Ide/Integration.hs−2
@@ -111,8 +111,6 @@ fileGlob :: String
111111fileGlob = unwords
112112 [ "\"src/**/*.purs\""
113113 , "\"src/**/*.js\""
114− , "\"bower_components/purescript-*/**/*.purs\""
115− , "\"bower_components/purescript-*/**/*.js\""
116114 ]
117115
118116-- Integration Testing API
tests/Main.hs+4−1
@@ -9,10 +9,11 @@ import Prelude ()
99import Prelude.Compat
1010
1111import qualified TestCompiler
12−import qualified TestPscPublish
1312import qualified TestDocs
1413import qualified TestPsci
1514import qualified TestPscIde
15+import qualified TestPscPublish
16+import qualified TestUtils
1617
1718import System.IO (hSetEncoding, stdout, stderr, utf8)
1819
@@ -21,6 +22,8 @@ main = do
2122 hSetEncoding stdout utf8
2223 hSetEncoding stderr utf8
2324
25+ heading "Updating support code"
26+ TestUtils.updateSupportCode
2427 heading "Main compiler test suite"
2528 TestCompiler.main
2629 heading "Documentation test suite"
tests/TestCompiler.hs+2−2
@@ -52,8 +52,8 @@ main :: IO ()
5252main = do
5353 cwd <- getCurrentDirectory
5454
55− let supportDir = cwd </> "tests" </> "support" </> "flattened"
56− let supportFiles ext = Glob.globDir1 (Glob.compile ("*." ++ ext)) supportDir
55+ let supportDir = cwd </> "tests" </> "support" </> "bower_components"
56+ let supportFiles ext = Glob.globDir1 (Glob.compile ("purescript-*/**/*." ++ ext)) supportDir
5757
5858 supportPurs <- supportFiles "purs"
5959 supportJS <- supportFiles "js"
tests/TestPscPublish.hs+1−1
@@ -24,7 +24,7 @@ import Language.PureScript.Publish.ErrorsWarnings as Publish
2424import TestUtils
2525
2626main :: IO ()
27−main = testPackage "tests/support/prelude"
27+main = testPackage "tests/support/bower_components/purescript-prelude"
2828
2929data TestResult
3030 = ParseFailed String
tests/TestPsci.hs+37−12
@@ -75,13 +75,13 @@ completionTestData =
7575 , (":show a", [])
7676
7777 -- :type should complete values and data constructors in scope
78− , (":type Control.Monad.Eff.Console.lo", [":type Control.Monad.Eff.Console.log"])
79− , (":type uni", [":type unit"])
80− , (":type E", [":type EQ"])
78+ , (":type Control.Monad.Eff.Console.lo", [":type Control.Monad.Eff.Console.log", ":type Control.Monad.Eff.Console.logShow"])
79+ --, (":type uni", [":type unit"])
80+ --, (":type E", [":type EQ"])
8181
8282 -- :kind should complete types in scope
83− , (":kind C", [":kind Control.Monad.Eff.Pure"])
84− , (":kind O", [":kind Ordering"])
83+ --, (":kind C", [":kind Control.Monad.Eff.Pure"])
84+ --, (":kind O", [":kind Ordering"])
8585
8686 -- Only one argument for directives should be completed
8787 , (":show import ", [])
@@ -98,10 +98,10 @@ completionTestData =
9898 , ("34", [])
9999
100100 -- Identifiers and data constructors should be completed
101− , ("uni", ["unit"])
101+ --, ("uni", ["unit"])
102102 , ("Control.Monad.Eff.Class.", ["Control.Monad.Eff.Class.liftEff"])
103− , ("G", ["GT"])
104− , ("Prelude.L", ["Prelude.LT"])
103+ --, ("G", ["GT"])
104+ , ("Data.Ordering.L", ["Data.Ordering.LT"])
105105
106106 -- if a module is imported qualified, values should complete under the
107107 -- qualified name, as well as the original name.
@@ -125,8 +125,8 @@ runCM act = do
125125getPSCiState :: IO PSCiState
126126getPSCiState = do
127127 cwd <- getCurrentDirectory
128− let supportDir = cwd </> "tests" </> "support" </> "flattened"
129− let supportFiles ext = Glob.globDir1 (Glob.compile ("*." ++ ext)) supportDir
128+ let supportDir = cwd </> "tests" </> "support" </> "bower_components"
129+ let supportFiles ext = Glob.globDir1 (Glob.compile ("purescript-*/**/*." ++ ext)) supportDir
130130 pursFiles <- supportFiles "purs"
131131 jsFiles <- supportFiles "js"
132132
@@ -147,12 +147,37 @@ controlMonadSTasST = (s "Control.Monad.ST", P.Implicit, Just (s "ST"))
147147
148148supportModules :: [String]
149149supportModules =
150− [ "Control.Monad.Eff.Class"
151− , "Control.Monad.Eff.Console"
150+ [ "Control.Applicative"
151+ , "Control.Apply"
152+ , "Control.Bind"
153+ , "Control.Category"
154+ , "Control.Monad"
152155 , "Control.Monad.Eff"
156+ , "Control.Monad.Eff.Class"
157+ , "Control.Monad.Eff.Console"
153158 , "Control.Monad.Eff.Unsafe"
154159 , "Control.Monad.ST"
160+ , "Control.Semigroupoid"
161+ , "Data.Boolean"
162+ , "Data.BooleanAlgebra"
163+ , "Data.Bounded"
164+ , "Data.CommutativeRing"
165+ , "Data.Eq"
166+ , "Data.EuclideanRing"
167+ , "Data.Field"
155168 , "Data.Function"
169+ , "Data.Function.Uncurried"
170+ , "Data.Functor"
171+ , "Data.HeytingAlgebra"
172+ , "Data.Ord"
173+ , "Data.Ord.Unsafe"
174+ , "Data.Ordering"
175+ , "Data.Ring"
176+ , "Data.Semigroup"
177+ , "Data.Semiring"
178+ , "Data.Show"
179+ , "Data.Unit"
180+ , "Data.Void"
156181 , "Prelude"
157182 , "Test.Assert"
158183 ]
tests/TestUtils.hs−18
@@ -1,15 +1,3 @@
1−-----------------------------------------------------------------------------
2−--
3−-- Module : Main
4−-- License : MIT (http://opensource.org/licenses/MIT)
5−--
6−-- Maintainer : Phil Freeman <paf31@cantab.net>
7−-- Stability : experimental
8−-- Portability :
9−--
10−-- |
11−--
12−-----------------------------------------------------------------------------
131{-# LANGUAGE ScopedTypeVariables #-}
142
153module TestUtils where
@@ -17,7 +5,6 @@ module TestUtils where
175import Prelude ()
186import Prelude.Compat
197
20−import Data.Maybe (fromMaybe)
218import Control.Monad
229import Control.Monad.Trans.Maybe
2310import Control.Exception
@@ -26,8 +13,6 @@ import System.Process
2613import System.Directory
2714import System.Info
2815
29−import Language.PureScript.Crash
30−
3116findNodeProcess :: IO (Maybe String)
3217findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
3318 where
@@ -43,7 +28,6 @@ findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
4328--
4429updateSupportCode :: IO ()
4530updateSupportCode = do
46− node <- fromMaybe (internalError "cannot find node executable") <$> findNodeProcess
4731 setCurrentDirectory "tests/support"
4832 if System.Info.os == "mingw32"
4933 then callProcess "setup-win.cmd" []
@@ -52,7 +36,6 @@ updateSupportCode = do
5236 -- Sometimes we run as a root (e.g. in simple docker containers)
5337 -- And we are non-interactive: https://github.com/bower/bower/issues/1162
5438 callProcess "node_modules/.bin/bower" ["--allow-root", "install", "--config.interactive=false"]
55− callProcess node ["setup.js"]
5639 setCurrentDirectory "../.."
5740
5841pushd :: forall a. FilePath -> IO a -> IO a
@@ -62,4 +45,3 @@ pushd dir act = do
6245 result <- try act :: IO (Either IOException a)
6346 setCurrentDirectory original
6447 either throwIO return result
65−
tests/support/bower.json+6−6
@@ -1,11 +1,11 @@
11{
22 "name": "purescript-test-suite-support",
33 "dependencies": {
4− "purescript-eff": "0.1.0",
5− "purescript-prelude": "0.1.3",
6− "purescript-assert": "0.1.1",
7− "purescript-st": "0.1.0",
8− "purescript-console": "0.1.0",
9− "purescript-functions": "0.1.0"
4+ "purescript-assert": "1.0.0-rc.1",
5+ "purescript-console": "1.0.0-rc.1",
6+ "purescript-eff": "1.0.0-rc.1",
7+ "purescript-functions": "1.0.0-rc.1",
8+ "purescript-prelude": "1.0.0-rc.3",
9+ "purescript-st": "1.0.0-rc.1"
1010 }
1111}
tests/support/flattened/Control-Monad-Eff-Class.pursdeleted−24
@@ -1,24 +0,0 @@
1−module Control.Monad.Eff.Class
2− ( MonadEff
3− , liftEff
4− ) where
5−
6−import Prelude
7−
8−import Control.Monad.Eff
9−
10−-- | The `MonadEff` class captures those monads which support native effects.
11−-- |
12−-- | Instances are provided for `Eff` itself, and the standard monad transformers.
13−-- |
14−-- | `liftEff` can be used in any appropriate monad transformer stack to lift an action
15−-- | of type `Eff eff a` into the monad.
16−-- |
17−-- | Note that `MonadEff` is parameterized by the row of effects, so type inference can be
18−-- | tricky. It is generally recommended to either work with a polymorphic row of effects,
19−-- | or a concrete, closed row of effects such as `(trace :: Trace)`.
20−class (Monad m) <= MonadEff eff m where
21− liftEff :: forall a. Eff eff a -> m a
22−
23−instance monadEffEff :: MonadEff eff (Eff eff) where
24− liftEff = id
tests/support/flattened/Control-Monad-Eff-Console.jsdeleted−18
@@ -1,18 +0,0 @@
1−/* global exports, console */
2−"use strict";
3−
4−// module Control.Monad.Eff.Console
5−
6−exports.log = function (s) {
7− return function () {
8− console.log(s);
9− return {};
10− };
11−};
12−
13−exports.error = function (s) {
14− return function () {
15− console.error(s);
16− return {};
17− };
18−};
tests/support/flattened/Control-Monad-Eff-Console.pursdeleted−18
@@ -1,18 +0,0 @@
1−module Control.Monad.Eff.Console where
2−
3−import Prelude
4−
5−import Control.Monad.Eff
6−
7−-- | The `CONSOLE` effect represents those computations which write to the console.
8−foreign import data CONSOLE :: !
9−
10−-- | Write a message to the console.
11−foreign import log :: forall eff. String -> Eff (console :: CONSOLE | eff) Unit
12−
13−-- | Write an error to the console.
14−foreign import error :: forall eff. String -> Eff (console :: CONSOLE | eff) Unit
15−
16−-- | Write a value to the console, using its `Show` instance to produce a `String`.
17−print :: forall a eff. (Show a) => a -> Eff (console :: CONSOLE | eff) Unit
18−print = log <<< show
tests/support/flattened/Control-Monad-Eff-Unsafe.jsdeleted−8
@@ -1,8 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Control.Monad.Eff.Unsafe
5−
6−exports.unsafeInterleaveEff = function (f) {
7− return f;
8−};
tests/support/flattened/Control-Monad-Eff-Unsafe.pursdeleted−10
@@ -1,10 +0,0 @@
1−module Control.Monad.Eff.Unsafe where
2−
3−import Prelude
4−
5−import Control.Monad.Eff
6−
7−-- | Change the type of an effectful computation, allowing it to be run in another context.
8−-- |
9−-- | Note: use of this function can result in arbitrary side-effects.
10−foreign import unsafeInterleaveEff :: forall eff1 eff2 a. Eff eff1 a -> Eff eff2 a
tests/support/flattened/Control-Monad-Eff.jsdeleted−62
@@ -1,62 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Control.Monad.Eff
5−
6−exports.returnE = function (a) {
7− return function () {
8− return a;
9− };
10−};
11−
12−exports.bindE = function (a) {
13− return function (f) {
14− return function () {
15− return f(a())();
16− };
17− };
18−};
19−
20−exports.runPure = function (f) {
21− return f();
22−};
23−
24−exports.untilE = function (f) {
25− return function () {
26− while (!f());
27− return {};
28− };
29−};
30−
31−exports.whileE = function (f) {
32− return function (a) {
33− return function () {
34− while (f()) {
35− a();
36− }
37− return {};
38− };
39− };
40−};
41−
42−exports.forE = function (lo) {
43− return function (hi) {
44− return function (f) {
45− return function () {
46− for (var i = lo; i < hi; i++) {
47− f(i)();
48− }
49− };
50− };
51− };
52−};
53−
54−exports.foreachE = function (as) {
55− return function (f) {
56− return function () {
57− for (var i = 0, l = as.length; i < l; i++) {
58− f(as[i])();
59− }
60− };
61− };
62−};
tests/support/flattened/Control-Monad-Eff.pursdeleted−67
@@ -1,67 +0,0 @@
1−module Control.Monad.Eff
2− ( Eff()
3− , Pure()
4− , runPure
5− , untilE, whileE, forE, foreachE
6− ) where
7−
8−import Prelude
9−
10−-- | The `Eff` type constructor is used to represent _native_ effects.
11−-- |
12−-- | See [Handling Native Effects with the Eff Monad](https://github.com/purescript/purescript/wiki/Handling-Native-Effects-with-the-Eff-Monad) for more details.
13−-- |
14−-- | The first type parameter is a row of effects which represents the contexts in which a computation can be run, and the second type parameter is the return type.
15−foreign import data Eff :: # ! -> * -> *
16−
17−foreign import returnE :: forall e a. a -> Eff e a
18−
19−foreign import bindE :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
20−
21−-- | The `Pure` type synonym represents _pure_ computations, i.e. ones in which all effects have been handled.
22−-- |
23−-- | The `runPure` function can be used to run pure computations and obtain their result.
24−type Pure a = forall e. Eff e a
25−
26−-- | Run a pure computation and return its result.
27−-- |
28−-- | Note: since this function has a rank-2 type, it may cause problems to apply this function using the `$` operator. The recommended approach
29−-- | is to use parentheses instead.
30−foreign import runPure :: forall a. Pure a -> a
31−
32−instance functorEff :: Functor (Eff e) where
33− map = liftA1
34−
35−instance applyEff :: Apply (Eff e) where
36− apply = ap
37−
38−instance applicativeEff :: Applicative (Eff e) where
39− pure = returnE
40−
41−instance bindEff :: Bind (Eff e) where
42− bind = bindE
43−
44−instance monadEff :: Monad (Eff e)
45−
46−-- | Loop until a condition becomes `true`.
47−-- |
48−-- | `untilE b` is an effectful computation which repeatedly runs the effectful computation `b`,
49−-- | until its return value is `true`.
50−foreign import untilE :: forall e. Eff e Boolean -> Eff e Unit
51−
52−-- | Loop while a condition is `true`.
53−-- |
54−-- | `whileE b m` is effectful computation which runs the effectful computation `b`. If its result is
55−-- | `true`, it runs the effectful computation `m` and loops. If not, the computation ends.
56−foreign import whileE :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
57−
58−-- | Loop over a consecutive collection of numbers.
59−-- |
60−-- | `forE lo hi f` runs the computation returned by the function `f` for each of the inputs
61−-- | between `lo` (inclusive) and `hi` (exclusive).
62−foreign import forE :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit
63−
64−-- | Loop over an array of values.
65−-- |
66−-- | `foreach xs f` runs the computation returned by the function `f` for each of the inputs `xs`.
67−foreign import foreachE :: forall e a. Array a -> (a -> Eff e Unit) -> Eff e Unit
tests/support/flattened/Control-Monad-ST.jsdeleted−38
@@ -1,38 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Control.Monad.ST
5−
6−exports.newSTRef = function (val) {
7− return function () {
8− return { value: val };
9− };
10−};
11−
12−exports.readSTRef = function (ref) {
13− return function () {
14− return ref.value;
15− };
16−};
17−
18−exports.modifySTRef = function (ref) {
19− return function (f) {
20− return function () {
21− /* jshint boss: true */
22− return ref.value = f(ref.value);
23− };
24− };
25−};
26−
27−exports.writeSTRef = function (ref) {
28− return function (a) {
29− return function () {
30− /* jshint boss: true */
31− return ref.value = a;
32− };
33− };
34−};
35−
36−exports.runST = function (f) {
37− return f;
38−};
tests/support/flattened/Control-Monad-ST.pursdeleted−42
@@ -1,42 +0,0 @@
1−module Control.Monad.ST where
2−
3−import Prelude
4−
5−import Control.Monad.Eff (Eff(), runPure)
6−
7−-- | The `ST` effect represents _local mutation_, i.e. mutation which does not "escape" into the surrounding computation.
8−-- |
9−-- | An `ST` computation is parameterized by a phantom type which is used to restrict the set of reference cells it is allowed to access.
10−-- |
11−-- | The `runST` function can be used to handle the `ST` effect.
12−foreign import data ST :: * -> !
13−
14−-- | The type `STRef s a` represents a mutable reference holding a value of type `a`, which can be used with the `ST s` effect.
15−foreign import data STRef :: * -> * -> *
16−
17−-- | Create a new mutable reference.
18−foreign import newSTRef :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
19−
20−-- | Read the current value of a mutable reference.
21−foreign import readSTRef :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
22−
23−-- | Modify the value of a mutable reference by applying a function to the current value.
24−foreign import modifySTRef :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
25−
26−-- | Set the value of a mutable reference.
27−foreign import writeSTRef :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
28−
29−-- | Run an `ST` computation.
30−-- |
31−-- | Note: the type of `runST` uses a rank-2 type to constrain the phantom type `s`, such that the computation must not leak any mutable references
32−-- | to the surrounding computation.
33−-- |
34−-- | It may cause problems to apply this function using the `$` operator. The recommended approach is to use parentheses instead.
35−foreign import runST :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
36−
37−-- | A convenience function which combines `runST` with `runPure`, which can be used when the only required effect is `ST`.
38−-- |
39−-- | Note: since this function has a rank-2 type, it may cause problems to apply this function using the `$` operator. The recommended approach
40−-- | is to use parentheses instead.
41−pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
42−pureST st = runPure (runST st)
tests/support/flattened/Data-Function.jsdeleted−233
@@ -1,233 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Data.Function
5−
6−exports.mkFn0 = function (fn) {
7− return function () {
8− return fn({});
9− };
10−};
11−
12−exports.mkFn1 = function (fn) {
13− return function (a) {
14− return fn(a);
15− };
16−};
17−
18−exports.mkFn2 = function (fn) {
19− /* jshint maxparams: 2 */
20− return function (a, b) {
21− return fn(a)(b);
22− };
23−};
24−
25−exports.mkFn3 = function (fn) {
26− /* jshint maxparams: 3 */
27− return function (a, b, c) {
28− return fn(a)(b)(c);
29− };
30−};
31−
32−exports.mkFn4 = function (fn) {
33− /* jshint maxparams: 4 */
34− return function (a, b, c, d) {
35− return fn(a)(b)(c)(d);
36− };
37−};
38−
39−exports.mkFn5 = function (fn) {
40− /* jshint maxparams: 5 */
41− return function (a, b, c, d, e) {
42− return fn(a)(b)(c)(d)(e);
43− };
44−};
45−
46−exports.mkFn6 = function (fn) {
47− /* jshint maxparams: 6 */
48− return function (a, b, c, d, e, f) {
49− return fn(a)(b)(c)(d)(e)(f);
50− };
51−};
52−
53−exports.mkFn7 = function (fn) {
54− /* jshint maxparams: 7 */
55− return function (a, b, c, d, e, f, g) {
56− return fn(a)(b)(c)(d)(e)(f)(g);
57− };
58−};
59−
60−exports.mkFn8 = function (fn) {
61− /* jshint maxparams: 8 */
62− return function (a, b, c, d, e, f, g, h) {
63− return fn(a)(b)(c)(d)(e)(f)(g)(h);
64− };
65−};
66−
67−exports.mkFn9 = function (fn) {
68− /* jshint maxparams: 9 */
69− return function (a, b, c, d, e, f, g, h, i) {
70− return fn(a)(b)(c)(d)(e)(f)(g)(h)(i);
71− };
72−};
73−
74−exports.mkFn10 = function (fn) {
75− /* jshint maxparams: 10 */
76− return function (a, b, c, d, e, f, g, h, i, j) {
77− return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j);
78− };
79−};
80−
81−exports.runFn0 = function (fn) {
82− return fn();
83−};
84−
85−exports.runFn1 = function (fn) {
86− return function (a) {
87− return fn(a);
88− };
89−};
90−
91−exports.runFn2 = function (fn) {
92− return function (a) {
93− return function (b) {
94− return fn(a, b);
95− };
96− };
97−};
98−
99−exports.runFn3 = function (fn) {
100− return function (a) {
101− return function (b) {
102− return function (c) {
103− return fn(a, b, c);
104− };
105− };
106− };
107−};
108−
109−exports.runFn4 = function (fn) {
110− return function (a) {
111− return function (b) {
112− return function (c) {
113− return function (d) {
114− return fn(a, b, c, d);
115− };
116− };
117− };
118− };
119−};
120−
121−exports.runFn5 = function (fn) {
122− return function (a) {
123− return function (b) {
124− return function (c) {
125− return function (d) {
126− return function (e) {
127− return fn(a, b, c, d, e);
128− };
129− };
130− };
131− };
132− };
133−};
134−
135−exports.runFn6 = function (fn) {
136− return function (a) {
137− return function (b) {
138− return function (c) {
139− return function (d) {
140− return function (e) {
141− return function (f) {
142− return fn(a, b, c, d, e, f);
143− };
144− };
145− };
146− };
147− };
148− };
149−};
150−
151−exports.runFn7 = function (fn) {
152− return function (a) {
153− return function (b) {
154− return function (c) {
155− return function (d) {
156− return function (e) {
157− return function (f) {
158− return function (g) {
159− return fn(a, b, c, d, e, f, g);
160− };
161− };
162− };
163− };
164− };
165− };
166− };
167−};
168−
169−exports.runFn8 = function (fn) {
170− return function (a) {
171− return function (b) {
172− return function (c) {
173− return function (d) {
174− return function (e) {
175− return function (f) {
176− return function (g) {
177− return function (h) {
178− return fn(a, b, c, d, e, f, g, h);
179− };
180− };
181− };
182− };
183− };
184− };
185− };
186− };
187−};
188−
189−exports.runFn9 = function (fn) {
190− return function (a) {
191− return function (b) {
192− return function (c) {
193− return function (d) {
194− return function (e) {
195− return function (f) {
196− return function (g) {
197− return function (h) {
198− return function (i) {
199− return fn(a, b, c, d, e, f, g, h, i);
200− };
201− };
202− };
203− };
204− };
205− };
206− };
207− };
208− };
209−};
210−
211−exports.runFn10 = function (fn) {
212− return function (a) {
213− return function (b) {
214− return function (c) {
215− return function (d) {
216− return function (e) {
217− return function (f) {
218− return function (g) {
219− return function (h) {
220− return function (i) {
221− return function (j) {
222− return fn(a, b, c, d, e, f, g, h, i, j);
223− };
224− };
225− };
226− };
227− };
228− };
229− };
230− };
231− };
232− };
233−};
tests/support/flattened/Data-Function.pursdeleted−113
@@ -1,113 +0,0 @@
1−module Data.Function where
2−
3−import Prelude
4−
5−-- | The `on` function is used to change the domain of a binary operator.
6−-- |
7−-- | For example, we can create a function which compares two records based on the values of their `x` properties:
8−-- |
9−-- | ```purescript
10−-- | compareX :: forall r. { x :: Number | r } -> { x :: Number | r } -> Ordering
11−-- | compareX = compare `on` _.x
12−-- | ```
13−on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
14−on f g x y = g x `f` g y
15−
16−-- | A function of zero arguments
17−foreign import data Fn0 :: * -> *
18−
19−-- | A function of one argument
20−foreign import data Fn1 :: * -> * -> *
21−
22−-- | A function of two arguments
23−foreign import data Fn2 :: * -> * -> * -> *
24−
25−-- | A function of three arguments
26−foreign import data Fn3 :: * -> * -> * -> * -> *
27−
28−-- | A function of four arguments
29−foreign import data Fn4 :: * -> * -> * -> * -> * -> *
30−
31−-- | A function of five arguments
32−foreign import data Fn5 :: * -> * -> * -> * -> * -> * -> *
33−
34−-- | A function of six arguments
35−foreign import data Fn6 :: * -> * -> * -> * -> * -> * -> * -> *
36−
37−-- | A function of seven arguments
38−foreign import data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> *
39−
40−-- | A function of eight arguments
41−foreign import data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> *
42−
43−-- | A function of nine arguments
44−foreign import data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
45−
46−-- | A function of ten arguments
47−foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
48−
49−-- | Create a function of no arguments
50−foreign import mkFn0 :: forall a. (Unit -> a) -> Fn0 a
51−
52−-- | Create a function of one argument
53−foreign import mkFn1 :: forall a b. (a -> b) -> Fn1 a b
54−
55−-- | Create a function of two arguments from a curried function
56−foreign import mkFn2 :: forall a b c. (a -> b -> c) -> Fn2 a b c
57−
58−-- | Create a function of three arguments from a curried function
59−foreign import mkFn3 :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
60−
61−-- | Create a function of four arguments from a curried function
62−foreign import mkFn4 :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
63−
64−-- | Create a function of five arguments from a curried function
65−foreign import mkFn5 :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
66−
67−-- | Create a function of six arguments from a curried function
68−foreign import mkFn6 :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
69−
70−-- | Create a function of seven arguments from a curried function
71−foreign import mkFn7 :: forall a b c d e f g h. (a -> b -> c -> d -> e -> f -> g -> h) -> Fn7 a b c d e f g h
72−
73−-- | Create a function of eight arguments from a curried function
74−foreign import mkFn8 :: forall a b c d e f g h i. (a -> b -> c -> d -> e -> f -> g -> h -> i) -> Fn8 a b c d e f g h i
75−
76−-- | Create a function of nine arguments from a curried function
77−foreign import mkFn9 :: forall a b c d e f g h i j. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> Fn9 a b c d e f g h i j
78−
79−-- | Create a function of ten arguments from a curried function
80−foreign import mkFn10 :: forall a b c d e f g h i j k. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> Fn10 a b c d e f g h i j k
81−
82−-- | Apply a function of no arguments
83−foreign import runFn0 :: forall a. Fn0 a -> a
84−
85−-- | Apply a function of one argument
86−foreign import runFn1 :: forall a b. Fn1 a b -> a -> b
87−
88−-- | Apply a function of two arguments
89−foreign import runFn2 :: forall a b c. Fn2 a b c -> a -> b -> c
90−
91−-- | Apply a function of three arguments
92−foreign import runFn3 :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
93−
94−-- | Apply a function of four arguments
95−foreign import runFn4 :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
96−
97−-- | Apply a function of five arguments
98−foreign import runFn5 :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
99−
100−-- | Apply a function of six arguments
101−foreign import runFn6 :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
102−
103−-- | Apply a function of seven arguments
104−foreign import runFn7 :: forall a b c d e f g h. Fn7 a b c d e f g h -> a -> b -> c -> d -> e -> f -> g -> h
105−
106−-- | Apply a function of eight arguments
107−foreign import runFn8 :: forall a b c d e f g h i. Fn8 a b c d e f g h i -> a -> b -> c -> d -> e -> f -> g -> h -> i
108−
109−-- | Apply a function of nine arguments
110−foreign import runFn9 :: forall a b c d e f g h i j. Fn9 a b c d e f g h i j -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
111−
112−-- | Apply a function of ten arguments
113−foreign import runFn10 :: forall a b c d e f g h i j k. Fn10 a b c d e f g h i j k -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
tests/support/flattened/Prelude.jsdeleted−228
@@ -1,228 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Prelude
5−
6−//- Functor --------------------------------------------------------------------
7−
8−exports.arrayMap = function (f) {
9− return function (arr) {
10− var l = arr.length;
11− var result = new Array(l);
12− for (var i = 0; i < l; i++) {
13− result[i] = f(arr[i]);
14− }
15− return result;
16− };
17−};
18−
19−//- Bind -----------------------------------------------------------------------
20−
21−exports.arrayBind = function (arr) {
22− return function (f) {
23− var result = [];
24− for (var i = 0, l = arr.length; i < l; i++) {
25− Array.prototype.push.apply(result, f(arr[i]));
26− }
27− return result;
28− };
29−};
30−
31−//- Monoid ---------------------------------------------------------------------
32−
33−exports.concatString = function (s1) {
34− return function (s2) {
35− return s1 + s2;
36− };
37−};
38−
39−exports.concatArray = function (xs) {
40− return function (ys) {
41− return xs.concat(ys);
42− };
43−};
44−
45−//- Semiring -------------------------------------------------------------------
46−
47−exports.intAdd = function (x) {
48− return function (y) {
49− /* jshint bitwise: false */
50− return x + y | 0;
51− };
52−};
53−
54−exports.intMul = function (x) {
55− return function (y) {
56− /* jshint bitwise: false */
57− return x * y | 0;
58− };
59−};
60−
61−exports.numAdd = function (n1) {
62− return function (n2) {
63− return n1 + n2;
64− };
65−};
66−
67−exports.numMul = function (n1) {
68− return function (n2) {
69− return n1 * n2;
70− };
71−};
72−
73−//- ModuloSemiring -------------------------------------------------------------
74−
75−exports.intDiv = function (x) {
76− return function (y) {
77− /* jshint bitwise: false */
78− return x / y | 0;
79− };
80−};
81−
82−exports.intMod = function (x) {
83− return function (y) {
84− return x % y;
85− };
86−};
87−
88−exports.numDiv = function (n1) {
89− return function (n2) {
90− return n1 / n2;
91− };
92−};
93−
94−//- Ring -----------------------------------------------------------------------
95−
96−exports.intSub = function (x) {
97− return function (y) {
98− /* jshint bitwise: false */
99− return x - y | 0;
100− };
101−};
102−
103−exports.numSub = function (n1) {
104− return function (n2) {
105− return n1 - n2;
106− };
107−};
108−
109−//- Eq -------------------------------------------------------------------------
110−
111−exports.refEq = function (r1) {
112− return function (r2) {
113− return r1 === r2;
114− };
115−};
116−
117−exports.refIneq = function (r1) {
118− return function (r2) {
119− return r1 !== r2;
120− };
121−};
122−
123−exports.eqArrayImpl = function (f) {
124− return function (xs) {
125− return function (ys) {
126− if (xs.length !== ys.length) return false;
127− for (var i = 0; i < xs.length; i++) {
128− if (!f(xs[i])(ys[i])) return false;
129− }
130− return true;
131− };
132− };
133−};
134−
135−exports.ordArrayImpl = function (f) {
136− return function (xs) {
137− return function (ys) {
138− var i = 0;
139− var xlen = xs.length;
140− var ylen = ys.length;
141− while (i < xlen && i < ylen) {
142− var x = xs[i];
143− var y = ys[i];
144− var o = f(x)(y);
145− if (o !== 0) {
146− return o;
147− }
148− i++;
149− }
150− if (xlen === ylen) {
151− return 0;
152− } else if (xlen > ylen) {
153− return -1;
154− } else {
155− return 1;
156− }
157− };
158− };
159−};
160−
161−//- Ord ------------------------------------------------------------------------
162−
163−exports.unsafeCompareImpl = function (lt) {
164− return function (eq) {
165− return function (gt) {
166− return function (x) {
167− return function (y) {
168− return x < y ? lt : x > y ? gt : eq;
169− };
170− };
171− };
172− };
173−};
174−
175−//- Bounded --------------------------------------------------------------------
176−
177−exports.topInt = 2147483647;
178−exports.bottomInt = -2147483648;
179−
180−exports.topChar = String.fromCharCode(65535);
181−exports.bottomChar = String.fromCharCode(0);
182−
183−//- BooleanAlgebra -------------------------------------------------------------
184−
185−exports.boolOr = function (b1) {
186− return function (b2) {
187− return b1 || b2;
188− };
189−};
190−
191−exports.boolAnd = function (b1) {
192− return function (b2) {
193− return b1 && b2;
194− };
195−};
196−
197−exports.boolNot = function (b) {
198− return !b;
199−};
200−
201−//- Show -----------------------------------------------------------------------
202−
203−exports.showIntImpl = function (n) {
204− return n.toString();
205−};
206−
207−exports.showNumberImpl = function (n) {
208− /* jshint bitwise: false */
209− return n === (n | 0) ? n + ".0" : n.toString();
210−};
211−
212−exports.showCharImpl = function (c) {
213− return c === "'" ? "'\\''" : "'" + c + "'";
214−};
215−
216−exports.showStringImpl = function (s) {
217− return JSON.stringify(s);
218−};
219−
220−exports.showArrayImpl = function (f) {
221− return function (xs) {
222− var ss = [];
223− for (var i = 0, l = xs.length; i < l; i++) {
224− ss[i] = f(xs[i]);
225− }
226− return "[" + ss.join(",") + "]";
227− };
228−};
tests/support/flattened/Prelude.pursdeleted−872
@@ -1,872 +0,0 @@
1−module Prelude
2− ( Unit(), unit
3− , ($), (#)
4− , flip
5− , const
6− , asTypeOf
7− , otherwise
8− , Semigroupoid, compose, (<<<), (>>>)
9− , Category, id
10− , Functor, map, (<$>), (<#>), void
11− , Apply, apply, (<*>)
12− , Applicative, pure, liftA1
13− , Bind, bind, (>>=)
14− , Monad, return, liftM1, ap
15− , Semigroup, append, (<>), (++)
16− , Semiring, add, zero, mul, one, (+), (*)
17− , ModuloSemiring, div, mod, (/)
18− , Ring, sub, negate, (-)
19− , Num
20− , DivisionRing
21− , Eq, eq, (==), (/=)
22− , Ordering(..), Ord, compare, (<), (>), (<=), (>=)
23− , unsafeCompare
24− , Bounded, top, bottom
25− , BoundedOrd
26− , BooleanAlgebra, conj, disj, not, (&&), (||)
27− , Show, show
28− ) where
29−
30−-- | The `Unit` type has a single inhabitant, called `unit`. It represents
31−-- | values with no computational content.
32−-- |
33−-- | `Unit` is often used, wrapped in a monadic type constructor, as the
34−-- | return type of a computation where only
35−-- | the _effects_ are important.
36−newtype Unit = Unit {}
37−
38−-- | `unit` is the sole inhabitant of the `Unit` type.
39−unit :: Unit
40−unit = Unit {}
41−
42−infixr 0 $
43−infixl 1 #
44−
45−-- | Applies a function to its argument.
46−-- |
47−-- | ```purescript
48−-- | length $ groupBy productCategory $ filter isInStock $ products
49−-- | ```
50−-- |
51−-- | is equivalent to:
52−-- |
53−-- | ```purescript
54−-- | length (groupBy productCategory (filter isInStock products))
55−-- | ```
56−-- |
57−-- | `($)` is different from [`(#)`](#-2) because it is right-infix instead of
58−-- | left: `a $ b $ c $ d x = a $ (b $ (c $ (d $ x))) = a (b (c (d x)))`
59−($) :: forall a b. (a -> b) -> a -> b
60−($) f x = f x
61−
62−-- | Applies an argument to a function.
63−-- |
64−-- | ```purescript
65−-- | products # filter isInStock # groupBy productCategory # length
66−-- | ```
67−-- |
68−-- | is equivalent to:
69−-- |
70−-- | ```purescript
71−-- | length (groupBy productCategory (filter isInStock products))
72−-- | ```
73−-- |
74−-- | `(#)` is different from [`($)`](#-1) because it is left-infix instead of
75−-- | right: `x # a # b # c # d = (((x # a) # b) # c) # d = d (c (b (a x)))`
76−(#) :: forall a b. a -> (a -> b) -> b
77−(#) x f = f x
78−
79−-- | Flips the order of the arguments to a function of two arguments.
80−-- |
81−-- | ```purescript
82−-- | flip const 1 2 = const 2 1 = 2
83−-- | ```
84−flip :: forall a b c. (a -> b -> c) -> b -> a -> c
85−flip f b a = f a b
86−
87−-- | Returns its first argument and ignores its second.
88−-- |
89−-- | ```purescript
90−-- | const 1 "hello" = 1
91−-- | ```
92−const :: forall a b. a -> b -> a
93−const a _ = a
94−
95−-- | This function returns its first argument, and can be used to assert type
96−-- | equalities. This can be useful when types are otherwise ambiguous.
97−-- |
98−-- | ```purescript
99−-- | main = print $ [] `asTypeOf` [0]
100−-- | ```
101−-- |
102−-- | If instead, we had written `main = print []`, the type of the argument
103−-- | `[]` would have been ambiguous, resulting in a compile-time error.
104−asTypeOf :: forall a. a -> a -> a
105−asTypeOf x _ = x
106−
107−-- | An alias for `true`, which can be useful in guard clauses:
108−-- |
109−-- | ```purescript
110−-- | max x y | x >= y = x
111−-- | | otherwise = y
112−-- | ```
113−otherwise :: Boolean
114−otherwise = true
115−
116−-- | A `Semigroupoid` is similar to a [`Category`](#category) but does not
117−-- | require an identity element `id`, just composable morphisms.
118−-- |
119−-- | `Semigroupoid`s must satisfy the following law:
120−-- |
121−-- | - Associativity: `p <<< (q <<< r) = (p <<< q) <<< r`
122−-- |
123−-- | One example of a `Semigroupoid` is the function type constructor `(->)`,
124−-- | with `(<<<)` defined as function composition.
125−class Semigroupoid a where
126− compose :: forall b c d. a c d -> a b c -> a b d
127−
128−instance semigroupoidFn :: Semigroupoid (->) where
129− compose f g x = f (g x)
130−
131−infixr 9 >>>
132−infixr 9 <<<
133−
134−-- | `(<<<)` is an alias for `compose`.
135−(<<<) :: forall a b c d. (Semigroupoid a) => a c d -> a b c -> a b d
136−(<<<) = compose
137−
138−-- | Forwards composition, or `(<<<)` with its arguments reversed.
139−(>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
140−(>>>) = flip compose
141−
142−-- | `Category`s consist of objects and composable morphisms between them, and
143−-- | as such are [`Semigroupoids`](#semigroupoid), but unlike `semigroupoids`
144−-- | must have an identity element.
145−-- |
146−-- | Instances must satisfy the following law in addition to the
147−-- | `Semigroupoid` law:
148−-- |
149−-- | - Identity: `id <<< p = p <<< id = p`
150−class (Semigroupoid a) <= Category a where
151− id :: forall t. a t t
152−
153−instance categoryFn :: Category (->) where
154− id x = x
155−
156−-- | A `Functor` is a type constructor which supports a mapping operation
157−-- | `(<$>)`.
158−-- |
159−-- | `(<$>)` can be used to turn functions `a -> b` into functions
160−-- | `f a -> f b` whose argument and return types use the type constructor `f`
161−-- | to represent some computational context.
162−-- |
163−-- | Instances must satisfy the following laws:
164−-- |
165−-- | - Identity: `(<$>) id = id`
166−-- | - Composition: `(<$>) (f <<< g) = (f <$>) <<< (g <$>)`
167−class Functor f where
168− map :: forall a b. (a -> b) -> f a -> f b
169−
170−instance functorFn :: Functor ((->) r) where
171− map = compose
172−
173−instance functorArray :: Functor Array where
174− map = arrayMap
175−
176−foreign import arrayMap :: forall a b. (a -> b) -> Array a -> Array b
177−
178−infixl 4 <$>
179−infixl 1 <#>
180−
181−-- | `(<$>)` is an alias for `map`
182−(<$>) :: forall f a b. (Functor f) => (a -> b) -> f a -> f b
183−(<$>) = map
184−
185−-- | `(<#>)` is `(<$>)` with its arguments reversed. For example:
186−-- |
187−-- | ```purescript
188−-- | [1, 2, 3] <#> \n -> n * n
189−-- | ```
190−(<#>) :: forall f a b. (Functor f) => f a -> (a -> b) -> f b
191−(<#>) fa f = f <$> fa
192−
193−-- | The `void` function is used to ignore the type wrapped by a
194−-- | [`Functor`](#functor), replacing it with `Unit` and keeping only the type
195−-- | information provided by the type constructor itself.
196−-- |
197−-- | `void` is often useful when using `do` notation to change the return type
198−-- | of a monadic computation:
199−-- |
200−-- | ```purescript
201−-- | main = forE 1 10 \n -> void do
202−-- | print n
203−-- | print (n * n)
204−-- | ```
205−void :: forall f a. (Functor f) => f a -> f Unit
206−void fa = const unit <$> fa
207−
208−-- | The `Apply` class provides the `(<*>)` which is used to apply a function
209−-- | to an argument under a type constructor.
210−-- |
211−-- | `Apply` can be used to lift functions of two or more arguments to work on
212−-- | values wrapped with the type constructor `f`. It might also be understood
213−-- | in terms of the `lift2` function:
214−-- |
215−-- | ```purescript
216−-- | lift2 :: forall f a b c. (Apply f) => (a -> b -> c) -> f a -> f b -> f c
217−-- | lift2 f a b = f <$> a <*> b
218−-- | ```
219−-- |
220−-- | `(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts
221−-- | the function application operator `($)` to arguments wrapped with the
222−-- | type constructor `f`.
223−-- |
224−-- | Instances must satisfy the following law in addition to the `Functor`
225−-- | laws:
226−-- |
227−-- | - Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`
228−-- |
229−-- | Formally, `Apply` represents a strong lax semi-monoidal endofunctor.
230−class (Functor f) <= Apply f where
231− apply :: forall a b. f (a -> b) -> f a -> f b
232−
233−instance applyFn :: Apply ((->) r) where
234− apply f g x = f x (g x)
235−
236−instance applyArray :: Apply Array where
237− apply = ap
238−
239−infixl 4 <*>
240−
241−-- | `(<*>)` is an alias for `apply`.
242−(<*>) :: forall f a b. (Apply f) => f (a -> b) -> f a -> f b
243−(<*>) = apply
244−
245−-- | The `Applicative` type class extends the [`Apply`](#apply) type class
246−-- | with a `pure` function, which can be used to create values of type `f a`
247−-- | from values of type `a`.
248−-- |
249−-- | Where [`Apply`](#apply) provides the ability to lift functions of two or
250−-- | more arguments to functions whose arguments are wrapped using `f`, and
251−-- | [`Functor`](#functor) provides the ability to lift functions of one
252−-- | argument, `pure` can be seen as the function which lifts functions of
253−-- | _zero_ arguments. That is, `Applicative` functors support a lifting
254−-- | operation for any number of function arguments.
255−-- |
256−-- | Instances must satisfy the following laws in addition to the `Apply`
257−-- | laws:
258−-- |
259−-- | - Identity: `(pure id) <*> v = v`
260−-- | - Composition: `(pure <<<) <*> f <*> g <*> h = f <*> (g <*> h)`
261−-- | - Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
262−-- | - Interchange: `u <*> (pure y) = (pure ($ y)) <*> u`
263−class (Apply f) <= Applicative f where
264− pure :: forall a. a -> f a
265−
266−instance applicativeFn :: Applicative ((->) r) where
267− pure = const
268−
269−instance applicativeArray :: Applicative Array where
270− pure x = [x]
271−
272−-- | `return` is an alias for `pure`.
273−return :: forall m a. (Applicative m) => a -> m a
274−return = pure
275−
276−-- | `liftA1` provides a default implementation of `(<$>)` for any
277−-- | [`Applicative`](#applicative) functor, without using `(<$>)` as provided
278−-- | by the [`Functor`](#functor)-[`Applicative`](#applicative) superclass
279−-- | relationship.
280−-- |
281−-- | `liftA1` can therefore be used to write [`Functor`](#functor) instances
282−-- | as follows:
283−-- |
284−-- | ```purescript
285−-- | instance functorF :: Functor F where
286−-- | map = liftA1
287−-- | ```
288−liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b
289−liftA1 f a = pure f <*> a
290−
291−-- | The `Bind` type class extends the [`Apply`](#apply) type class with a
292−-- | "bind" operation `(>>=)` which composes computations in sequence, using
293−-- | the return value of one computation to determine the next computation.
294−-- |
295−-- | The `>>=` operator can also be expressed using `do` notation, as follows:
296−-- |
297−-- | ```purescript
298−-- | x >>= f = do y <- x
299−-- | f y
300−-- | ```
301−-- |
302−-- | where the function argument of `f` is given the name `y`.
303−-- |
304−-- | Instances must satisfy the following law in addition to the `Apply`
305−-- | laws:
306−-- |
307−-- | - Associativity: `(x >>= f) >>= g = x >>= (\k => f k >>= g)`
308−-- |
309−-- | Associativity tells us that we can regroup operations which use `do`
310−-- | notation so that we can unambiguously write, for example:
311−-- |
312−-- | ```purescript
313−-- | do x <- m1
314−-- | y <- m2 x
315−-- | m3 x y
316−-- | ```
317−class (Apply m) <= Bind m where
318− bind :: forall a b. m a -> (a -> m b) -> m b
319−
320−instance bindFn :: Bind ((->) r) where
321− bind m f x = f (m x) x
322−
323−instance bindArray :: Bind Array where
324− bind = arrayBind
325−
326−foreign import arrayBind :: forall a b. Array a -> (a -> Array b) -> Array b
327−
328−infixl 1 >>=
329−
330−-- | `(>>=)` is an alias for `bind`.
331−(>>=) :: forall m a b. (Bind m) => m a -> (a -> m b) -> m b
332−(>>=) = bind
333−
334−-- | The `Monad` type class combines the operations of the `Bind` and
335−-- | `Applicative` type classes. Therefore, `Monad` instances represent type
336−-- | constructors which support sequential composition, and also lifting of
337−-- | functions of arbitrary arity.
338−-- |
339−-- | Instances must satisfy the following laws in addition to the
340−-- | `Applicative` and `Bind` laws:
341−-- |
342−-- | - Left Identity: `pure x >>= f = f x`
343−-- | - Right Identity: `x >>= pure = x`
344−class (Applicative m, Bind m) <= Monad m
345−
346−instance monadFn :: Monad ((->) r)
347−instance monadArray :: Monad Array
348−
349−-- | `liftM1` provides a default implementation of `(<$>)` for any
350−-- | [`Monad`](#monad), without using `(<$>)` as provided by the
351−-- | [`Functor`](#functor)-[`Monad`](#monad) superclass relationship.
352−-- |
353−-- | `liftM1` can therefore be used to write [`Functor`](#functor) instances
354−-- | as follows:
355−-- |
356−-- | ```purescript
357−-- | instance functorF :: Functor F where
358−-- | map = liftM1
359−-- | ```
360−liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
361−liftM1 f a = do
362− a' <- a
363− return (f a')
364−
365−-- | `ap` provides a default implementation of `(<*>)` for any
366−-- | [`Monad`](#monad), without using `(<*>)` as provided by the
367−-- | [`Apply`](#apply)-[`Monad`](#monad) superclass relationship.
368−-- |
369−-- | `ap` can therefore be used to write [`Apply`](#apply) instances as
370−-- | follows:
371−-- |
372−-- | ```purescript
373−-- | instance applyF :: Apply F where
374−-- | apply = ap
375−-- | ```
376−ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b
377−ap f a = do
378− f' <- f
379− a' <- a
380− return (f' a')
381−
382−-- | The `Semigroup` type class identifies an associative operation on a type.
383−-- |
384−-- | Instances are required to satisfy the following law:
385−-- |
386−-- | - Associativity: `(x <> y) <> z = x <> (y <> z)`
387−-- |
388−-- | One example of a `Semigroup` is `String`, with `(<>)` defined as string
389−-- | concatenation.
390−class Semigroup a where
391− append :: a -> a -> a
392−
393−infixr 5 <>
394−infixr 5 ++
395−
396−-- | `(<>)` is an alias for `append`.
397−(<>) :: forall s. (Semigroup s) => s -> s -> s
398−(<>) = append
399−
400−-- | `(++)` is an alternative alias for `append`.
401−(++) :: forall s. (Semigroup s) => s -> s -> s
402−(++) = append
403−
404−instance semigroupString :: Semigroup String where
405− append = concatString
406−
407−instance semigroupUnit :: Semigroup Unit where
408− append _ _ = unit
409−
410−instance semigroupFn :: (Semigroup s') => Semigroup (s -> s') where
411− append f g = \x -> f x <> g x
412−
413−instance semigroupOrdering :: Semigroup Ordering where
414− append LT _ = LT
415− append GT _ = GT
416− append EQ y = y
417−
418−instance semigroupArray :: Semigroup (Array a) where
419− append = concatArray
420−
421−foreign import concatString :: String -> String -> String
422−foreign import concatArray :: forall a. Array a -> Array a -> Array a
423−
424−-- | The `Semiring` class is for types that support an addition and
425−-- | multiplication operation.
426−-- |
427−-- | Instances must satisfy the following laws:
428−-- |
429−-- | - Commutative monoid under addition:
430−-- | - Associativity: `(a + b) + c = a + (b + c)`
431−-- | - Identity: `zero + a = a + zero = a`
432−-- | - Commutative: `a + b = b + a`
433−-- | - Monoid under multiplication:
434−-- | - Associativity: `(a * b) * c = a * (b * c)`
435−-- | - Identity: `one * a = a * one = a`
436−-- | - Multiplication distributes over addition:
437−-- | - Left distributivity: `a * (b + c) = (a * b) + (a * c)`
438−-- | - Right distributivity: `(a + b) * c = (a * c) + (b * c)`
439−-- | - Annihiliation: `zero * a = a * zero = zero`
440−class Semiring a where
441− add :: a -> a -> a
442− zero :: a
443− mul :: a -> a -> a
444− one :: a
445−
446−instance semiringInt :: Semiring Int where
447− add = intAdd
448− zero = 0
449− mul = intMul
450− one = 1
451−
452−instance semiringNumber :: Semiring Number where
453− add = numAdd
454− zero = 0.0
455− mul = numMul
456− one = 1.0
457−
458−instance semiringUnit :: Semiring Unit where
459− add _ _ = unit
460− zero = unit
461− mul _ _ = unit
462− one = unit
463−
464−infixl 6 +
465−infixl 7 *
466−
467−-- | `(+)` is an alias for `add`.
468−(+) :: forall a. (Semiring a) => a -> a -> a
469−(+) = add
470−
471−-- | `(*)` is an alias for `mul`.
472−(*) :: forall a. (Semiring a) => a -> a -> a
473−(*) = mul
474−
475−foreign import intAdd :: Int -> Int -> Int
476−foreign import intMul :: Int -> Int -> Int
477−foreign import numAdd :: Number -> Number -> Number
478−foreign import numMul :: Number -> Number -> Number
479−
480−-- | The `Ring` class is for types that support addition, multiplication,
481−-- | and subtraction operations.
482−-- |
483−-- | Instances must satisfy the following law in addition to the `Semiring`
484−-- | laws:
485−-- |
486−-- | - Additive inverse: `a - a = (zero - a) + a = zero`
487−class (Semiring a) <= Ring a where
488− sub :: a -> a -> a
489−
490−instance ringInt :: Ring Int where
491− sub = intSub
492−
493−instance ringNumber :: Ring Number where
494− sub = numSub
495−
496−instance ringUnit :: Ring Unit where
497− sub _ _ = unit
498−
499−infixl 6 -
500−
501−-- | `(-)` is an alias for `sub`.
502−(-) :: forall a. (Ring a) => a -> a -> a
503−(-) = sub
504−
505−-- | `negate x` can be used as a shorthand for `zero - x`.
506−negate :: forall a. (Ring a) => a -> a
507−negate a = zero - a
508−
509−foreign import intSub :: Int -> Int -> Int
510−foreign import numSub :: Number -> Number -> Number
511−
512−-- | The `ModuloSemiring` class is for types that support addition,
513−-- | multiplication, division, and modulo (division remainder) operations.
514−-- |
515−-- | Instances must satisfy the following law in addition to the `Semiring`
516−-- | laws:
517−-- |
518−-- | - Remainder: ``a / b * b + (a `mod` b) = a``
519−class (Semiring a) <= ModuloSemiring a where
520− div :: a -> a -> a
521− mod :: a -> a -> a
522−
523−instance moduloSemiringInt :: ModuloSemiring Int where
524− div = intDiv
525− mod = intMod
526−
527−instance moduloSemiringNumber :: ModuloSemiring Number where
528− div = numDiv
529− mod _ _ = 0.0
530−
531−instance moduloSemiringUnit :: ModuloSemiring Unit where
532− div _ _ = unit
533− mod _ _ = unit
534−
535−infixl 7 /
536−
537−-- | `(/)` is an alias for `div`.
538−(/) :: forall a. (ModuloSemiring a) => a -> a -> a
539−(/) = div
540−
541−foreign import intDiv :: Int -> Int -> Int
542−foreign import numDiv :: Number -> Number -> Number
543−foreign import intMod :: Int -> Int -> Int
544−
545−-- | A `Ring` where every nonzero element has a multiplicative inverse.
546−-- |
547−-- | Instances must satisfy the following law in addition to the `Ring` and
548−-- | `ModuloSemiring` laws:
549−-- |
550−-- | - Multiplicative inverse: `(one / x) * x = one`
551−-- |
552−-- | As a consequence of this ```a `mod` b = zero``` as no divide operation
553−-- | will have a remainder.
554−class (Ring a, ModuloSemiring a) <= DivisionRing a
555−
556−instance divisionRingNumber :: DivisionRing Number
557−instance divisionRingUnit :: DivisionRing Unit
558−
559−-- | The `Num` class is for types that are commutative fields.
560−-- |
561−-- | Instances must satisfy the following law in addition to the
562−-- | `DivisionRing` laws:
563−-- |
564−-- | - Commutative multiplication: `a * b = b * a`
565−class (DivisionRing a) <= Num a
566−
567−instance numNumber :: Num Number
568−instance numUnit :: Num Unit
569−
570−-- | The `Eq` type class represents types which support decidable equality.
571−-- |
572−-- | `Eq` instances should satisfy the following laws:
573−-- |
574−-- | - Reflexivity: `x == x = true`
575−-- | - Symmetry: `x == y = y == x`
576−-- | - Transitivity: if `x == y` and `y == z` then `x == z`
577−class Eq a where
578− eq :: a -> a -> Boolean
579−
580−infix 4 ==
581−infix 4 /=
582−
583−-- | `(==)` is an alias for `eq`. Tests whether one value is equal to another.
584−(==) :: forall a. (Eq a) => a -> a -> Boolean
585−(==) = eq
586−
587−-- | `(/=)` tests whether one value is _not equal_ to another. Shorthand for
588−-- | `not (x == y)`.
589−(/=) :: forall a. (Eq a) => a -> a -> Boolean
590−(/=) x y = not (x == y)
591−
592−instance eqBoolean :: Eq Boolean where
593− eq = refEq
594−
595−instance eqInt :: Eq Int where
596− eq = refEq
597−
598−instance eqNumber :: Eq Number where
599− eq = refEq
600−
601−instance eqChar :: Eq Char where
602− eq = refEq
603−
604−instance eqString :: Eq String where
605− eq = refEq
606−
607−instance eqUnit :: Eq Unit where
608− eq _ _ = true
609−
610−instance eqArray :: (Eq a) => Eq (Array a) where
611− eq = eqArrayImpl (==)
612−
613−instance eqOrdering :: Eq Ordering where
614− eq LT LT = true
615− eq GT GT = true
616− eq EQ EQ = true
617− eq _ _ = false
618−
619−foreign import refEq :: forall a. a -> a -> Boolean
620−foreign import refIneq :: forall a. a -> a -> Boolean
621−foreign import eqArrayImpl :: forall a. (a -> a -> Boolean) -> Array a -> Array a -> Boolean
622−
623−-- | The `Ordering` data type represents the three possible outcomes of
624−-- | comparing two values:
625−-- |
626−-- | `LT` - The first value is _less than_ the second.
627−-- | `GT` - The first value is _greater than_ the second.
628−-- | `EQ` - The first value is _equal to_ the second.
629−data Ordering = LT | GT | EQ
630−
631−-- | The `Ord` type class represents types which support comparisons with a
632−-- | _total order_.
633−-- |
634−-- | `Ord` instances should satisfy the laws of total orderings:
635−-- |
636−-- | - Reflexivity: `a <= a`
637−-- | - Antisymmetry: if `a <= b` and `b <= a` then `a = b`
638−-- | - Transitivity: if `a <= b` and `b <= c` then `a <= c`
639−class (Eq a) <= Ord a where
640− compare :: a -> a -> Ordering
641−
642−instance ordBoolean :: Ord Boolean where
643− compare = unsafeCompare
644−
645−instance ordInt :: Ord Int where
646− compare = unsafeCompare
647−
648−instance ordNumber :: Ord Number where
649− compare = unsafeCompare
650−
651−instance ordString :: Ord String where
652− compare = unsafeCompare
653−
654−instance ordChar :: Ord Char where
655− compare = unsafeCompare
656−
657−instance ordUnit :: Ord Unit where
658− compare _ _ = EQ
659−
660−instance ordArray :: (Ord a) => Ord (Array a) where
661− compare xs ys = compare 0 $ ordArrayImpl (\x y -> case compare x y of
662− EQ -> 0
663− LT -> 1
664− GT -> -1) xs ys
665−
666−foreign import ordArrayImpl :: forall a. (a -> a -> Int) -> Array a -> Array a -> Int
667−
668−instance ordOrdering :: Ord Ordering where
669− compare LT LT = EQ
670− compare EQ EQ = EQ
671− compare GT GT = EQ
672− compare LT _ = LT
673− compare EQ LT = GT
674− compare EQ GT = LT
675− compare GT _ = GT
676−
677−infixl 4 <
678−infixl 4 >
679−infixl 4 <=
680−infixl 4 >=
681−
682−-- | Test whether one value is _strictly less than_ another.
683−(<) :: forall a. (Ord a) => a -> a -> Boolean
684−(<) a1 a2 = case a1 `compare` a2 of
685− LT -> true
686− _ -> false
687−
688−-- | Test whether one value is _strictly greater than_ another.
689−(>) :: forall a. (Ord a) => a -> a -> Boolean
690−(>) a1 a2 = case a1 `compare` a2 of
691− GT -> true
692− _ -> false
693−
694−-- | Test whether one value is _non-strictly less than_ another.
695−(<=) :: forall a. (Ord a) => a -> a -> Boolean
696−(<=) a1 a2 = case a1 `compare` a2 of
697− GT -> false
698− _ -> true
699−
700−-- | Test whether one value is _non-strictly greater than_ another.
701−(>=) :: forall a. (Ord a) => a -> a -> Boolean
702−(>=) a1 a2 = case a1 `compare` a2 of
703− LT -> false
704− _ -> true
705−
706−unsafeCompare :: forall a. a -> a -> Ordering
707−unsafeCompare = unsafeCompareImpl LT EQ GT
708−
709−foreign import unsafeCompareImpl :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
710−
711−-- | The `Bounded` type class represents types that are finite.
712−-- |
713−-- | Although there are no "internal" laws for `Bounded`, every value of `a`
714−-- | should be considered less than or equal to `top` by some means, and greater
715−-- | than or equal to `bottom`.
716−-- |
717−-- | The lack of explicit `Ord` constraint allows flexibility in the use of
718−-- | `Bounded` so it can apply to total and partially ordered sets, boolean
719−-- | algebras, etc.
720−class Bounded a where
721− top :: a
722− bottom :: a
723−
724−instance boundedBoolean :: Bounded Boolean where
725− top = true
726− bottom = false
727−
728−instance boundedUnit :: Bounded Unit where
729− top = unit
730− bottom = unit
731−
732−instance boundedOrdering :: Bounded Ordering where
733− top = GT
734− bottom = LT
735−
736−instance boundedInt :: Bounded Int where
737− top = topInt
738− bottom = bottomInt
739−
740−-- | Characters fall within the Unicode range.
741−instance boundedChar :: Bounded Char where
742− top = topChar
743− bottom = bottomChar
744−
745−instance boundedFn :: (Bounded b) => Bounded (a -> b) where
746− top _ = top
747− bottom _ = bottom
748−
749−foreign import topInt :: Int
750−foreign import bottomInt :: Int
751−
752−foreign import topChar :: Char
753−foreign import bottomChar :: Char
754−
755−-- | The `BoundedOrd` type class represents totally ordered finite data types.
756−-- |
757−-- | Instances should satisfy the following law in addition to the `Ord` laws:
758−-- |
759−-- | - Ordering: `bottom <= a <= top`
760−class (Bounded a, Ord a) <= BoundedOrd a
761−
762−instance boundedOrdBoolean :: BoundedOrd Boolean where
763−instance boundedOrdUnit :: BoundedOrd Unit where
764−instance boundedOrdOrdering :: BoundedOrd Ordering where
765−instance boundedOrdInt :: BoundedOrd Int where
766−instance boundedOrdChar :: BoundedOrd Char where
767−
768−-- | The `BooleanAlgebra` type class represents types that behave like boolean
769−-- | values.
770−-- |
771−-- | Instances should satisfy the following laws in addition to the `Bounded`
772−-- | laws:
773−-- |
774−-- | - Associativity:
775−-- | - `a || (b || c) = (a || b) || c`
776−-- | - `a && (b && c) = (a && b) && c`
777−-- | - Commutativity:
778−-- | - `a || b = b || a`
779−-- | - `a && b = b && a`
780−-- | - Distributivity:
781−-- | - `a && (b || c) = (a && b) || (a && c)`
782−-- | - `a || (b && c) = (a || b) && (a || c)`
783−-- | - Identity:
784−-- | - `a || bottom = a`
785−-- | - `a && top = a`
786−-- | - Idempotent:
787−-- | - `a || a = a`
788−-- | - `a && a = a`
789−-- | - Absorption:
790−-- | - `a || (a && b) = a`
791−-- | - `a && (a || b) = a`
792−-- | - Annhiliation:
793−-- | - `a || top = top`
794−-- | - Complementation:
795−-- | - `a && not a = bottom`
796−-- | - `a || not a = top`
797−class (Bounded a) <= BooleanAlgebra a where
798− conj :: a -> a -> a
799− disj :: a -> a -> a
800− not :: a -> a
801−
802−instance booleanAlgebraBoolean :: BooleanAlgebra Boolean where
803− conj = boolAnd
804− disj = boolOr
805− not = boolNot
806−
807−instance booleanAlgebraUnit :: BooleanAlgebra Unit where
808− conj _ _ = unit
809− disj _ _ = unit
810− not _ = unit
811−
812−instance booleanAlgebraFn :: (BooleanAlgebra b) => BooleanAlgebra (a -> b) where
813− conj fx fy a = fx a `conj` fy a
814− disj fx fy a = fx a `disj` fy a
815− not fx a = not (fx a)
816−
817−infixr 3 &&
818−infixr 2 ||
819−
820−-- | `(&&)` is an alias for `conj`.
821−(&&) :: forall a. (BooleanAlgebra a) => a -> a -> a
822−(&&) = conj
823−
824−-- | `(||)` is an alias for `disj`.
825−(||) :: forall a. (BooleanAlgebra a) => a -> a -> a
826−(||) = disj
827−
828−foreign import boolOr :: Boolean -> Boolean -> Boolean
829−foreign import boolAnd :: Boolean -> Boolean -> Boolean
830−foreign import boolNot :: Boolean -> Boolean
831−
832−-- | The `Show` type class represents those types which can be converted into
833−-- | a human-readable `String` representation.
834−-- |
835−-- | While not required, it is recommended that for any expression `x`, the
836−-- | string `show x` be executable PureScript code which evaluates to the same
837−-- | value as the expression `x`.
838−class Show a where
839− show :: a -> String
840−
841−instance showBoolean :: Show Boolean where
842− show true = "true"
843− show false = "false"
844−
845−instance showInt :: Show Int where
846− show = showIntImpl
847−
848−instance showNumber :: Show Number where
849− show = showNumberImpl
850−
851−instance showChar :: Show Char where
852− show = showCharImpl
853−
854−instance showString :: Show String where
855− show = showStringImpl
856−
857−instance showUnit :: Show Unit where
858− show _ = "unit"
859−
860−instance showArray :: (Show a) => Show (Array a) where
861− show = showArrayImpl show
862−
863−instance showOrdering :: Show Ordering where
864− show LT = "LT"
865− show GT = "GT"
866− show EQ = "EQ"
867−
868−foreign import showIntImpl :: Int -> String
869−foreign import showNumberImpl :: Number -> String
870−foreign import showCharImpl :: Char -> String
871−foreign import showStringImpl :: String -> String
872−foreign import showArrayImpl :: forall a. (a -> String) -> Array a -> String
tests/support/flattened/Test-Assert.jsdeleted−27
@@ -1,27 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Test.Assert
5−
6−exports["assert'"] = function (message) {
7− return function (success) {
8− return function () {
9− if (!success) throw new Error(message);
10− return {};
11− };
12− };
13−};
14−
15−exports.checkThrows = function (fn) {
16− return function () {
17− try {
18− fn();
19− return false;
20− } catch (e) {
21− if (e instanceof Error) return true;
22− var err = new Error("Threw something other than an Error");
23− err.something = e;
24− throw err;
25− }
26− };
27−};
tests/support/flattened/Test-Assert.pursdeleted−46
@@ -1,46 +0,0 @@
1−module Test.Assert
2− ( assert'
3− , assert
4− , assertThrows
5− , assertThrows'
6− , ASSERT()
7− ) where
8−
9−import Control.Monad.Eff (Eff())
10−import Prelude
11−
12−-- | Assertion effect type.
13−foreign import data ASSERT :: !
14−
15−-- | Throws a runtime exception with message "Assertion failed" when the boolean
16−-- | value is false.
17−assert :: forall e. Boolean -> Eff (assert :: ASSERT | e) Unit
18−assert = assert' "Assertion failed"
19−
20−-- | Throws a runtime exception with the specified message when the boolean
21−-- | value is false.
22−foreign import assert' :: forall e. String -> Boolean -> Eff (assert :: ASSERT | e) Unit
23−
24−-- | Throws a runtime exception with message "Assertion failed: An error should
25−-- | have been thrown", unless the argument throws an exception when evaluated.
26−-- |
27−-- | This function is specifically for testing unsafe pure code; for example,
28−-- | to make sure that an exception is thrown if a precondition is not
29−-- | satisfied. Functions which use `Eff (err :: EXCEPTION | eff) a` can be
30−-- | tested with `catchException` instead.
31−assertThrows :: forall e a. (Unit -> a) -> Eff (assert :: ASSERT | e) Unit
32−assertThrows = assertThrows' "Assertion failed: An error should have been thrown"
33−
34−-- | Throws a runtime exception with the specified message, unless the argument
35−-- | throws an exception when evaluated.
36−-- |
37−-- | This function is specifically for testing unsafe pure code; for example,
38−-- | to make sure that an exception is thrown if a precondition is not
39−-- | satisfied. Functions which use `Eff (err :: EXCEPTION | eff) a` can be
40−-- | tested with `catchException` instead.
41−assertThrows' :: forall e a. String -> (Unit -> a) -> Eff (assert :: ASSERT | e) Unit
42−assertThrows' msg fn =
43− checkThrows fn >>= assert' msg
44−
45−
46−foreign import checkThrows :: forall e a. (Unit -> a) -> Eff (assert :: ASSERT | e) Boolean
tests/support/package.json+2−1
@@ -2,6 +2,7 @@
22 "private": true,
33 "dependencies": {
44 "bower": "^1.4.1",
5− "glob": "^5.0.14"
5+ "glob": "^5.0.14",
6+ "rimraf": "^2.5.2"
67 }
78}
tests/support/preludedeleted−1

Submodule changed.

tests/support/setup.jsdeleted−22
@@ -1,22 +0,0 @@
1−var glob = require("glob");
2−var fs = require("fs");
3−
4−try {
5− fs.mkdirSync("./flattened");
6−} catch(e) {
7− // ignore the error if it already exists
8− if (e.code !== "EEXIST") {
9− throw(e);
10− }
11−}
12−
13−glob("bower_components/*/src/**/*.{js,purs}", function(err, files) {
14− if (err) throw err;
15− files.forEach(function(file) {
16− // We join with "-" because Cabal is weird about file extensions.
17− var dest = "./flattened/" + file.split("/").slice(3).join("-");
18− console.log("Copying " + file + " to " + dest);
19− var content = fs.readFileSync(file, "utf-8");
20− fs.writeFileSync(dest, content, "utf-8");
21− });
22−})