git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update test suite

* Use real versions of supporting libraries * Use bower to make it easy to update supporting libraries

commit412cfe03af734fe7d2d405fcc017ccabd30573d8 authorHarry Garrood <harry@garrood.me> dateWed 29 Jul 2015, 10:21 (11 years ago) parentd96b0ef
178 files changed+1863−1121
examples/failing/ArrayType.purs+1−1 examples/failing/Eff.purs+2−2 examples/failing/ExtraRecordField.purs+9 examples/failing/MissingRecordField.purs+10 examples/failing/OverlappingInstances.purs+1−1 examples/failing/OverlappingInstances2.purs+1−1 examples/failing/RowConstructors1.purs+1−1 examples/failing/RowConstructors2.purs+1−1 examples/failing/RowConstructors3.purs+1−1 examples/failing/UnderscoreModuleName.purs+1−1 examples/manual/QualifiedNames.purs+1−1 examples/manual/failing/ExportExplicit1.purs+1−1 examples/manual/failing/ExportExplicit3.purs+1−1 examples/manual/passing/ExportExplicit.purs+1−1 examples/manual/passing/ExportExplicit2.purs+1−1 examples/manual/passing/Import.purs+1−1 examples/manual/passing/ImportExplicit.purs+1−1 examples/manual/passing/ImportQualified.purs+3−3 examples/manual/passing/Module.purs+1−1 examples/manual/passing/ModuleDeps.purs+1−1 examples/manual/passing/RedefinedFixity.purs+1−1 examples/manual/passing/ShadowedName.purs+2−2 examples/manual/passing/TransitiveImport.purs+1−1 examples/manual/passing/WildcardType.purs+2−2 examples/passing/652.purs+1−1 examples/passing/810.purs+1−1 examples/passing/Applicative.purs+4−4 examples/passing/ArrayType.purs+1−1 examples/passing/Auto.purs+1−1 examples/passing/AutoPrelude.purs+2−2 examples/passing/AutoPrelude2.purs+2−2 examples/passing/BindersInFunctions.purs+5−6 examples/passing/BindingGroups.purs+1−1 examples/passing/BlockString.purs+1−1 examples/passing/CaseInDo.purs+3−3 examples/passing/CaseStatement.purs+1−1 examples/passing/CheckFunction.purs+1−1 examples/passing/CheckSynonymBug.purs+4−1 examples/passing/CheckTypeClass.purs+1−1 examples/passing/Church.purs+1−1 examples/passing/Collatz.purs+6−6 examples/passing/Comparisons.purs+3−3 examples/passing/Conditional.purs+1−1 examples/passing/Console.purs+2−2 examples/passing/DataAndType.purs+1−1 examples/passing/DeepArrayBinder.purs+5−4 examples/passing/DeepCase.purs+1−1 examples/passing/Do.purs+5−5 examples/passing/Dollar.purs+1−1 examples/passing/Eff.purs+5−5 examples/passing/EmptyDataDecls.purs+4−4 examples/passing/EmptyRow.purs+1−1 examples/passing/EmptyTypeClass.purs+1−1 examples/passing/EqOrd.purs+2−3 examples/passing/ExtendedInfixOperators.purs+1−1 examples/passing/Fib.purs+1−1 examples/passing/FinalTagless.purs+2−2 examples/passing/FunctionScope.purs+3−4 examples/passing/Functions.purs+1−1 examples/passing/Functions2.purs+3−4 examples/passing/Guards.purs+2−2 examples/passing/HoistError.purs+3−3 examples/passing/IfThenElseMaybe.purs+1−1 examples/passing/ImplicitEmptyImport.purs+3−3 examples/passing/ImportHiding.purs+1−1 examples/passing/InferRecFunWithConstrainedArgument.purs+1−1 examples/passing/InstanceBeforeClass.purs+1−1 examples/passing/IntAndChar.purs+2−2 examples/passing/JSReserved.purs+1−1 examples/passing/KindedType.purs+1−1 examples/passing/Let.purs+7−7 examples/passing/Let2.purs+1−1 examples/passing/LetInInstance.purs+1−1 examples/passing/LiberalTypeSynonyms.purs+1−1 examples/passing/MPTCs.purs+1−1 examples/passing/Match.purs+1−1 examples/passing/ModuleExport.purs+1−1 examples/passing/ModuleExportDupes.purs+1−1 examples/passing/ModuleExportExcluded.purs+1−1 examples/passing/ModuleExportHiding.purs+1−1 examples/passing/ModuleExportQualified.purs+1−1 examples/passing/ModuleExportSelf.purs+1−1 examples/passing/Monad.purs+1−1 examples/passing/MonadState.purs+3−3 examples/passing/MultiArgFunctions.purs+13−13 examples/passing/MutRec.purs+1−1 examples/passing/MutRec2.purs+1−1 examples/passing/MutRec3.purs+1−1 examples/passing/NamedPatterns.purs+1−1 examples/passing/NegativeBinder.purs+1−1 examples/passing/Nested.purs+1−1 examples/passing/NestedTypeSynonyms.purs+1−1 examples/passing/NestedWhere.purs+1−1 examples/passing/Newtype.purs+3−3 examples/passing/NewtypeEff.purs+8−8 examples/passing/NewtypeWithRecordUpdate.purs+2−2 examples/passing/ObjectGetter.purs+4−4 examples/passing/ObjectSynonym.purs+1−1 examples/passing/ObjectUpdate.purs+1−1 examples/passing/ObjectUpdate2.purs+1−1 examples/passing/ObjectUpdater.purs+2−2 examples/passing/ObjectWildcards.purs+3−3 examples/passing/Objects.purs+2−2 examples/passing/OneConstructor.purs+1−1 examples/passing/OperatorAssociativity.purs+3−3 examples/passing/OperatorInlining.purs+1−1 examples/passing/OperatorSections.purs+2−2 examples/passing/Operators.purs+2−2 examples/passing/OptimizerBug.purs+1−1 examples/passing/PartialFunction.purs+2−2 examples/passing/Patterns.purs+1−1 examples/passing/Person.purs+1−1 examples/passing/Rank2Data.purs+2−2 examples/passing/Rank2Object.purs+2−2 examples/passing/Rank2TypeSynonym.purs+1−1 examples/passing/Rank2Types.purs+1−1 examples/passing/RebindableSyntax.purs+4−4 examples/passing/Recursion.purs+1−1 examples/passing/ReservedWords.purs+1−1 examples/passing/RowConstructors.purs+1−1 examples/passing/RowPolyInstanceContext.purs+1−1 examples/passing/RuntimeScopeIssue.purs+1−1 examples/passing/ScopedTypeVariables.purs+1−1 examples/passing/Sequence.purs+1−1 examples/passing/SequenceDesugared.purs+4−4 examples/passing/ShadowedRename.purs+3−3 examples/passing/ShadowedTCO.purs+2−2 examples/passing/ShadowedTCOLet.purs+1−1 examples/passing/SignedNumericLiterals.purs+1−1 examples/passing/Superclasses1.purs+1−1 examples/passing/Superclasses2.purs+1−2 examples/passing/Superclasses3.purs+6−6 examples/passing/TCOCase.purs+1−1 examples/passing/TailCall.purs+1−1 examples/passing/Tick.purs+1−1 examples/passing/TopLevelCase.purs+3−3 examples/passing/TypeClassMemberOrderChange.purs+1−1 examples/passing/TypeClasses.purs+5−5 examples/passing/TypeClassesInOrder.purs+1−1 examples/passing/TypeClassesWithOverlappingTypeVariables.purs+3−3 examples/passing/TypeDecl.purs+1−1 examples/passing/TypeSynonymInData.purs+1−1 examples/passing/TypeSynonyms.purs+1−1 examples/passing/TypeWildcards.purs+1−1 examples/passing/TypeWildcardsRecordExtension.purs+1−1 examples/passing/TypedWhere.purs+1−1 examples/passing/UnderscoreIdent.purs+1−1 examples/passing/Unit.purs+1−1 examples/passing/UnknownInTypeClassLookup.purs+1−1 examples/passing/Where.purs+7−7 examples/passing/iota.purs+1−1 examples/passing/s.purs+1−1 purescript.cabal+4−3 tests/Main.hs+65−17 tests/prelude/Prelude.purs−631 tests/prelude/js/Assert.js−19 tests/prelude/js/Debug.Trace.js−11 tests/prelude/js/Prelude.Unsafe.js−10 tests/prelude/js/Prelude.js−150 tests/support/.gitignore+2 tests/support/bower.json+11 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/prelude/js/Control.Monad.Eff.js → tests/support/flattened/Control-Monad-Eff.js+23−1 tests/support/flattened/Control-Monad-Eff.purs+67 tests/prelude/js/Control.Monad.ST.js → tests/support/flattened/Control-Monad-ST.js+1−1 tests/support/flattened/Control-Monad-ST.purs+42 tests/prelude/js/Data.Function.js → tests/support/flattened/Data-Function.js+1−1 tests/support/flattened/Data-Function.purs+113 tests/support/flattened/Prelude.js+222 tests/support/flattened/Prelude.purs+860 tests/support/flattened/Test-Assert.js+27 tests/support/flattened/Test-Assert.purs+32 tests/support/package.json+7 tests/support/setup.js+13
examples/failing/ArrayType.purs+1−1
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55
66bar :: Number -> Number -> Number
77bar n m = n + m
examples/failing/Eff.purs+2−2
@@ -3,10 +3,10 @@ module Main where
33import Prelude
44import Control.Monad.Eff
55import Control.Monad.ST
6−import Debug.Trace
6+import Control.Monad.Eff.Console
77
88test = pureST (do
99 ref <- newSTRef 0
10− trace "ST"
10+ log "ST"
1111 modifySTRef ref $ \n -> n + 1
1212 readSTRef ref)
examples/failing/ExtraRecordField.pursnew file+9
@@ -0,0 +1,9 @@
1+
2+module ExtraRecordField where
3+
4+import Prelude ((<>))
5+
6+full :: { first :: String, last :: String } -> String
7+full p = p.first <> " " <> p.last
8+
9+oops = full { first: "Jane", last: "Smith", age: 29 }
examples/failing/MissingRecordField.pursnew file+10
@@ -0,0 +1,10 @@
1+
2+module MissingRecordField where
3+
4+import Prelude ((>))
5+
6+john = { first: "John", last: "Smith" }
7+
8+isOver50 p = p.age > 50.0
9+
10+result = isOver50 john
examples/failing/OverlappingInstances.purs+1−1
@@ -10,4 +10,4 @@ instance showA1 :: Show A where
1010instance showA2 :: Show A where
1111 show A = "Instance 2"
1212
13−main = Debug.Trace.trace $ show A
13+main = Control.Monad.Eff.Console.log $ show A
examples/failing/OverlappingInstances2.purs+1−1
@@ -22,4 +22,4 @@ instance ordA :: Ord A where
2222test :: forall a. (Ord a) => a -> a -> String
2323test x y = show $ x == y
2424
25−main = Debug.Trace.trace $ test A B
25+main = Control.Monad.Eff.Console.log $ test A B
examples/failing/RowConstructors1.purs+1−1
@@ -5,4 +5,4 @@ import Prelude
55data Foo = Bar
66type Baz = { | Foo }
77
8−main = Debug.Trace.trace "Done"
8+main = Control.Monad.Eff.Console.log "Done"
examples/failing/RowConstructors2.purs+1−1
@@ -5,4 +5,4 @@ import Prelude
55type Foo r = (x :: Number | r)
66type Bar = { | Foo }
77
8−main = Debug.Trace.trace "Done"
8+main = Control.Monad.Eff.Console.log "Done"
examples/failing/RowConstructors3.purs+1−1
@@ -5,4 +5,4 @@ import Prelude
55type Foo = { x :: Number }
66type Bar = { | Foo }
77
8−main = Debug.Trace.trace "Done"
8+main = Control.Monad.Eff.Console.log "Done"
examples/failing/UnderscoreModuleName.purs+1−1
@@ -2,4 +2,4 @@ module Bad_Module where
22
33import Prelude
44
5−main = Debug.Trace.trace "Done"
5+main = Control.Monad.Eff.Console.log "Done"
examples/manual/QualifiedNames.purs+1−1
@@ -10,4 +10,4 @@ either :: forall a b c. (a -> c) -> (b -> c) -> Data.Either.Either a b -> c
1010either f _ (Data.Either.Left x) = f x
1111either _ g (Data.Either.Right y) = g y
1212
13−main = Debug.Trace.trace (either id id (Data.Either.Left "Done"))
13+main = Control.Monad.Eff.Console.log (either id id (Data.Either.Left "Done"))
examples/manual/failing/ExportExplicit1.purs+1−1
@@ -11,4 +11,4 @@ module Main where
1111 -- should fail as Y constructor is not exported from M1
1212 testY = Y
1313
14− main = Debug.Trace.trace "Done"
14+ main = Control.Monad.Eff.Console.log "Done"
examples/manual/failing/ExportExplicit3.purs+1−1
@@ -10,4 +10,4 @@ module Main where
1010 -- should fail as Z is not exported from M1
1111 testZ = M1.Z
1212
13− main = Debug.Trace.trace "Done"
13+ main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ExportExplicit.purs+1−1
@@ -17,4 +17,4 @@ module Main where
1717 testZ = Z
1818 testFoo = foo
1919
20− main = Debug.Trace.trace "Done"
20+ main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ExportExplicit2.purs+1−1
@@ -12,4 +12,4 @@ module Main where
1212
1313 testBar = bar
1414
15− main = Debug.Trace.trace "Done"
15+ main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/Import.purs+1−1
@@ -16,4 +16,4 @@ module M2 where
1616
1717module Main where
1818
19−main = Debug.Trace.trace "Done"
19+main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ImportExplicit.purs+1−1
@@ -11,4 +11,4 @@ module Main where
1111 testX = X
1212 testY = Y
1313
14− main = Debug.Trace.trace "Done"
14+ main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ImportQualified.purs+3−3
@@ -1,12 +1,12 @@
11module M1 where
22
3− trace x = x
3+ log x = x
44
55module Main where
66
77 import Prelude
88 import Control.Monad.Eff
99 import M1
10− import qualified Debug.Trace as T
10+ import qualified Control.Monad.Eff.Console as C
1111
12− main = T.trace (trace "Done")
12+ main = C.log (log "Done")
examples/manual/passing/Module.purs+1−1
@@ -25,4 +25,4 @@ module M2 where
2525
2626module Main where
2727
28−main = Debug.Trace.trace "Done"
28+main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ModuleDeps.purs+1−1
@@ -14,4 +14,4 @@ baz = 1
1414
1515module Main where
1616
17−main = Debug.Trace.trace "Done"
17+main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/RedefinedFixity.purs+1−1
@@ -21,4 +21,4 @@ import M2
2121
2222module Main where
2323
24−main = Debug.Trace.trace "Done"
24+main = Control.Monad.Eff.Console.log "Done"
examples/manual/passing/ShadowedName.purs+2−2
@@ -1,10 +1,10 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55
66done :: String
77done = let str = "Not yet done" in
88 let str = "Done" in str
99
10−main = Debug.Trace.trace done
10+main = Control.Monad.Eff.Console.log done
examples/manual/passing/TransitiveImport.purs+1−1
@@ -16,7 +16,7 @@ module Main where
1616
1717 import Prelude
1818 import Middle
19− import Debug.Trace
19+ import Control.Monad.Eff.Console
2020
2121 main = do
2222 print (middle unit)
examples/manual/passing/WildcardType.purs+2−2
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55
66f1 :: (_ -> _) -> _
77f1 g = g 1
@@ -9,5 +9,5 @@ f1 g = g 1
99f2 :: _ -> _
1010f2 _ = "Done"
1111
12−main = Debug.Trace.trace $ f1 f2
12+main = Control.Monad.Eff.Console.log $ f1 f2
1313
examples/passing/652.purs+1−1
@@ -14,4 +14,4 @@ instance bar :: Bar (a -> b) b
1414
1515instance baz :: (Eq a) => Baz (a -> b) a b
1616
17−main = Debug.Trace.trace "Done"
17+main = Control.Monad.Eff.Console.log "Done"
examples/passing/810.purs+1−1
@@ -10,4 +10,4 @@ test m = o.x
1010 o = case m of Nothing -> { x : Nothing }
1111 Just a -> { x : Just a }
1212
13−main = Debug.Trace.trace "Done"
13+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Applicative.purs+4−4
@@ -4,13 +4,13 @@ import Prelude ()
44
55class Applicative f where
66 pure :: forall a. a -> f a
7− (<*>) :: forall a b. f (a -> b) -> f a -> f b
7+ apply :: forall a b. f (a -> b) -> f a -> f b
88
99data Maybe a = Nothing | Just a
1010
1111instance applicativeMaybe :: Applicative Maybe where
1212 pure = Just
13− (<*>) (Just f) (Just a) = Just (f a)
14− (<*>) _ _ = Nothing
13+ apply (Just f) (Just a) = Just (f a)
14+ apply _ _ = Nothing
1515
16−main = Debug.Trace.trace "Done"
16+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ArrayType.purs+1−1
@@ -8,4 +8,4 @@ class Pointed p where
88instance pointedArray :: Pointed Array where
99 point a = [a]
1010
11−main = Debug.Trace.trace "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Auto.purs+1−1
@@ -12,4 +12,4 @@ exists = \state step f -> f (Auto { state: state, step: step })
1212run :: forall i o. SomeAuto i o -> i -> o
1313run = \s i -> s (\a -> case a of Auto a -> a.step a.state i)
1414
15−main = Debug.Trace.trace "Done"
15+main = Control.Monad.Eff.Console.log "Done"
examples/passing/AutoPrelude.purs+2−2
@@ -1,9 +1,9 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55
66f x = x * 10.0
77g y = y - 10.0
88
9−main = trace $ show $ (f <<< g) 100.0
9+main = log $ show $ (f <<< g) 100.0
examples/passing/AutoPrelude2.purs+2−2
@@ -2,9 +2,9 @@ module Main where
22
33import Prelude
44import qualified Prelude as P
5−import Debug.Trace
5+import Control.Monad.Eff.Console
66
77f :: forall a. a -> a
88f = P.id
99
10−main = P.($) trace ((f P.<<< f) "Done")
10+main = P.($) log ((f P.<<< f) "Done")
examples/passing/BindersInFunctions.purs+5−6
@@ -1,12 +1,11 @@
11module Main where
22
33import Prelude
4−import Assert
4+import Test.Assert
55
66snd = \[_, y] -> y
77
8−main =
9− let ts = snd [1.0, 2.0] in
10− if ts == 2.0
11− then Debug.Trace.trace "Done"
12− else error "Incorrect result from 'snd'."
8+main = do
9+ let ts = snd [1.0, 2.0]
10+ assert' "Incorrect result from 'snd'." (ts == 2.0)
11+ Control.Monad.Eff.Console.log "Done"
examples/passing/BindingGroups.purs+1−1
@@ -7,4 +7,4 @@ foo = bar
77
88r = foo 2.0
99
10−main = Debug.Trace.trace "Done"
10+main = Control.Monad.Eff.Console.log "Done"
examples/passing/BlockString.purs+1−1
@@ -5,4 +5,4 @@ import Prelude
55foo :: String
66foo = """foo"""
77
8−main = Debug.Trace.trace "Done"
8+main = Control.Monad.Eff.Console.log "Done"
examples/passing/CaseInDo.purs+3−3
@@ -1,14 +1,14 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55import Control.Monad.Eff
66
77doIt :: forall eff. Eff eff Boolean
88doIt = return true
99
1010set = do
11− trace "Testing..."
11+ log "Testing..."
1212 case 0 of
1313 0 -> doIt
1414 _ -> return false
@@ -16,4 +16,4 @@ set = do
1616main = do
1717 b <- set
1818 case b of
19− true -> trace "Done"
19+ true -> log "Done"
examples/passing/CaseStatement.purs+1−1
@@ -18,4 +18,4 @@ h f N a = a
1818h f a N = a
1919h f (J a) (J b) = J (f a b)
2020
21−main = Debug.Trace.trace $ f "Done" "Failed" A
21+main = Control.Monad.Eff.Console.log $ f "Done" "Failed" A
examples/passing/CheckFunction.purs+1−1
@@ -4,4 +4,4 @@ import Prelude
44
55test = ((\x -> x+1.0) >>> (\x -> x*2.0)) 4.0
66
7−main = Debug.Trace.trace "Done"
7+main = Control.Monad.Eff.Console.log "Done"
examples/passing/CheckSynonymBug.purs+4−1
@@ -2,8 +2,11 @@ module Main where
22
33import Prelude
44
5+length :: forall a. Array a -> Int
6+length _ = 0
7+
58type Foo a = Array a
69
710foo _ = length ([] :: Foo Number)
811
9−main = Debug.Trace.trace "Done"
12+main = Control.Monad.Eff.Console.log "Done"
examples/passing/CheckTypeClass.purs+1−1
@@ -14,5 +14,5 @@ foo_ x = foo ((mkBar :: forall a. (Foo a) => a -> Bar a) x)
1414mkBar :: forall a. a -> Bar a
1515mkBar _ = Bar
1616
17−main = Debug.Trace.trace "Done"
17+main = Control.Monad.Eff.Console.log "Done"
1818
examples/passing/Church.purs+1−1
@@ -15,4 +15,4 @@ append = \l1 l2 r f -> l2 (l1 r f) f
1515
1616test = append (cons 1 empty) (cons 2 empty)
1717
18−main = Debug.Trace.trace "Done"
18+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Collatz.purs+6−6
@@ -4,15 +4,15 @@ import Prelude
44import Control.Monad.Eff
55import Control.Monad.ST
66
7−collatz :: Number -> Number
7+collatz :: Int -> Int
88collatz n = runPure (runST (do
99 r <- newSTRef n
10− count <- newSTRef 0.0
10+ count <- newSTRef 0
1111 untilE $ do
12− modifySTRef count $ (+) 1.0
12+ modifySTRef count $ (+) 1
1313 m <- readSTRef r
14− writeSTRef r $ if m % 2.0 == 0.0 then m / 2.0 else 3.0 * m + 1.0
15− return $ m == 1.0
14+ writeSTRef r $ if m `mod` 2 == 0 then m / 2 else 3 * m + 1
15+ return $ m == 1
1616 readSTRef count))
1717
18−main = Debug.Trace.print $ collatz 1000.0
18+main = Control.Monad.Eff.Console.print $ collatz 1000
examples/passing/Comparisons.purs+3−3
@@ -2,8 +2,8 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Debug.Trace
6−import Assert
5+import Control.Monad.Eff.Console
6+import Test.Assert
77
88main = do
99 assert (1.0 < 2.0)
@@ -12,4 +12,4 @@ main = do
1212 assert ("a" < "b")
1313 assert ("a" == "a")
1414 assert ("z" > "a")
15− trace "Done!"
15+ log "Done!"
examples/passing/Conditional.purs+1−1
@@ -6,4 +6,4 @@ fns = \f -> if f true then f else \x -> x
66
77not = \x -> if x then false else true
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Console.purs+2−2
@@ -2,7 +2,7 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Debug.Trace
5+import Control.Monad.Eff.Console
66
77replicateM_ :: forall m a. (Monad m) => Number -> m a -> m {}
88replicateM_ 0.0 _ = return {}
@@ -10,4 +10,4 @@ replicateM_ n act = do
1010 act
1111 replicateM_ (n - 1.0) act
1212
13−main = replicateM_ 10.0 (trace "Hello World!")
13+main = replicateM_ 10.0 (log "Hello World!")
examples/passing/DataAndType.purs+1−1
@@ -6,4 +6,4 @@ data A = A B
66
77type B = A
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/DeepArrayBinder.purs+5−4
@@ -2,7 +2,7 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Assert
5+import Test.Assert
66
77data List a = Cons a (List a) | Nil
88
@@ -10,6 +10,7 @@ match2 :: List Number -> Number
1010match2 (Cons x (Cons y xs)) = x * y + match2 xs
1111match2 _ = 0.0
1212
13−main = case match2 (Cons 1.0 (Cons 2.0 (Cons 3.0 (Cons 4.0 (Cons 5.0 (Cons 6.0 (Cons 7.0 (Cons 8.0 (Cons 9.0 Nil))))))))) of
14− 100.0 -> Debug.Trace.trace "Done"
15− _ -> error "Incorrect result!"
13+main = do
14+ let result = match2 (Cons 1.0 (Cons 2.0 (Cons 3.0 (Cons 4.0 (Cons 5.0 (Cons 6.0 (Cons 7.0 (Cons 8.0 (Cons 9.0 Nil)))))))))
15+ assert' "Incorrect result!" (result == 100.0)
16+ Control.Monad.Eff.Console.log "Done"
examples/passing/DeepCase.purs+1−1
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55import Control.Monad.Eff
66import Control.Monad.ST
77
examples/passing/Do.purs+5−5
@@ -5,12 +5,12 @@ import Prelude
55data Maybe a = Nothing | Just a
66
77instance functorMaybe :: Functor Maybe where
8− (<$>) f Nothing = Nothing
9− (<$>) f (Just x) = Just (f x)
8+ map f Nothing = Nothing
9+ map f (Just x) = Just (f x)
1010
1111instance applyMaybe :: Apply Maybe where
12− (<*>) (Just f) (Just x) = Just (f x)
13− (<*>) _ _ = Nothing
12+ apply (Just f) (Just x) = Just (f x)
13+ apply _ _ = Nothing
1414
1515instance applicativeMaybe :: Applicative Maybe where
1616 pure = Just
@@ -64,4 +64,4 @@ test10 _ = do
6464 g x = f x / 2.0
6565 Just (f 10.0)
6666
67−main = Debug.Trace.trace "Done"
67+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Dollar.purs+1−1
@@ -13,4 +13,4 @@ test1 x = id $ id $ id $ id $ x
1313
1414test2 x = id id $ id x
1515
16−main = Debug.Trace.trace "Done"
16+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Eff.purs+5−5
@@ -3,11 +3,11 @@ module Main where
33import Prelude
44import Control.Monad.Eff
55import Control.Monad.ST
6−import Debug.Trace
6+import Control.Monad.Eff.Console
77
88test1 = do
9− trace "Line 1"
10− trace "Line 2"
9+ log "Line 1"
10+ log "Line 2"
1111
1212test2 = runPure (runST (do
1313 ref <- newSTRef 0.0
@@ -21,5 +21,5 @@ test3 = pureST (do
2121
2222main = do
2323 test1
24− Debug.Trace.print test2
25− Debug.Trace.print test3
24+ Control.Monad.Eff.Console.print test2
25+ Control.Monad.Eff.Console.print test3
examples/passing/EmptyDataDecls.purs+4−4
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Assert
4+import Test.Assert
55
66data Z
77data S n
@@ -12,8 +12,8 @@ nil :: forall a. ArrayBox Z a
1212nil = ArrayBox []
1313
1414cons' :: forall a n. a -> ArrayBox n a -> ArrayBox (S n) a
15−cons' x (ArrayBox xs) = ArrayBox $ concat [x] xs
15+cons' x (ArrayBox xs) = ArrayBox $ append [x] xs
1616
1717main = case cons' 1 $ cons' 2 $ cons' 3 nil of
18− ArrayBox [1, 2, 3] -> Debug.Trace.trace "Done"
19− _ -> error "Failed"
18+ ArrayBox [1, 2, 3] -> Control.Monad.Eff.Console.log "Done"
19+ _ -> assert' "Failed" false
examples/passing/EmptyRow.purs+1−1
@@ -7,4 +7,4 @@ data Foo r = Foo { | r }
77test :: Foo ()
88test = Foo {}
99
10−main = Debug.Trace.trace "Done"
10+main = Control.Monad.Eff.Console.log "Done"
examples/passing/EmptyTypeClass.purs+1−1
@@ -9,4 +9,4 @@ head [x] = x
99
1010instance allowPartials :: Partial
1111
12−main = Debug.Trace.trace $ head ["Done"]
12+main = Control.Monad.Eff.Console.log $ head ["Done"]
examples/passing/EqOrd.purs+2−3
@@ -10,7 +10,6 @@ instance ordPair :: (Ord a, Ord b) => Ord (Pair a b) where
1010 r -> r
1111
1212instance eqPair :: (Eq a, Eq b) => Eq (Pair a b) where
13− (==) (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2
14− (/=) (Pair a1 b1) (Pair a2 b2) = a1 /= a2 || b1 /= b2
13+ eq (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2
1514
16−main = Debug.Trace.print $ Pair 1.0 2.0 == Pair 1.0 2.0
15+main = Control.Monad.Eff.Console.print $ 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− Debug.Trace.print test
14+ Control.Monad.Eff.Console.print 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− Debug.Trace.print n2')
15+ Control.Monad.Eff.Console.print n2')
examples/passing/FinalTagless.purs+2−2
@@ -1,6 +1,6 @@
11module Main where
22
3−import Prelude
3+import Prelude hiding (add)
44
55class E e where
66 num :: Number -> e Number
@@ -19,4 +19,4 @@ runId (Id a) = a
1919three :: Expr Number
2020three = add (num 1.0) (num 2.0)
2121
22−main = Debug.Trace.print $ runId three
22+main = Control.Monad.Eff.Console.print $ runId three
examples/passing/FunctionScope.purs+3−4
@@ -1,13 +1,12 @@
11module Main where
22
33import Prelude
4−import Assert
4+import Test.Assert
55
66mkValue :: Number -> Number
77mkValue id = id
88
99main = do
1010 let value = mkValue 1.0
11− if value == 1.0
12− then Debug.Trace.trace "Done"
13− else error "Not done"
11+ assert $ value == 1.0
12+ Control.Monad.Eff.Console.log "Done"
examples/passing/Functions.purs+1−1
@@ -12,4 +12,4 @@ test4 = \(%%) -> 1.0 %% 2.0
1212
1313test5 = \(+++) (***) -> 1.0 +++ 2.0 *** 3.0
1414
15−main = Debug.Trace.trace "Done"
15+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Functions2.purs+3−4
@@ -1,13 +1,12 @@
11module Main where
22
33import Prelude
4−import Assert
4+import Test.Assert
55
66test :: forall a b. a -> b -> a
77test = \const _ -> const
88
99main = do
1010 let value = test "Done" {}
11− if value == "Done"
12− then Debug.Trace.trace "Done"
13− else error "Not done"
11+ assert' "Not done" $ value == "Done"
12+ Control.Monad.Eff.Console.log "Done"
examples/passing/Guards.purs+2−2
@@ -3,7 +3,7 @@ module Main where
33import Prelude
44
55collatz = \x -> case x of
6− y | y % 2.0 == 0.0 -> y / 2.0
6+ y | y `mod` 2.0 == 0.0 -> y / 2.0
77 y -> y * 3.0 + 1.0
88
99-- Guards have access to current scope
@@ -26,4 +26,4 @@ testIndentation x y | x > 0.0
2626 | otherwise
2727 = y - x
2828
29−main = Debug.Trace.trace $ min "Done" "ZZZZ"
29+main = Control.Monad.Eff.Console.log $ min "Done" "ZZZZ"
examples/passing/HoistError.purs+3−3
@@ -2,11 +2,11 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Debug.Trace
6−import Assert
5+import Control.Monad.Eff.Console
6+import Test.Assert
77
88main = do
99 let x = 0.0
1010 assert $ x == 0.0
1111 let x = 1.0 + 1.0
12− trace "Done"
12+ log "Done"
examples/passing/IfThenElseMaybe.purs+1−1
@@ -8,4 +8,4 @@ test1 = if true then Just 10 else Nothing
88
99test2 = if true then Nothing else Just 10
1010
11−main = Debug.Trace.trace "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ImplicitEmptyImport.purs+3−3
@@ -3,6 +3,6 @@ module Main where
33import Prelude
44
55main = do
6− Debug.Trace.trace "Hello"
7− Debug.Trace.trace "Goodbye"
8− Debug.Trace.trace "Done"
6+ Control.Monad.Eff.Console.log "Hello"
7+ Control.Monad.Eff.Console.log "Goodbye"
8+ Control.Monad.Eff.Console.log "Done"
examples/passing/ImportHiding.purs+1−1
@@ -1,6 +1,6 @@
11module Main where
22
3−import Debug.Trace
3+import Control.Monad.Eff.Console
44import Prelude hiding (
55 show, -- a value
66 Show, -- a type class
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 = Debug.Trace.print $ test 0.0
8+main = Control.Monad.Eff.Console.print $ test 0.0
examples/passing/InstanceBeforeClass.purs+1−1
@@ -8,4 +8,4 @@ instance fooNumber :: Foo Number where
88class Foo a where
99 foo :: a
1010
11−main = Debug.Trace.trace "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/IntAndChar.purs+2−2
@@ -2,7 +2,7 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Assert
5+import Test.Assert
66
77f 1 = 1
88f _ = 0
@@ -15,4 +15,4 @@ main = do
1515 assert $ f 0 == 0
1616 assert $ g 'a' == 'a'
1717 assert $ g 'b' == 'b'
18− Debug.Trace.trace "Done"
18+ Control.Monad.Eff.Console.log "Done"
examples/passing/JSReserved.purs+1−1
@@ -9,4 +9,4 @@ public = \return -> return
99
1010this catch = catch
1111
12−main = Debug.Trace.trace "Done"
12+main = Control.Monad.Eff.Console.log "Done"
examples/passing/KindedType.purs+1−1
@@ -30,4 +30,4 @@ class Clazz (a :: *) where
3030instance clazzString :: Clazz String where
3131 def = "test"
3232
33−main = Debug.Trace.trace "Done"
33+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Let.purs+7−7
@@ -44,10 +44,10 @@ test10 _ =
4444 in f 10.0
4545
4646main = do
47− Debug.Trace.print (test1 1.0)
48− Debug.Trace.print (test2 1.0 2.0)
49− Debug.Trace.print test3
50− Debug.Trace.print test4
51− Debug.Trace.print test5
52− Debug.Trace.print test7
53− Debug.Trace.print (test8 100.0)
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)
examples/passing/Let2.purs+1−1
@@ -14,4 +14,4 @@ test =
1414 x = f 1.0
1515 in not x
1616
17−main = Debug.Trace.print test
17+main = Control.Monad.Eff.Console.print test
examples/passing/LetInInstance.purs+1−1
@@ -11,4 +11,4 @@ instance fooString :: Foo String where
1111 go :: String -> String
1212 go s = s
1313
14−main = Debug.Trace.trace "Done"
14+main = Control.Monad.Eff.Console.log "Done"
examples/passing/LiberalTypeSynonyms.purs+1−1
@@ -18,4 +18,4 @@ f :: (forall r. F r) -> String
1818f g = case g { x: "Hello" } of
1919 { x = x } -> x
2020
21−main = Debug.Trace.trace "Done"
21+main = Control.Monad.Eff.Console.log "Done"
examples/passing/MPTCs.purs+1−1
@@ -17,4 +17,4 @@ instance coerceRefl :: Coerce a a where
1717instance coerceShow :: (Prelude.Show a) => Coerce a String where
1818 coerce = show
1919
20−main = Debug.Trace.trace "Done"
20+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Match.purs+1−1
@@ -6,4 +6,4 @@ data Foo a = Foo
66
77foo = \f -> case f of Foo -> "foo"
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ModuleExport.purs+1−1
@@ -2,7 +2,7 @@ module A (module Prelude) where
22 import Prelude
33
44module Main where
5− import Debug.Trace
5+ import Control.Monad.Eff.Console
66 import A
77
88 main = do
examples/passing/ModuleExportDupes.purs+1−1
@@ -9,7 +9,7 @@ module C (module Prelude, module A) where
99 import A
1010
1111module Main where
12− import Debug.Trace
12+ import Control.Monad.Eff.Console
1313 import A
1414 import B
1515 import C
examples/passing/ModuleExportExcluded.purs+1−1
@@ -5,7 +5,7 @@ module A (module Prelude, foo) where
55 foo _ = 0.0
66
77module Main where
8− import Debug.Trace
8+ import Control.Monad.Eff.Console
99 import A (foo)
1010
1111 otherwise = false
examples/passing/ModuleExportHiding.purs+1−1
@@ -2,7 +2,7 @@ module A (module Prelude) where
22 import Prelude
33
44module Main where
5− import Debug.Trace
5+ import Control.Monad.Eff.Console
66 import A hiding (module Prelude)
77
88 otherwise = false
examples/passing/ModuleExportQualified.purs+1−1
@@ -2,7 +2,7 @@ module A (module Prelude) where
22 import Prelude
33
44module Main where
5− import Debug.Trace
5+ import Control.Monad.Eff.Console
66 import qualified A as B
77
88 main = do
examples/passing/ModuleExportSelf.purs+1−1
@@ -4,7 +4,7 @@ module A (module A, module Prelude) where
44 type Foo = Boolean
55
66module Main where
7− import Debug.Trace
7+ import Control.Monad.Eff.Console
88 import A
99
1010 bar :: Foo
examples/passing/Monad.purs+1−1
@@ -29,4 +29,4 @@ test1 = test id
2929
3030test2 = test maybe
3131
32−main = Debug.Trace.trace "Done"
32+main = Control.Monad.Eff.Console.log "Done"
examples/passing/MonadState.purs+3−3
@@ -13,10 +13,10 @@ data State s a = State (s -> Tuple s a)
1313runState s (State f) = f s
1414
1515instance functorState :: Functor (State s) where
16− (<$>) = liftM1
16+ map = liftM1
1717
1818instance applyState :: Apply (State s) where
19− (<*>) = ap
19+ apply = ap
2020
2121instance applicativeState :: Applicative (State s) where
2222 pure a = State $ \s -> Tuple s a
@@ -44,5 +44,5 @@ test = runState "" $ do
4444
4545main = do
4646 let t1 = test
47− Debug.Trace.trace "Done"
47+ Control.Monad.Eff.Console.log "Done"
4848
examples/passing/MultiArgFunctions.purs+13−13
@@ -3,7 +3,7 @@ module Main where
33import Prelude
44import Data.Function
55import Control.Monad.Eff
6−import Debug.Trace
6+import Control.Monad.Eff.Console
77
88f = mkFn2 $ \a b -> runFn2 g a b + runFn2 g b a
99
@@ -12,16 +12,16 @@ g = mkFn2 $ \a b -> case {} of
1212 _ -> runFn2 f (a - 0.0) (b - 0.0)
1313
1414main = do
15− runFn0 (mkFn0 $ \_ -> trace $ show 0.0)
16− runFn1 (mkFn1 $ \a -> trace $ show a) 0.0
17− runFn2 (mkFn2 $ \a b -> trace $ show [a, b]) 0.0 0.0
18− runFn3 (mkFn3 $ \a b c -> trace $ show [a, b, c]) 0.0 0.0 0.0
19− runFn4 (mkFn4 $ \a b c d -> trace $ show [a, b, c, d]) 0.0 0.0 0.0 0.0
20− runFn5 (mkFn5 $ \a b c d e -> trace $ show [a, b, c, d, e]) 0.0 0.0 0.0 0.0 0.0
21− runFn6 (mkFn6 $ \a b c d e f -> trace $ show [a, b, c, d, e, f]) 0.0 0.0 0.0 0.0 0.0 0.0
22− runFn7 (mkFn7 $ \a b c d e f g -> trace $ show [a, b, c, d, e, f, g]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0
23− runFn8 (mkFn8 $ \a b c d e f g h -> trace $ 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
24− runFn9 (mkFn9 $ \a b c d e f g h i -> trace $ 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
25− runFn10 (mkFn10 $ \a b c d e f g h i j-> trace $ 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
15+ runFn0 (mkFn0 $ \_ -> log $ show 0.0)
16+ runFn1 (mkFn1 $ \a -> log $ show a) 0.0
17+ runFn2 (mkFn2 $ \a b -> log $ show [a, b]) 0.0 0.0
18+ runFn3 (mkFn3 $ \a b c -> log $ show [a, b, c]) 0.0 0.0 0.0
19+ runFn4 (mkFn4 $ \a b c d -> log $ show [a, b, c, d]) 0.0 0.0 0.0 0.0
20+ runFn5 (mkFn5 $ \a b c d e -> log $ show [a, b, c, d, e]) 0.0 0.0 0.0 0.0 0.0
21+ runFn6 (mkFn6 $ \a b c d e f -> log $ show [a, b, c, d, e, f]) 0.0 0.0 0.0 0.0 0.0 0.0
22+ runFn7 (mkFn7 $ \a b c d e f g -> log $ show [a, b, c, d, e, f, g]) 0.0 0.0 0.0 0.0 0.0 0.0 0.0
23+ 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
24+ 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
25+ 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
2626 print $ runFn2 g 0.0 0.0
27− trace "Done!"
27+ log "Done!"
examples/passing/MutRec.purs+1−1
@@ -16,4 +16,4 @@ evenToNumber (Even n) = oddToNumber n + 0.0
1616
1717oddToNumber (Odd n) = evenToNumber n + 0.0
1818
19−main = Debug.Trace.trace "Done"
19+main = Control.Monad.Eff.Console.log "Done"
examples/passing/MutRec2.purs+1−1
@@ -16,4 +16,4 @@ g b = case b of B a -> f a
1616showN :: A -> S
1717showN a = f a
1818
19−main = Debug.Trace.trace "Done"
19+main = Control.Monad.Eff.Console.log "Done"
examples/passing/MutRec3.purs+1−1
@@ -16,4 +16,4 @@ g b = case b of B a -> f a
1616showN :: A -> S
1717showN a = f a
1818
19−main = Debug.Trace.trace "Done"
19+main = Control.Monad.Eff.Console.log "Done"
examples/passing/NamedPatterns.purs+1−1
@@ -6,4 +6,4 @@ foo = \x -> case x of
66 y@{ foo = "Foo" } -> y
77 y -> y
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/NegativeBinder.purs+1−1
@@ -6,4 +6,4 @@ test :: Number -> Boolean
66test -1.0 = false
77test _ = true
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Nested.purs+1−1
@@ -6,4 +6,4 @@ data Extend r a = Extend { prev :: r a, next :: a }
66
77data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/NestedTypeSynonyms.purs+1−1
@@ -8,4 +8,4 @@ type Y = X -> X
88fn :: Y
99fn a = a
1010
11−main = Debug.Trace.print (fn "Done")
11+main = Control.Monad.Eff.Console.print (fn "Done")
examples/passing/NestedWhere.purs+1−1
@@ -9,4 +9,4 @@ f x = g x
99 go x = go1 (x - 1.0)
1010 go1 x = go x
1111
12−main = Debug.Trace.trace "Done"
12+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Newtype.purs+3−3
@@ -1,8 +1,8 @@
11module Main where
22
3−import Prelude
3+import Prelude hiding (apply)
44import Control.Monad.Eff
5−import Debug.Trace
5+import Control.Monad.Eff.Console
66
77newtype Thing = Thing String
88
@@ -20,4 +20,4 @@ main = do
2020 print $ Thing "hello"
2121 print $ Box 42.0
2222 print $ apply Box 9000.0
23− trace "Done"
23+ log "Done"
examples/passing/NewtypeEff.purs+8−8
@@ -1,19 +1,19 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55import Control.Monad.Eff
66
7−newtype T a = T (Eff (trace :: Trace) a)
7+newtype T a = T (Eff (console :: CONSOLE) a)
88
9−runT :: forall a. T a -> Eff (trace :: Trace) a
9+runT :: forall a. T a -> Eff (console :: CONSOLE) a
1010runT (T t) = t
1111
1212instance functorT :: Functor T where
13− (<$>) f (T t) = T (f <$> t)
13+ map f (T t) = T (f <$> t)
1414
1515instance applyT :: Apply T where
16− (<*>) (T f) (T x) = T (f <*> x)
16+ apply (T f) (T x) = T (f <*> x)
1717
1818instance applicativeT :: Applicative T where
1919 pure t = T (pure t)
@@ -24,6 +24,6 @@ instance bindT :: Bind T where
2424instance monadT :: Monad T
2525
2626main = runT do
27− T $ trace "Done"
28− T $ trace "Done"
29− T $ trace "Done"
27+ T $ log "Done"
28+ T $ log "Done"
29+ T $ log "Done"
examples/passing/NewtypeWithRecordUpdate.purs+2−2
@@ -3,7 +3,7 @@
33module Main where
44
55import Prelude
6−import Debug.Trace
6+import Control.Monad.Eff.Console
77
88newtype NewType a = NewType (Object a)
99
@@ -13,4 +13,4 @@ rec1 = { a: 0.0, b: 0.0, c: 0.0 }
1313rec2 :: NewType (a :: Number, b :: Number, c :: Number)
1414rec2 = NewType (rec1 { a = 1.0 })
1515
16−main = trace "Done"
16+main = log "Done"
examples/passing/ObjectGetter.purs+4−4
@@ -7,7 +7,7 @@ getX = _.x
77point = { x: 1.0, y: 0.0 }
88
99main = do
10− Debug.Trace.print $ getX point
11− Debug.Trace.trace $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" }
12− Debug.Trace.trace $ (_.x >>> _.y) { x: { y: "Nested" } }
13− Debug.Trace.trace $ _.value { value: "Done!" }
10+ Control.Monad.Eff.Console.print $ getX point
11+ Control.Monad.Eff.Console.log $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" }
12+ Control.Monad.Eff.Console.log $ (_.x >>> _.y) { x: { y: "Nested" } }
13+ Control.Monad.Eff.Console.log $ _.value { value: "Done!" }
examples/passing/ObjectSynonym.purs+1−1
@@ -12,4 +12,4 @@ type Outer = { inner :: Inner }
1212outer :: Outer
1313outer = { inner: inner }
1414
15−main = Debug.Trace.trace "Done"
15+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ObjectUpdate.purs+1−1
@@ -17,4 +17,4 @@ polyUpdate = \o -> o { foo = "Foo" }
1717
1818inferPolyUpdate = \o -> o { foo = "Foo" }
1919
20−main = Debug.Trace.trace ((update1 {foo: ""}).foo)
20+main = Control.Monad.Eff.Console.log ((update1 {foo: ""}).foo)
examples/passing/ObjectUpdate2.purs+1−1
@@ -14,4 +14,4 @@ test = blah x
1414 { baz = "blah"
1515 }
1616
17−main = Debug.Trace.trace "Done"
17+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ObjectUpdater.purs+2−2
@@ -2,8 +2,8 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Debug.Trace
6−import Assert
5+import Control.Monad.Eff.Console
6+import Test.Assert
77
88getValue :: forall e. Eff (| e) Boolean
99getValue = return true
examples/passing/ObjectWildcards.purs+3−3
@@ -2,8 +2,8 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Debug.Trace
6−import Assert
5+import Control.Monad.Eff.Console
6+import Test.Assert
77
88mkRecord = { foo: _, bar: _, baz: "baz" }
99
@@ -17,4 +17,4 @@ main = do
1717 point <- { x: _, y: x } <$> return 2.0
1818 assert $ point.x == 2.0
1919 assert $ point.y == 1.0
20− trace (mkRecord 1.0 "Done!").bar
20+ log (mkRecord 1.0 "Done!").bar
examples/passing/Objects.purs+2−2
@@ -1,6 +1,6 @@
11module Main where
22
3−import Prelude
3+import Prelude hiding (append)
44
55test = \x -> x.foo + x.bar + 1.0
66
@@ -32,4 +32,4 @@ test6 = case { "***": 1.0 } of
3232
3333test7 {a: snoog , b : blah } = blah
3434
35−main = Debug.Trace.trace "Done"
35+main = Control.Monad.Eff.Console.log "Done"
examples/passing/OneConstructor.purs+1−1
@@ -6,4 +6,4 @@ data One a = One a
66
77one' (One a) = a
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/OperatorAssociativity.purs+3−3
@@ -2,8 +2,8 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Debug.Trace
6−import Assert
5+import Control.Monad.Eff.Console
6+import Test.Assert
77
88bug :: Number -> Number -> Number
99bug a b = 0.0 - (a - b)
@@ -22,4 +22,4 @@ main = do
2222 assert (1.0 + 10.0 - 5.0 == 6.0)
2323 assert (1.0 + 10.0 * 5.0 == 51.0)
2424 assert (10.0 * 5.0 - 1.0 == 49.0)
25− trace "Success!"
25+ log "Success!"
examples/passing/OperatorInlining.purs+1−1
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55
66main = do
77
examples/passing/OperatorSections.purs+2−2
@@ -1,11 +1,11 @@
11module Main where
22
33import Prelude
4−import Assert
4+import Test.Assert
55
66main = do
77 assert $ (/ 2.0) 4.0 == 2.0
88 assert $ (2.0 /) 4.0 == 0.5
99 assert $ (`const` 1.0) 2.0 == 2.0
1010 assert $ (1.0 `const`) 2.0 == 1.0
11− Debug.Trace.trace "Done!"
11+ Control.Monad.Eff.Console.log "Done!"
examples/passing/Operators.purs+2−2
@@ -2,7 +2,7 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Debug.Trace
5+import Control.Monad.Eff.Console
66
77(?!) :: forall a. a -> a -> a
88(?!) x _ = x
@@ -96,4 +96,4 @@ main = do
9696 let t18 = test18
9797 let t19 = test19
9898 let t20 = test20
99− trace "Done"
99+ log "Done"
examples/passing/OptimizerBug.purs+1−1
@@ -6,4 +6,4 @@ x a = 1.0 + y a
66
77y a = x a
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/PartialFunction.purs+2−2
@@ -1,10 +1,10 @@
11module Main where
22
33import Prelude
4−import Assert
4+import Test.Assert
55
66fn :: Number -> Number
77fn 0.0 = 0.0
88fn 1.0 = 2.0
99
10−main = assertPartial $ \_ -> fn 2.0
10+main = assertThrows $ \_ -> fn 2.0
examples/passing/Patterns.purs+1−1
@@ -19,4 +19,4 @@ isDesc :: Array Number -> Boolean
1919isDesc [x, y] | x > y = true
2020isDesc _ = false
2121
22−main = Debug.Trace.trace "Done"
22+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Person.purs+1−1
@@ -8,4 +8,4 @@ showPerson :: Person -> String
88showPerson = \p -> case p of
99 Person o -> o.name ++ ", aged " ++ show o.age
1010
11−main = Debug.Trace.trace "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Rank2Data.purs+2−2
@@ -1,6 +1,6 @@
11module Main where
22
3−import Prelude
3+import Prelude hiding (add)
44
55data Id = Id forall a. a -> a
66
@@ -26,4 +26,4 @@ two = succ zero'
2626four = add two two
2727fourNumber = runNat four
2828
29−main = Debug.Trace.trace "Done'"
29+main = Control.Monad.Eff.Console.log "Done'"
examples/passing/Rank2Object.purs+2−2
@@ -1,11 +1,11 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55
66data Foo = Foo { id :: forall a. a -> a }
77
88foo :: Foo -> Number
99foo (Foo { id = f }) = f 0.0
1010
11−main = trace "Done"
11+main = log "Done"
examples/passing/Rank2TypeSynonym.purs+1−1
@@ -13,4 +13,4 @@ bar = foo 3.0
1313
1414main = do
1515 x <- bar
16− Debug.Trace.print x
16+ Control.Monad.Eff.Console.print x
examples/passing/Rank2Types.purs+1−1
@@ -8,4 +8,4 @@ test1 = \f -> f 0.0
88forever :: forall m a b. (forall a b. m a -> (a -> m b) -> m b) -> m a -> m b
99forever = \bind action -> bind action $ \_ -> forever bind action
1010
11−main = Debug.Trace.trace "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/RebindableSyntax.purs+4−4
@@ -20,10 +20,10 @@ runConst :: forall a b. Const a b -> a
2020runConst (Const a) = a
2121
2222instance functorConst :: Functor (Const a) where
23− (<$>) _ (Const a) = Const a
23+ map _ (Const a) = Const a
2424
2525instance applyConst :: (Semigroup a) => Apply (Const a) where
26− (<*>) (Const a1) (Const a2) = Const (a1 <> a2)
26+ apply (Const a1) (Const a2) = Const (a1 <> a2)
2727
2828example2 :: Const String Unit
2929example2 = do
@@ -35,5 +35,5 @@ example2 = do
3535 bind x f = x *> f unit
3636
3737main = do
38− Debug.Trace.trace example1
39− Debug.Trace.trace $ runConst example2
38+ Control.Monad.Eff.Console.log example1
39+ Control.Monad.Eff.Console.log $ runConst example2
examples/passing/Recursion.purs+1−1
@@ -7,4 +7,4 @@ fib = \n -> case n of
77 1.0 -> 1.0
88 n -> fib (n - 1.0) + fib (n - 2.0)
99
10−main = Debug.Trace.trace "Done"
10+main = Control.Monad.Eff.Console.log "Done"
examples/passing/ReservedWords.purs+1−1
@@ -12,4 +12,4 @@ p = o { type = "p" }
1212f :: forall r. { type :: String | r } -> String
1313f { type = "p" } = "Done"
1414
15−main = Debug.Trace.trace $ f { type: p.type, foo: "bar" }
15+main = Control.Monad.Eff.Console.log $ f { type: p.type, foo: "bar" }
examples/passing/RowConstructors.purs+1−1
@@ -39,4 +39,4 @@ wildcard { w: w } = { x: w, y: w, z: w, w: w }
3939wildcard' :: { | Quux _ } -> Number
4040wildcard' { q: q } = q
4141
42−main = Debug.Trace.trace "Done"
42+main = Control.Monad.Eff.Console.log "Done"
examples/passing/RowPolyInstanceContext.purs+1−1
@@ -19,4 +19,4 @@ test2 = state $ \o -> o { foo = o.foo ++ "!" }
1919main = do
2020 let t1 = test1
2121 let t2 = test2
22− Debug.Trace.trace "Done"
22+ Control.Monad.Eff.Console.log "Done"
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 = Debug.Trace.print $ a 10.0
19+main = Control.Monad.Eff.Console.print $ a 10.0
examples/passing/ScopedTypeVariables.purs+1−1
@@ -33,4 +33,4 @@ test4 = h
3333 j x = x
3434
3535
36−main = Debug.Trace.trace "Done"
36+main = Control.Monad.Eff.Console.log "Done"
examples/passing/Sequence.purs+1−1
@@ -12,4 +12,4 @@ instance sequenceList :: Sequence List where
1212 sequence Nil = pure Nil
1313 sequence (Cons x xs) = Cons <$> x <*> sequence xs
1414
15−main = sequence $ Cons (Debug.Trace.trace "Done") Nil
15+main = sequence $ Cons (Control.Monad.Eff.Console.log "Done") Nil
examples/passing/SequenceDesugared.purs+4−4
@@ -31,7 +31,7 @@ sequenceList''' = Sequence ((\val -> case val of
3131 Cons x xs -> Cons <$> x <*> sequence sequenceList''' xs) :: forall m a. (Monad m) => List (m a) -> m (List a))
3232
3333main = do
34− sequence sequenceList $ Cons (Debug.Trace.trace "Done") Nil
35− sequence sequenceList' $ Cons (Debug.Trace.trace "Done") Nil
36− sequence sequenceList'' $ Cons (Debug.Trace.trace "Done") Nil
37− sequence sequenceList''' $ Cons (Debug.Trace.trace "Done") Nil
34+ sequence sequenceList $ Cons (Control.Monad.Eff.Console.log "Done") Nil
35+ sequence sequenceList' $ Cons (Control.Monad.Eff.Console.log "Done") Nil
36+ sequence sequenceList'' $ Cons (Control.Monad.Eff.Console.log "Done") Nil
37+ sequence sequenceList''' $ Cons (Control.Monad.Eff.Console.log "Done") Nil
examples/passing/ShadowedRename.purs+3−3
@@ -2,8 +2,8 @@ module Main where
22
33import Prelude
44import Control.Monad.Eff
5−import Debug.Trace
6−import Assert
5+import Control.Monad.Eff.Console
6+import Test.Assert
77
88foo foo = let foo_1 = \_ -> foo
99 foo_2 = foo_1 unit + 1.0
@@ -11,4 +11,4 @@ foo foo = let foo_1 = \_ -> foo
1111
1212main = do
1313 assert $ foo 1.0 == 2.0
14− trace "Done"
14+ log "Done"
examples/passing/ShadowedTCO.purs+2−2
@@ -1,6 +1,6 @@
11module Main where
22
3−import Prelude
3+import Prelude hiding (add)
44
55runNat f = f 0.0 (\n -> n + 1.0)
66
@@ -15,4 +15,4 @@ two = succ one'
1515four = add two two
1616fourNumber = runNat four
1717
18−main = Debug.Trace.trace $ show fourNumber
18+main = Control.Monad.Eff.Console.log $ show fourNumber
examples/passing/ShadowedTCOLet.purs+1−1
@@ -6,4 +6,4 @@ f x y z =
66 let f 1.0 2.0 3.0 = 1.0
77 in f x z y
88
9−main = Debug.Trace.trace $ show $ f 1.0 3.0 2.0
9+main = Control.Monad.Eff.Console.log $ show $ f 1.0 3.0 2.0
examples/passing/SignedNumericLiterals.purs+1−1
@@ -14,4 +14,4 @@ f x = -x
1414
1515test1 = 2.0 - 1.0
1616
17−main = Debug.Trace.trace "Done"
17+main = Control.Monad.Eff.Console.log "Done"
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 = Debug.Trace.print $ test 10.0
20+main = Control.Monad.Eff.Console.print $ test 10.0
examples/passing/Superclasses2.purs+1−2
@@ -1,7 +1,6 @@
11module Main where
22
33import Prelude
4−import Prelude.Unsafe (unsafeIndex)
54
65class Su a where
76 su :: a -> a
@@ -21,4 +20,4 @@ instance clNumber :: Cl Number where
2120test :: forall a. (Cl a) => a -> Array a
2221test x = su [cl x x]
2322
24−main = Debug.Trace.print $ test 10.0 `unsafeIndex` 0.0
23+main = Control.Monad.Eff.Console.print $ test 10.0
examples/passing/Superclasses3.purs+6−6
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55import Control.Monad.Eff
66
77class (Monad m) <= MonadWriter w m where
@@ -16,16 +16,16 @@ test w = do
1616 tell w
1717 tell w
1818
19−data MTrace a = MTrace (Eff (trace :: Trace) a)
19+data MTrace a = MTrace (Eff (console :: CONSOLE) a)
2020
21−runMTrace :: forall a. MTrace a -> Eff (trace :: Trace) a
21+runMTrace :: forall a. MTrace a -> Eff (console :: CONSOLE) a
2222runMTrace (MTrace a) = a
2323
2424instance functorMTrace :: Functor MTrace where
25− (<$>) = liftM1
25+ map = liftM1
2626
2727instance applyMTrace :: Apply MTrace where
28− (<*>) = ap
28+ apply = ap
2929
3030instance applicativeMTrace :: Applicative MTrace where
3131 pure = MTrace <<< return
@@ -36,6 +36,6 @@ instance bindMTrace :: Bind MTrace where
3636instance monadMTrace :: Monad MTrace
3737
3838instance writerMTrace :: MonadWriter String MTrace where
39− tell s = MTrace (trace s)
39+ tell s = MTrace (log s)
4040
4141main = runMTrace $ test "Done"
examples/passing/TCOCase.purs+1−1
@@ -4,7 +4,7 @@ import Prelude
44
55data Data = One | More Data
66
7−main = Debug.Trace.trace (from (to 10000.0 One))
7+main = Control.Monad.Eff.Console.log (from (to 10000.0 One))
88 where
99 to 0.0 a = a
1010 to n a = to (n - 1.0) (More a)
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 = Debug.Trace.print (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N))))
17+main = Control.Monad.Eff.Console.print (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N))))
examples/passing/Tick.purs+1−1
@@ -4,4 +4,4 @@ import Prelude
44
55test' x = x
66
7−main = Debug.Trace.trace "Done"
7+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TopLevelCase.purs+3−3
@@ -5,8 +5,8 @@ import Prelude
55gcd :: Number -> Number -> Number
66gcd 0.0 x = x
77gcd x 0.0 = x
8−gcd x y | x > y = gcd (x % y) y
9−gcd x y = gcd (y % x) x
8+gcd x y | x > y = gcd (x `mod` y) y
9+gcd x y = gcd (y `mod` x) x
1010
1111guardsTest [x] | x > 0.0 = []
1212guardsTest xs = xs
@@ -15,4 +15,4 @@ data A = A
1515
1616parseTest A 0.0 = 0.0
1717
18−main = Debug.Trace.trace "Done"
18+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypeClassMemberOrderChange.purs+1−1
@@ -10,4 +10,4 @@ instance testBoolean :: Test Boolean where
1010 val = true
1111 fn x y = y
1212
13−main = Debug.Trace.trace (show (fn true val))
13+main = Control.Monad.Eff.Console.log (show (fn true val))
examples/passing/TypeClasses.purs+5−5
@@ -22,10 +22,10 @@ instance showData :: (Prelude.Show a) => Prelude.Show (Data a) where
2222test3 = \_ -> show (Data "testing")
2323
2424instance functorData :: Functor Data where
25− (<$>) = liftM1
25+ map = liftM1
2626
2727instance applyData :: Apply Data where
28− (<*>) = ap
28+ apply = ap
2929
3030instance applicativeData :: Applicative Data where
3131 pure = Data
@@ -38,10 +38,10 @@ instance monadData :: Monad Data
3838data Maybe a = Nothing | Just a
3939
4040instance functorMaybe :: Functor Maybe where
41− (<$>) = liftM1
41+ map = liftM1
4242
4343instance applyMaybe :: Apply Maybe where
44− (<*>) = ap
44+ apply = ap
4545
4646instance applicativeMaybe :: Applicative Maybe where
4747 pure = Just
@@ -65,5 +65,5 @@ test9 _ = runReader 0.0 $ do
6565 n <- ask
6666 return $ n + 1.0
6767
68−main = Debug.Trace.trace (test7 "Done")
68+main = Control.Monad.Eff.Console.log (test7 "Done")
6969
examples/passing/TypeClassesInOrder.purs+1−1
@@ -8,4 +8,4 @@ class Foo a where
88instance fooString :: Foo String where
99 foo s = s
1010
11−main = Debug.Trace.trace $ foo "Done"
11+main = Control.Monad.Eff.Console.log $ foo "Done"
examples/passing/TypeClassesWithOverlappingTypeVariables.purs+3−3
@@ -5,7 +5,7 @@ import Prelude
55data Either a b = Left a | Right b
66
77instance functorEither :: Prelude.Functor (Either a) where
8− (<$>) _ (Left x) = Left x
9− (<$>) f (Right y) = Right (f y)
8+ map _ (Left x) = Left x
9+ map f (Right y) = Right (f y)
1010
11−main = Debug.Trace.trace "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypeDecl.purs+1−1
@@ -9,4 +9,4 @@ iterate :: forall a. Number -> (a -> a) -> a -> a
99iterate 0.0 f a = a
1010iterate n f a = iterate (n - 1.0) f (f a)
1111
12−main = Debug.Trace.trace "Done"
12+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypeSynonymInData.purs+1−1
@@ -8,4 +8,4 @@ data Foo a = Foo (A a) | Bar
88
99foo (Foo []) = Bar
1010
11−main = Debug.Trace.trace "Done"
11+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypeSynonyms.purs+1−1
@@ -24,4 +24,4 @@ fst =
2424test1 :: forall a b c. Lens (Pair (Pair a b) c) a
2525test1 = composeLenses fst fst
2626
27−main = Debug.Trace.trace "Done"
27+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypeWildcards.purs+1−1
@@ -12,4 +12,4 @@ test f a = go (f a) a
1212 go a1 a2 | a1 == a2 = a1
1313 go a1 _ = go (f a1) a1
1414
15−main = Debug.Trace.trace "Done"
15+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypeWildcardsRecordExtension.purs+1−1
@@ -5,4 +5,4 @@ import Prelude
55foo :: forall a. {b :: Number | a} -> {b :: Number | _}
66foo f = f
77
8−main = Debug.Trace.trace "Done"
8+main = Control.Monad.Eff.Console.log "Done"
examples/passing/TypedWhere.purs+1−1
@@ -14,4 +14,4 @@ lefts = go N
1414 go ls (C (L a) rest) = go (C a ls) rest
1515 go ls (C _ rest) = go ls rest
1616
17−main = Debug.Trace.trace "Done"
17+main = Control.Monad.Eff.Console.log "Done"
examples/passing/UnderscoreIdent.purs+1−1
@@ -8,4 +8,4 @@ type Type_name = Data_type
88
99done (Con_2 s) = s
1010
11−main = Debug.Trace.trace (done (Con_2 "Done"))
11+main = Control.Monad.Eff.Console.log (done (Con_2 "Done"))
examples/passing/Unit.purs+1−1
@@ -1,6 +1,6 @@
11module Main where
22
33import Prelude
4−import Debug.Trace
4+import Control.Monad.Eff.Console
55
66main = print (const unit $ "Hello world")
examples/passing/UnknownInTypeClassLookup.purs+1−1
@@ -11,4 +11,4 @@ test _ _ = "Done"
1111
1212runTest a = test a a
1313
14−main = Debug.Trace.trace $ runTest 0.0
14+main = Control.Monad.Eff.Console.log $ runTest 0.0
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− Debug.Trace.print (test1 1.0)
44− Debug.Trace.print (test2 1.0 2.0)
45− Debug.Trace.print test3
46− Debug.Trace.print test4
47− Debug.Trace.print test5
48− Debug.Trace.print test6
49− Debug.Trace.print (test7 100.0)
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)
examples/passing/iota.purs+1−1
@@ -6,4 +6,4 @@ k = \x -> \y -> x
66
77iota = \x -> x s k
88
9−main = Debug.Trace.trace "Done"
9+main = Control.Monad.Eff.Console.log "Done"
examples/passing/s.purs+1−1
@@ -4,4 +4,4 @@ import Prelude
44
55s = \x y z -> x z (y z)
66
7−main = Debug.Trace.trace "Done"
7+main = Control.Monad.Eff.Console.log "Done"
purescript.cabal+4−3
@@ -20,8 +20,8 @@ tested-with: GHC==7.8
2020
2121extra-source-files: examples/passing/*.purs
2222 , examples/failing/*.purs
23− , tests/prelude/*.purs
24− , tests/prelude/js/*.js
23+ , tests/support/*.purs
24+ , tests/support/*.js
2525
2626source-repository head
2727 type: git
@@ -236,7 +236,8 @@ executable psc-bundle
236236test-suite tests
237237 build-depends: base >=4 && <5, containers -any, directory -any,
238238 filepath -any, mtl -any, parsec -any, purescript -any,
239− transformers -any, process -any, transformers-compat -any, time -any
239+ transformers -any, process -any, transformers-compat -any, time -any,
240+ Glob -any
240241 type: exitcode-stdio-1.0
241242 main-is: Main.hs
242243 buildable: True
tests/Main.hs+65−17
@@ -44,6 +44,7 @@ import System.Exit
4444import System.Process
4545import System.FilePath
4646import System.Directory
47+import qualified System.FilePath.Glob as Glob
4748
4849import Text.Parsec (ParseError)
4950
@@ -61,18 +62,10 @@ makeActions foreigns = P.MakeActions getInputTimestamp getOutputTimestamp readEx
6162 where
6263 getInputTimestamp :: P.ModuleName -> Test (Either P.RebuildPolicy (Maybe UTCTime))
6364 getInputTimestamp mn
64− | isPreludeModule (P.runModuleName mn) = return (Left P.RebuildNever)
65+ | isSupportModule (P.runModuleName mn) = return (Left P.RebuildNever)
6566 | otherwise = return (Left P.RebuildAlways)
6667 where
67− isPreludeModule = flip elem
68− [ "Prelude.Unsafe"
69− , "Prelude"
70− , "Data.Function"
71− , "Control.Monad.Eff"
72− , "Control.Monad.ST"
73− , "Debug.Trace"
74− , "Assert"
75− ]
68+ isSupportModule = flip elem supportModules
7669
7770 getOutputTimestamp :: P.ModuleName -> Test (Maybe UTCTime)
7871 getOutputTimestamp mn = do
@@ -168,19 +161,74 @@ main :: IO ()
168161main = do
169162 cwd <- getCurrentDirectory
170163
171− let preludeDir = cwd </> "tests" </> "prelude"
172− preludePurs = preludeDir </> "Prelude.purs"
173− jsDir = preludeDir </> "js"
174− jsFiles <- map (jsDir </>) . filter (".js" `isSuffixOf`) <$> getDirectoryContents jsDir
175− foreignFiles <- forM jsFiles (\f -> (f,) <$> readFile f)
164+ let supportDir = cwd </> "tests" </> "support" </> "flattened"
165+ let supportFiles ext = Glob.globDir1 (Glob.compile ("*." ++ ext)) supportDir
166+
167+ supportPurs <- supportFiles "purs"
168+ supportJS <- supportFiles "js"
169+
170+ foreignFiles <- forM supportJS (\f -> (f,) <$> readFile f)
176171 Right (foreigns, _) <- runExceptT $ runWriterT $ P.parseForeignModulesFromFiles foreignFiles
177172
178173 let passing = cwd </> "examples" </> "passing"
179174 passingTestCases <- getDirectoryContents passing
180175 forM_ passingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $
181− assertCompiles [preludePurs, passing </> inputFile] foreigns
176+ assertCompiles (supportPurs ++ [passing </> inputFile]) foreigns
182177 let failing = cwd </> "examples" </> "failing"
183178 failingTestCases <- getDirectoryContents failing
184179 forM_ failingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $
185− assertDoesNotCompile [preludePurs, failing </> inputFile] foreigns
180+ assertDoesNotCompile (supportPurs ++ [failing </> inputFile]) foreigns
186181 exitSuccess
182+
183+supportModules :: [String]
184+supportModules =
185+ [ "Control.Alternative"
186+ , "Control.Alt"
187+ , "Control.Apply"
188+ , "Control.Biapplicative"
189+ , "Control.Biapply"
190+ , "Control.Bind"
191+ , "Control.Comonad"
192+ , "Control.Extend"
193+ , "Control.Lazy"
194+ , "Control.Monad.Eff.Class"
195+ , "Control.Monad.Eff.Console"
196+ , "Control.Monad.Eff"
197+ , "Control.Monad.Eff.Unsafe"
198+ , "Control.MonadPlus"
199+ , "Control.Monad"
200+ , "Control.Monad.ST"
201+ , "Control.Plus"
202+ , "Data.Array"
203+ , "Data.Array.ST"
204+ , "Data.Array.Unsafe"
205+ , "Data.Bifoldable"
206+ , "Data.Bifunctor.Clown"
207+ , "Data.Bifunctor.Flip"
208+ , "Data.Bifunctor.Join"
209+ , "Data.Bifunctor.Joker"
210+ , "Data.Bifunctor.Product"
211+ , "Data.Bifunctor"
212+ , "Data.Bifunctor.Wrap"
213+ , "Data.Bitraversable"
214+ , "Data.Foldable"
215+ , "Data.Function"
216+ , "Data.Functor.Invariant"
217+ , "Data.Functor"
218+ , "Data.Maybe.First"
219+ , "Data.Maybe.Last"
220+ , "Data.Maybe"
221+ , "Data.Maybe.Unsafe"
222+ , "Data.Monoid.Additive"
223+ , "Data.Monoid.Conj"
224+ , "Data.Monoid.Disj"
225+ , "Data.Monoid.Dual"
226+ , "Data.Monoid.Endo"
227+ , "Data.Monoid.Multiplicative"
228+ , "Data.Monoid"
229+ , "Data.Traversable"
230+ , "Data.Tuple.Nested"
231+ , "Data.Tuple"
232+ , "Prelude"
233+ , "Test.Assert"
234+ ]
tests/prelude/Prelude.pursdeleted−631
@@ -1,631 +0,0 @@
1−-- | This snapshot is provided for the purposes of running the test suite.
2−-- | It is not necessarily kept up to date with the official PureScript Prelude,
3−-- | and should not be used in user code.
4−-- | The official Prelude can be found at https://github.com/purescript/purescript-prelude
5−
6−module Prelude
7− ( Unit(..), unit
8− , ($), (#)
9− , length
10− , flip
11− , const
12− , asTypeOf
13− , otherwise
14− , (:), cons, concat
15− , Semigroupoid, (<<<), (>>>)
16− , Category, id
17− , Functor, (<$>), (<#>), void
18− , Apply, (<*>)
19− , Applicative, pure, liftA1
20− , Bind, bind, (>>=)
21− , Monad, return, liftM1, ap
22− , Semigroup, (<>), (++)
23− , Semiring, (+), zero, (*), one
24− , ModuloSemiring, (/), mod, jsMod, (%)
25− , Ring, (-), negate
26− , Num
27− , DivisionRing
28− , Eq, (==), (/=)
29− , Ordering(..), Ord, compare, (<), (>), (<=), (>=)
30− , Bounded, top, bottom
31− , Lattice, sup, inf, (||), (&&)
32− , BoundedLattice
33− , ComplementedLattice, not
34− , DistributiveLattice
35− , BooleanAlgebra
36− , Show, show
37− ) where
38−
39− newtype Unit = Unit {}
40−
41− unit :: Unit
42− unit = Unit {}
43−
44− foreign import length :: forall a. Array a -> Number
45−
46− infixr 0 $
47− infixl 0 #
48−
49− ($) :: forall a b. (a -> b) -> a -> b
50− ($) f x = f x
51−
52− (#) :: forall a b. a -> (a -> b) -> b
53− (#) x f = f x
54−
55− flip :: forall a b c. (a -> b -> c) -> b -> a -> c
56− flip f b a = f a b
57−
58− const :: forall a b. a -> b -> a
59− const a _ = a
60−
61− asTypeOf :: forall a. a -> a -> a
62− asTypeOf x _ = x
63−
64− otherwise :: Boolean
65− otherwise = true
66−
67− foreign import cons :: forall a. a -> Array a -> Array a
68−
69− infixr 6 :
70−
71− (:) :: forall a. a -> Array a -> Array a
72− (:) = cons
73−
74− foreign import concat :: forall a. Array a -> Array a -> Array a
75−
76− infixr 9 >>>
77− infixr 9 <<<
78−
79− class Semigroupoid a where
80− (<<<) :: forall b c d. a c d -> a b c -> a b d
81−
82− instance semigroupoidArr :: Semigroupoid (->) where
83− (<<<) f g x = f (g x)
84−
85− (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
86− (>>>) f g = g <<< f
87−
88− class (Semigroupoid a) <= Category a where
89− id :: forall t. a t t
90−
91− instance categoryArr :: Category (->) where
92− id x = x
93−
94− infixl 4 <$>
95− infixl 1 <#>
96−
97− class Functor f where
98− (<$>) :: forall a b. (a -> b) -> f a -> f b
99−
100− instance functorArr :: Functor ((->) r) where
101− (<$>) = (<<<)
102−
103− (<#>) :: forall f a b. (Functor f) => f a -> (a -> b) -> f b
104− (<#>) fa f = f <$> fa
105−
106− void :: forall f a. (Functor f) => f a -> f Unit
107− void fa = const unit <$> fa
108−
109− infixl 4 <*>
110−
111− class (Functor f) <= Apply f where
112− (<*>) :: forall a b. f (a -> b) -> f a -> f b
113−
114− instance applyArr :: Apply ((->) r) where
115− (<*>) f g x = f x (g x)
116−
117− class (Apply f) <= Applicative f where
118− pure :: forall a. a -> f a
119−
120− instance applicativeArr :: Applicative ((->) r) where
121− pure = const
122−
123− return :: forall m a. (Applicative m) => a -> m a
124− return = pure
125−
126− liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b
127− liftA1 f a = pure f <*> a
128−
129− infixl 1 >>=
130−
131− (>>=) :: forall m a b. (Bind m) => m a -> (a -> m b) -> m b
132− (>>=) = bind
133−
134− class (Apply m) <= Bind m where
135− bind :: forall a b. m a -> (a -> m b) -> m b
136−
137− instance bindArr :: Bind ((->) r) where
138− bind m f x = f (m x) x
139−
140− class (Applicative m, Bind m) <= Monad m
141−
142− instance monadArr :: Monad ((->) r)
143−
144− liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
145− liftM1 f a = do
146− a' <- a
147− return (f a')
148−
149− ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b
150− ap f a = do
151− f' <- f
152− a' <- a
153− return (f' a')
154−
155− infixr 5 <>
156− infixr 5 ++
157−
158− class Semigroup a where
159− (<>) :: a -> a -> a
160−
161− (++) :: forall s. (Semigroup s) => s -> s -> s
162− (++) = (<>)
163−
164− instance semigroupString :: Semigroup String where
165− (<>) = concatString
166−
167− instance semigroupUnit :: Semigroup Unit where
168− (<>) _ _ = unit
169−
170− instance semigroupArr :: (Semigroup s') => Semigroup (s -> s') where
171− (<>) f g = \x -> f x <> g x
172−
173− instance semigroupOrdering :: Semigroup Ordering where
174− (<>) LT _ = LT
175− (<>) GT _ = GT
176− (<>) EQ y = y
177−
178− foreign import concatString :: String -> String -> String
179−
180− infixl 6 +
181− infixl 7 *
182−
183− class Semiring a where
184− (+) :: a -> a -> a
185− zero :: a
186− (*) :: a -> a -> a
187− one :: a
188−
189− instance semiringNumber :: Semiring Number where
190− (+) = numAdd
191− zero = 0.0
192− (*) = numMul
193− one = 1.0
194−
195− instance semiringUnit :: Semiring Unit where
196− (+) _ _ = unit
197− zero = unit
198− (*) _ _ = unit
199− one = unit
200−
201− infixl 6 -
202−
203− class (Semiring a) <= Ring a where
204− (-) :: a -> a -> a
205−
206− instance ringNumber :: Ring Number where
207− (-) = numSub
208−
209− instance ringUnit :: Ring Unit where
210− (-) _ _ = unit
211−
212− negate :: forall a. (Ring a) => a -> a
213− negate a = zero - a
214−
215− infixl 7 /
216−
217− class (Semiring a) <= ModuloSemiring a where
218− (/) :: a -> a -> a
219− mod :: a -> a -> a
220−
221− instance moduloSemiringNumber :: ModuloSemiring Number where
222− (/) = numDiv
223− mod _ _ = 0.0
224−
225− instance moduloSemiringUnit :: ModuloSemiring Unit where
226− (/) _ _ = unit
227− mod _ _ = unit
228−
229− foreign import jsMod :: Number -> Number -> Number
230−
231− infixl 7 %
232−
233− (%) = jsMod
234−
235− class (Ring a, ModuloSemiring a) <= DivisionRing a
236−
237− instance divisionRingNumber :: DivisionRing Number
238−
239− instance divisionRingUnit :: DivisionRing Unit
240−
241− class (DivisionRing a) <= Num a
242−
243− instance numNumber :: Num Number
244−
245− instance numUnit :: Num Unit
246−
247− foreign import numAdd :: Number -> Number -> Number
248−
249− foreign import numMul :: Number -> Number -> Number
250−
251− foreign import numDiv :: Number -> Number -> Number
252−
253− foreign import numSub :: Number -> Number -> Number
254−
255− infix 4 ==
256− infix 4 /=
257−
258− class Eq a where
259− (==) :: a -> a -> Boolean
260− (/=) :: a -> a -> Boolean
261−
262− instance eqBoolean :: Eq Boolean where
263− (==) = refEq
264− (/=) = refIneq
265−
266− instance eqNumber :: Eq Number where
267− (==) = refEq
268− (/=) = refIneq
269−
270− instance eqInt :: Eq Int where
271− (==) = refEq
272− (/=) = refIneq
273−
274− instance eqChar :: Eq Char where
275− (==) = refEq
276− (/=) = refIneq
277−
278− instance eqString :: Eq String where
279− (==) = refEq
280− (/=) = refIneq
281−
282− instance eqUnit :: Eq Unit where
283− (==) _ _ = true
284− (/=) _ _ = false
285−
286− instance eqArray :: (Eq a) => Eq (Array a) where
287− (==) = eqArrayImpl (==)
288− (/=) xs ys = not (xs == ys)
289−
290− instance eqOrdering :: Eq Ordering where
291− (==) LT LT = true
292− (==) GT GT = true
293− (==) EQ EQ = true
294− (==) _ _ = false
295− (/=) x y = not (x == y)
296−
297− foreign import refEq :: forall a. a -> a -> Boolean
298−
299− foreign import refIneq :: forall a. a -> a -> Boolean
300−
301− foreign import eqArrayImpl :: forall a. (a -> a -> Boolean) -> Array a -> Array a -> Boolean
302−
303− data Ordering = LT | GT | EQ
304−
305− class (Eq a) <= Ord a where
306− compare :: a -> a -> Ordering
307−
308− instance ordBoolean :: Ord Boolean where
309− compare false false = EQ
310− compare false true = LT
311− compare true true = EQ
312− compare true false = GT
313−
314− instance ordNumber :: Ord Number where
315− compare = unsafeCompare
316−
317− instance ordString :: Ord String where
318− compare = unsafeCompare
319−
320− instance ordUnit :: Ord Unit where
321− compare _ _ = EQ
322−
323− instance ordArray :: (Ord a) => Ord (Array a) where
324− compare xs ys = compare 0.0 $ ordArrayImpl (\x y -> case compare x y of
325− EQ -> 0.0
326− LT -> -1.0
327− GT -> 1.0) xs ys
328−
329− foreign import ordArrayImpl :: forall a. (a -> a -> Number) -> Array a -> Array a -> Number
330−
331− instance ordOrdering :: Ord Ordering where
332− compare LT LT = EQ
333− compare EQ EQ = EQ
334− compare GT GT = EQ
335− compare LT _ = LT
336− compare EQ LT = GT
337− compare EQ GT = LT
338− compare GT _ = GT
339−
340− infixl 4 <
341− infixl 4 >
342− infixl 4 <=
343− infixl 4 >=
344−
345− (<) :: forall a. (Ord a) => a -> a -> Boolean
346− (<) a1 a2 = case a1 `compare` a2 of
347− LT -> true
348− _ -> false
349−
350− (>) :: forall a. (Ord a) => a -> a -> Boolean
351− (>) a1 a2 = case a1 `compare` a2 of
352− GT -> true
353− _ -> false
354−
355− (<=) :: forall a. (Ord a) => a -> a -> Boolean
356− (<=) a1 a2 = case a1 `compare` a2 of
357− GT -> false
358− _ -> true
359−
360− (>=) :: forall a. (Ord a) => a -> a -> Boolean
361− (>=) a1 a2 = case a1 `compare` a2 of
362− LT -> false
363− _ -> true
364−
365− unsafeCompare :: forall a. a -> a -> Ordering
366− unsafeCompare = unsafeCompareImpl LT EQ GT
367−
368− foreign import unsafeCompareImpl :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
369−
370− class (Ord a) <= Bounded a where
371− top :: a
372− bottom :: a
373−
374− instance boundedBoolean :: Bounded Boolean where
375− top = true
376− bottom = false
377−
378− instance boundedUnit :: Bounded Unit where
379− top = unit
380− bottom = unit
381−
382− instance boundedOrdering :: Bounded Ordering where
383− top = GT
384− bottom = LT
385−
386− class (Ord a) <= Lattice a where
387− sup :: a -> a -> a
388− inf :: a -> a -> a
389−
390− instance latticeBoolean :: Lattice Boolean where
391− sup = boolOr
392− inf = boolAnd
393−
394− instance latticeUnit :: Lattice Unit where
395− sup _ _ = unit
396− inf _ _ = unit
397−
398− infixr 2 ||
399− infixr 3 &&
400−
401− (||) :: forall a. (Lattice a) => a -> a -> a
402− (||) = sup
403−
404− (&&) :: forall a. (Lattice a) => a -> a -> a
405− (&&) = inf
406−
407− class (Bounded a, Lattice a) <= BoundedLattice a
408−
409− instance boundedLatticeBoolean :: BoundedLattice Boolean
410−
411− instance boundedLatticeUnit :: BoundedLattice Unit
412−
413− class (BoundedLattice a) <= ComplementedLattice a where
414− not :: a -> a
415−
416− instance complementedLatticeBoolean :: ComplementedLattice Boolean where
417− not = boolNot
418−
419− instance complementedLatticeUnit :: ComplementedLattice Unit where
420− not _ = unit
421−
422− class (Lattice a) <= DistributiveLattice a
423−
424− instance distributiveLatticeBoolean :: DistributiveLattice Boolean
425−
426− instance distributiveLatticeUnit :: DistributiveLattice Unit
427−
428− class (ComplementedLattice a, DistributiveLattice a) <= BooleanAlgebra a
429−
430− instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
431−
432− instance booleanAlgebraUnit :: BooleanAlgebra Unit
433−
434− foreign import boolOr :: Boolean -> Boolean -> Boolean
435−
436− foreign import boolAnd :: Boolean -> Boolean -> Boolean
437−
438− foreign import boolNot :: Boolean -> Boolean
439−
440− class Show a where
441− show :: a -> String
442−
443− instance showBoolean :: Show Boolean where
444− show true = "true"
445− show false = "false"
446−
447− instance showNumber :: Show Number where
448− show = showNumberImpl
449−
450− instance showString :: Show String where
451− show = showStringImpl
452−
453− instance showUnit :: Show Unit where
454− show _ = "unit"
455−
456− instance showArray :: (Show a) => Show (Array a) where
457− show = showArrayImpl show
458−
459− instance showOrdering :: Show Ordering where
460− show LT = "LT"
461− show GT = "GT"
462− show EQ = "EQ"
463−
464− foreign import showNumberImpl :: Number -> String
465−
466− foreign import showStringImpl :: String -> String
467−
468− foreign import showArrayImpl :: forall a. (a -> String) -> Array a -> String
469−
470−module Data.Function where
471−
472− import Prelude
473−
474− on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
475− on f g x y = g x `f` g y
476−
477− foreign import data Fn0 :: * -> *
478−
479− foreign import data Fn1 :: * -> * -> *
480−
481− foreign import data Fn2 :: * -> * -> * -> *
482−
483− foreign import data Fn3 :: * -> * -> * -> * -> *
484−
485− foreign import data Fn4 :: * -> * -> * -> * -> * -> *
486−
487− foreign import data Fn5 :: * -> * -> * -> * -> * -> * -> *
488−
489− foreign import data Fn6 :: * -> * -> * -> * -> * -> * -> * -> *
490−
491− foreign import data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> *
492−
493− foreign import data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> *
494−
495− foreign import data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
496−
497− foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
498−
499− foreign import mkFn0 :: forall a. (Unit -> a) -> Fn0 a
500−
501− foreign import mkFn1 :: forall a b. (a -> b) -> Fn1 a b
502−
503− foreign import mkFn2 :: forall a b c. (a -> b -> c) -> Fn2 a b c
504−
505− foreign import mkFn3 :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
506−
507− foreign import mkFn4 :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
508−
509− foreign import mkFn5 :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
510−
511− 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
512−
513− 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
514−
515− 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
516−
517− 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
518−
519− 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
520−
521− foreign import runFn0 :: forall a. Fn0 a -> a
522−
523− foreign import runFn1 :: forall a b. Fn1 a b -> a -> b
524−
525− foreign import runFn2 :: forall a b c. Fn2 a b c -> a -> b -> c
526−
527− foreign import runFn3 :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
528−
529− foreign import runFn4 :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
530−
531− foreign import runFn5 :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
532−
533− 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
534−
535− 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
536−
537− 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
538−
539− 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
540−
541− 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
542−
543−module Assert where
544−
545− import Prelude
546− import Control.Monad.Eff
547−
548− foreign import data Assert :: !
549−
550− foreign import error :: forall a. String -> a
551−
552− foreign import assertPartial :: forall e a. (Unit -> a) -> Eff (assert :: Assert | e) Unit
553−
554− assert :: forall e. Boolean -> Eff (assert :: Assert | e) Unit
555− assert true = return unit
556− assert false = error "Assertion failed!"
557−
558−module Prelude.Unsafe where
559−
560− foreign import unsafeIndex :: forall a. Array a -> Number -> a
561−
562−module Control.Monad.Eff
563− ( Eff()
564− , Pure()
565− , runPure
566− , untilE, whileE
567− ) where
568−
569− import Prelude
570−
571− foreign import data Eff :: # ! -> * -> *
572−
573− foreign import returnE :: forall e a. a -> Eff e a
574−
575− foreign import bindE :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
576−
577− type Pure a = forall e. Eff e a
578−
579− foreign import runPure :: forall a. Pure a -> a
580−
581− instance functorEff :: Functor (Eff e) where
582− (<$>) = liftA1
583−
584− instance applyEff :: Apply (Eff e) where
585− (<*>) = ap
586−
587− instance applicativeEff :: Applicative (Eff e) where
588− pure = returnE
589−
590− instance bindEff :: Bind (Eff e) where
591− bind = bindE
592−
593− instance monadEff :: Monad (Eff e)
594−
595− foreign import untilE :: forall e. Eff e Boolean -> Eff e Unit
596−
597− foreign import whileE :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
598−
599−module Debug.Trace where
600−
601− import Prelude
602− import Control.Monad.Eff
603−
604− foreign import data Trace :: !
605−
606− foreign import trace :: forall r. String -> Eff (trace :: Trace | r) Unit
607−
608− print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
609− print o = trace (show o)
610−
611−module Control.Monad.ST where
612−
613− import Prelude
614− import Control.Monad.Eff
615−
616− foreign import data ST :: * -> !
617−
618− foreign import data STRef :: * -> * -> *
619−
620− foreign import newSTRef :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
621−
622− foreign import readSTRef :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
623−
624− foreign import modifySTRef :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
625−
626− foreign import writeSTRef :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
627−
628− foreign import runST :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
629−
630− pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
631− pureST st = runPure (runST st)
tests/prelude/js/Assert.jsdeleted−19
@@ -1,19 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Assert
5−
6−exports.error = function(msg) {
7− throw msg;
8−};
9−
10−exports.assertPartial = function(f) {
11− return function() {
12− try {
13− return f();
14− } catch (e) {
15− if (e instanceof Error) return;
16− throw new Error('Pattern match failure is not Error');
17− }
18− };
19−};
tests/prelude/js/Debug.Trace.jsdeleted−11
@@ -1,11 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Debug.Trace
5−
6−exports.trace = function(s) {
7− return function() {
8− console.log(s);
9− return {};
10− };
11−};
tests/prelude/js/Prelude.Unsafe.jsdeleted−10
@@ -1,10 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Prelude.Unsafe
5−
6−exports.unsafeIndex = function(xs) {
7− return function(n) {
8− return xs[n];
9− };
10−};
tests/prelude/js/Prelude.jsdeleted−150
@@ -1,150 +0,0 @@
1−/* global exports */
2−"use strict";
3−
4−// module Prelude
5−
6−exports.cons = function(e) {
7− return function(l) {
8− return [e].concat(l);
9− };
10−};
11−
12−exports.concat = function(l1) {
13− return function(l2) {
14− return l1.concat(l2);
15− };
16−};
17−
18−exports.length = function(a) {
19− return a.length;
20−};
21−
22−exports.concatString = function(s1) {
23− return function(s2) {
24− return s1 + s2;
25− };
26−};
27−
28−exports.numAdd = function (n1) {
29− return function (n2) {
30− return n1 + n2;
31− };
32−};
33−
34−exports.numMul = function (n1) {
35− return function (n2) {
36− return n1 * n2;
37− };
38−};
39−
40−exports.numDiv = function (n1) {
41− return function (n2) {
42− return n1 / n2;
43− };
44−};
45−
46−exports.numSub = function (n1) {
47− return function (n2) {
48− return n1 - n2;
49− };
50−};
51−
52−exports.jsMod = function(x) {
53− return function (y) {
54− return x % y;
55− };
56−};
57−
58−exports.refEq = function(r1) {
59− return function(r2) {
60− return r1 === r2;
61− };
62−};
63−
64−exports.refIneq = function(r1) {
65− return function(r2) {
66− return r1 !== r2;
67− };
68−};
69−
70−exports.eqArrayImpl = function(f) {
71− return function(xs) {
72− return function(ys) {
73− if (xs.length !== ys.length) return false;
74− for (var i = 0; i < xs.length; i++) {
75− if (!f(xs[i])(ys[i])) return false;
76− }
77− return true;
78− };
79− };
80−};
81−
82−exports.ordArrayImpl = function(f) {
83− return function (xs) {
84− return function (ys) {
85− var i = 0;
86− while (i < xs.length && i < ys.length) {
87− var x = xs[i];
88− var y = ys[i];
89− var o = f(x)(y);
90− if (o !== 0) {
91− return o;
92− }
93− }
94− if (xs.length == ys.length) {
95− return 0;
96− } else if (xs.length > ys.length) {
97− return 1;
98− } else {
99− return -1;
100− }
101− };
102− };
103−};
104−
105−exports.unsafeCompareImpl = function(lt) {
106− return function(eq) {
107− return function(gt) {
108− return function(x) {
109− return function(y) {
110− return x < y ? lt : x > y ? gt : eq;
111− };
112− };
113− };
114− };
115−};
116−
117−exports.boolOr = function (b1) {
118− return function (b2) {
119− return b1 || b2;
120− };
121−};
122−
123−exports.boolAnd = function (b1) {
124− return function (b2) {
125− return b1 && b2;
126− };
127−};
128−
129−exports.boolNot = function (b) {
130− return !b;
131−};
132−
133−exports.showNumberImpl = function (n) {
134− /* jshint bitwise: false */
135− return n === (n | 0) ? n + ".0" : n.toString();
136−};
137−
138−exports.showStringImpl = function (s) {
139− return JSON.stringify(s);
140−};
141−
142−exports.showArrayImpl = function (f) {
143− return function (xs) {
144− var ss = [];
145− for (var i = 0, l = xs.length; i < l; i++) {
146− ss[i] = f(xs[i]);
147− }
148− return "[" + ss.join(",") + "]";
149− };
150−};
tests/support/.gitignorenew file+2
@@ -0,0 +1,2 @@
1+node_modules/
2+bower_components/
tests/support/bower.jsonnew file+11
@@ -0,0 +1,11 @@
1+{
2+ "name": "purescript-test-suite-support",
3+ "dependencies": {
4+ "purescript-eff": "0.1.0",
5+ "purescript-prelude": "0.1.1",
6+ "purescript-assert": "https://github.com/hdgarrood/purescript-assert.git#2f166394176548e19e0ddc72d4ff620036aec931",
7+ "purescript-st": "0.1.0",
8+ "purescript-console": "0.1.0",
9+ "purescript-functions": "0.1.0"
10+ }
11+}
tests/support/flattened/Control-Monad-Eff-Class.pursnew file+24
@@ -0,0 +1,24 @@
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.jsnew file+18
@@ -0,0 +1,18 @@
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.pursnew file+18
@@ -0,0 +1,18 @@
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.jsnew file+8
@@ -0,0 +1,8 @@
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.pursnew file+10
@@ -0,0 +1,10 @@
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/prelude/js/Control.Monad.Eff.js → tests/support/flattened/Control-Monad-Eff.jsrenamed+23−1
@@ -37,4 +37,26 @@ exports.whileE = function (f) {
3737 return {};
3838 };
3939 };
40−};
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.pursnew file+67
@@ -0,0 +1,67 @@
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/prelude/js/Control.Monad.ST.js → tests/support/flattened/Control-Monad-ST.jsrenamed+1−1
@@ -35,4 +35,4 @@ exports.writeSTRef = function (ref) {
3535
3636exports.runST = function (f) {
3737 return f;
38−};
38+};
tests/support/flattened/Control-Monad-ST.pursnew file+42
@@ -0,0 +1,42 @@
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/prelude/js/Data.Function.js → tests/support/flattened/Data-Function.jsrenamed+1−1
@@ -230,4 +230,4 @@ exports.runFn10 = function (fn) {
230230 };
231231 };
232232 };
233−};
233+};
tests/support/flattened/Data-Function.pursnew file+113
@@ -0,0 +1,113 @@
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.jsnew file+222
@@ -0,0 +1,222 @@
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+//- Lattice --------------------------------------------------------------------
176+
177+exports.boolOr = function (b1) {
178+ return function (b2) {
179+ return b1 || b2;
180+ };
181+};
182+
183+exports.boolAnd = function (b1) {
184+ return function (b2) {
185+ return b1 && b2;
186+ };
187+};
188+
189+//- ComplementedLattice --------------------------------------------------------
190+
191+exports.boolNot = function (b) {
192+ return !b;
193+};
194+
195+//- Show -----------------------------------------------------------------------
196+
197+exports.showIntImpl = function (n) {
198+ return n.toString();
199+};
200+
201+exports.showNumberImpl = function (n) {
202+ /* jshint bitwise: false */
203+ return n === (n | 0) ? n + ".0" : n.toString();
204+};
205+
206+exports.showCharImpl = function (c) {
207+ return c === "'" ? "'\\''" : "'" + c + "'";
208+};
209+
210+exports.showStringImpl = function (s) {
211+ return JSON.stringify(s);
212+};
213+
214+exports.showArrayImpl = function (f) {
215+ return function (xs) {
216+ var ss = [];
217+ for (var i = 0, l = xs.length; i < l; i++) {
218+ ss[i] = f(xs[i]);
219+ }
220+ return "[" + ss.join(",") + "]";
221+ };
222+};
tests/support/flattened/Prelude.pursnew file+860
@@ -0,0 +1,860 @@
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 = 2147483647
738+ bottom = -2147483648
739+
740+instance boundedFn :: (Bounded b) => Bounded (a -> b) where
741+ top _ = top
742+ bottom _ = bottom
743+
744+-- | The `BoundedOrd` type class represents totally ordered finite data types.
745+-- |
746+-- | Instances should satisfy the following law in addition to the `Ord` laws:
747+-- |
748+-- | - Ordering: `bottom <= a <= top`
749+class (Bounded a, Ord a) <= BoundedOrd a
750+
751+instance boundedOrdBoolean :: BoundedOrd Boolean where
752+instance boundedOrdUnit :: BoundedOrd Unit where
753+instance boundedOrdOrdering :: BoundedOrd Ordering where
754+instance boundedOrdInt :: BoundedOrd Int where
755+
756+-- | The `BooleanAlgebra` type class represents types that behave like boolean
757+-- | values.
758+-- |
759+-- | Instances should satisfy the following laws in addition to the `Bounded`
760+-- | laws:
761+-- |
762+-- | - Associativity:
763+-- | - `a || (b || c) = (a || b) || c`
764+-- | - `a && (b && c) = (a && b) && c`
765+-- | - Commutativity:
766+-- | - `a || b = b || a`
767+-- | - `a && b = b && a`
768+-- | - Distributivity:
769+-- | - `a && (b || c) = (a && b) || (a && c)`
770+-- | - `a || (b && c) = (a || b) && (a || c)`
771+-- | - Identity:
772+-- | - `a || bottom = a`
773+-- | - `a && top = a`
774+-- | - Idempotent:
775+-- | - `a || a = a`
776+-- | - `a && a = a`
777+-- | - Absorption:
778+-- | - `a || (a && b) = a`
779+-- | - `a && (a || b) = a`
780+-- | - Annhiliation:
781+-- | - `a || top = top`
782+-- | - Complementation:
783+-- | - `a && not a = bottom`
784+-- | - `a || not a = top`
785+class (Bounded a) <= BooleanAlgebra a where
786+ conj :: a -> a -> a
787+ disj :: a -> a -> a
788+ not :: a -> a
789+
790+instance booleanAlgebraBoolean :: BooleanAlgebra Boolean where
791+ conj = boolAnd
792+ disj = boolOr
793+ not = boolNot
794+
795+instance booleanAlgebraUnit :: BooleanAlgebra Unit where
796+ conj _ _ = unit
797+ disj _ _ = unit
798+ not _ = unit
799+
800+instance booleanAlgebraFn :: (BooleanAlgebra b) => BooleanAlgebra (a -> b) where
801+ conj fx fy a = fx a `conj` fy a
802+ disj fx fy a = fx a `disj` fy a
803+ not fx a = not (fx a)
804+
805+infixr 3 &&
806+infixr 2 ||
807+
808+-- | `(&&)` is an alias for `conj`.
809+(&&) :: forall a. (BooleanAlgebra a) => a -> a -> a
810+(&&) = conj
811+
812+-- | `(||)` is an alias for `disj`.
813+(||) :: forall a. (BooleanAlgebra a) => a -> a -> a
814+(||) = disj
815+
816+foreign import boolOr :: Boolean -> Boolean -> Boolean
817+foreign import boolAnd :: Boolean -> Boolean -> Boolean
818+foreign import boolNot :: Boolean -> Boolean
819+
820+-- | The `Show` type class represents those types which can be converted into
821+-- | a human-readable `String` representation.
822+-- |
823+-- | While not required, it is recommended that for any expression `x`, the
824+-- | string `show x` be executable PureScript code which evaluates to the same
825+-- | value as the expression `x`.
826+class Show a where
827+ show :: a -> String
828+
829+instance showBoolean :: Show Boolean where
830+ show true = "true"
831+ show false = "false"
832+
833+instance showInt :: Show Int where
834+ show = showIntImpl
835+
836+instance showNumber :: Show Number where
837+ show = showNumberImpl
838+
839+instance showChar :: Show Char where
840+ show = showCharImpl
841+
842+instance showString :: Show String where
843+ show = showStringImpl
844+
845+instance showUnit :: Show Unit where
846+ show _ = "unit"
847+
848+instance showArray :: (Show a) => Show (Array a) where
849+ show = showArrayImpl show
850+
851+instance showOrdering :: Show Ordering where
852+ show LT = "LT"
853+ show GT = "GT"
854+ show EQ = "EQ"
855+
856+foreign import showIntImpl :: Int -> String
857+foreign import showNumberImpl :: Number -> String
858+foreign import showCharImpl :: Char -> String
859+foreign import showStringImpl :: String -> String
860+foreign import showArrayImpl :: forall a. (a -> String) -> Array a -> String
tests/support/flattened/Test-Assert.jsnew file+27
@@ -0,0 +1,27 @@
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.pursnew file+32
@@ -0,0 +1,32 @@
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+assertThrows :: forall e a. (Unit -> a) -> Eff (assert :: ASSERT | e) Unit
25+assertThrows = assertThrows' "Assertion failed: An error should have been thrown"
26+
27+assertThrows' :: forall e a. String -> (Unit -> a) -> Eff (assert :: ASSERT | e) Unit
28+assertThrows' msg fn =
29+ checkThrows fn >>= assert' msg
30+
31+
32+foreign import checkThrows :: forall e a. (Unit -> a) -> Eff (assert :: ASSERT | e) Boolean
tests/support/package.jsonnew file+7
@@ -0,0 +1,7 @@
1+{
2+ "private": true,
3+ "dependencies": {
4+ "bower": "^1.4.1",
5+ "glob": "^5.0.14"
6+ }
7+}
tests/support/setup.jsnew file+13
@@ -0,0 +1,13 @@
1+var glob = require("glob");
2+var fs = require("fs");
3+
4+glob("bower_components/*/src/**/*.{js,purs}", function(err, files) {
5+ if (err) throw err;
6+ files.forEach(function(file) {
7+ // We join with "-" because Cabal is weird about file extensions.
8+ var dest = "./flattened/" + file.split("/").slice(3).join("-");
9+ console.log("Copying " + file + " to " + dest);
10+ var content = fs.readFileSync(file, "utf-8");
11+ fs.writeFileSync(dest, content, "utf-8");
12+ });
13+})