diff --git a/.gitignore b/.gitignore index b0a2561481..53f31d4c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ cabal.sandbox.config bower_components/ tmp/ .stack-work/ +tests/support/flattened/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5d8cdb614..01f971f7f5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,8 +9,8 @@ Please follow the following guidelines: - Add at least a test to `examples/passing/` and possibly to `examples/failing`. - Build the binaries and libs with `cabal build` - Install the binaries and libs with `cabal install`. -- Run `cabal configure --enable-tests && cabal build && cabal test` to build the test suite. -- Build the core libraries by running the script in `core-tests` +- Run `cabal configure --enable-tests && cabal build && cabal test` to build the test suite. You will need `npm`, `node`, and `bower` on your PATH to run the tests. +- Build the core libraries by running the script in `core-tests`. If you would like to contribute, please consider the issues in the current milestone first. If you are a new contributor, you may want to have a go at the ["easy" issues](https://github.com/purescript/purescript/labels/easy) to get started. diff --git a/examples/failing/ArrayType.purs b/examples/failing/ArrayType.purs index 88888aa844..c51530ed87 100644 --- a/examples/failing/ArrayType.purs +++ b/examples/failing/ArrayType.purs @@ -1,7 +1,7 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console bar :: Number -> Number -> Number bar n m = n + m diff --git a/examples/failing/Eff.purs b/examples/failing/Eff.purs index 6fb7174865..281ea1dfd1 100644 --- a/examples/failing/Eff.purs +++ b/examples/failing/Eff.purs @@ -3,10 +3,10 @@ module Main where import Prelude import Control.Monad.Eff import Control.Monad.ST -import Debug.Trace +import Control.Monad.Eff.Console test = pureST (do ref <- newSTRef 0 - trace "ST" + log "ST" modifySTRef ref $ \n -> n + 1 readSTRef ref) diff --git a/examples/failing/ExtraRecordField.purs b/examples/failing/ExtraRecordField.purs new file mode 100644 index 0000000000..e5a3429f8f --- /dev/null +++ b/examples/failing/ExtraRecordField.purs @@ -0,0 +1,9 @@ + +module ExtraRecordField where + +import Prelude ((<>)) + +full :: { first :: String, last :: String } -> String +full p = p.first <> " " <> p.last + +oops = full { first: "Jane", last: "Smith", age: 29 } diff --git a/examples/failing/MissingRecordField.purs b/examples/failing/MissingRecordField.purs new file mode 100644 index 0000000000..1d49d9c3bf --- /dev/null +++ b/examples/failing/MissingRecordField.purs @@ -0,0 +1,10 @@ + +module MissingRecordField where + +import Prelude ((>)) + +john = { first: "John", last: "Smith" } + +isOver50 p = p.age > 50.0 + +result = isOver50 john diff --git a/examples/failing/OverlappingInstances.purs b/examples/failing/OverlappingInstances.purs index aad48b0f46..79443cab7b 100644 --- a/examples/failing/OverlappingInstances.purs +++ b/examples/failing/OverlappingInstances.purs @@ -10,4 +10,4 @@ instance showA1 :: Show A where instance showA2 :: Show A where show A = "Instance 2" -main = Debug.Trace.trace $ show A +main = Control.Monad.Eff.Console.log $ show A diff --git a/examples/failing/OverlappingInstances2.purs b/examples/failing/OverlappingInstances2.purs index bf971ee64b..0cfe929337 100644 --- a/examples/failing/OverlappingInstances2.purs +++ b/examples/failing/OverlappingInstances2.purs @@ -22,4 +22,4 @@ instance ordA :: Ord A where test :: forall a. (Ord a) => a -> a -> String test x y = show $ x == y -main = Debug.Trace.trace $ test A B +main = Control.Monad.Eff.Console.log $ test A B diff --git a/examples/failing/RowConstructors1.purs b/examples/failing/RowConstructors1.purs index ca260db42d..ce014b1c2c 100644 --- a/examples/failing/RowConstructors1.purs +++ b/examples/failing/RowConstructors1.purs @@ -5,4 +5,4 @@ import Prelude data Foo = Bar type Baz = { | Foo } -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/failing/RowConstructors2.purs b/examples/failing/RowConstructors2.purs index d763d6e218..f4ac92a1dc 100644 --- a/examples/failing/RowConstructors2.purs +++ b/examples/failing/RowConstructors2.purs @@ -5,4 +5,4 @@ import Prelude type Foo r = (x :: Number | r) type Bar = { | Foo } -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/failing/RowConstructors3.purs b/examples/failing/RowConstructors3.purs index d5ad0b1f3a..bf998a3510 100644 --- a/examples/failing/RowConstructors3.purs +++ b/examples/failing/RowConstructors3.purs @@ -5,4 +5,4 @@ import Prelude type Foo = { x :: Number } type Bar = { | Foo } -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/failing/UnderscoreModuleName.purs b/examples/failing/UnderscoreModuleName.purs index 2cc71a5d79..eed8bc2a5a 100644 --- a/examples/failing/UnderscoreModuleName.purs +++ b/examples/failing/UnderscoreModuleName.purs @@ -2,4 +2,4 @@ module Bad_Module where import Prelude -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/QualifiedNames.purs b/examples/manual/QualifiedNames.purs index 8d458dbad1..7db54f05d5 100644 --- a/examples/manual/QualifiedNames.purs +++ b/examples/manual/QualifiedNames.purs @@ -10,4 +10,4 @@ either :: forall a b c. (a -> c) -> (b -> c) -> Data.Either.Either a b -> c either f _ (Data.Either.Left x) = f x either _ g (Data.Either.Right y) = g y -main = Debug.Trace.trace (either id id (Data.Either.Left "Done")) +main = Control.Monad.Eff.Console.log (either id id (Data.Either.Left "Done")) diff --git a/examples/manual/failing/ExportExplicit1.purs b/examples/manual/failing/ExportExplicit1.purs index b90797e9c2..6fc9226fa9 100644 --- a/examples/manual/failing/ExportExplicit1.purs +++ b/examples/manual/failing/ExportExplicit1.purs @@ -11,4 +11,4 @@ module Main where -- should fail as Y constructor is not exported from M1 testY = Y - main = Debug.Trace.trace "Done" + main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/failing/ExportExplicit3.purs b/examples/manual/failing/ExportExplicit3.purs index 5161488b59..f991d0d722 100644 --- a/examples/manual/failing/ExportExplicit3.purs +++ b/examples/manual/failing/ExportExplicit3.purs @@ -10,4 +10,4 @@ module Main where -- should fail as Z is not exported from M1 testZ = M1.Z - main = Debug.Trace.trace "Done" + main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/passing/ExportExplicit.purs b/examples/manual/passing/ExportExplicit.purs index 3dfb429b14..245ab353ac 100644 --- a/examples/manual/passing/ExportExplicit.purs +++ b/examples/manual/passing/ExportExplicit.purs @@ -17,4 +17,4 @@ module Main where testZ = Z testFoo = foo - main = Debug.Trace.trace "Done" + main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/passing/ExportExplicit2.purs b/examples/manual/passing/ExportExplicit2.purs index f665044c69..215f165393 100644 --- a/examples/manual/passing/ExportExplicit2.purs +++ b/examples/manual/passing/ExportExplicit2.purs @@ -12,4 +12,4 @@ module Main where testBar = bar - main = Debug.Trace.trace "Done" + main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/passing/Import.purs b/examples/manual/passing/Import.purs index 94369913af..6479e20654 100644 --- a/examples/manual/passing/Import.purs +++ b/examples/manual/passing/Import.purs @@ -16,4 +16,4 @@ module M2 where module Main where -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/passing/ImportExplicit.purs b/examples/manual/passing/ImportExplicit.purs index 05db349f24..4c7525ee49 100644 --- a/examples/manual/passing/ImportExplicit.purs +++ b/examples/manual/passing/ImportExplicit.purs @@ -11,4 +11,4 @@ module Main where testX = X testY = Y - main = Debug.Trace.trace "Done" + main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/passing/ImportQualified.purs b/examples/manual/passing/ImportQualified.purs index 2aa2f4664d..fb4e63118d 100644 --- a/examples/manual/passing/ImportQualified.purs +++ b/examples/manual/passing/ImportQualified.purs @@ -1,12 +1,12 @@ module M1 where - trace x = x + log x = x module Main where import Prelude import Control.Monad.Eff import M1 - import qualified Debug.Trace as T + import qualified Control.Monad.Eff.Console as C - main = T.trace (trace "Done") + main = C.log (log "Done") diff --git a/examples/manual/passing/Module.purs b/examples/manual/passing/Module.purs index 21da681471..a5dcea8f97 100644 --- a/examples/manual/passing/Module.purs +++ b/examples/manual/passing/Module.purs @@ -25,4 +25,4 @@ module M2 where module Main where -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/passing/ModuleDeps.purs b/examples/manual/passing/ModuleDeps.purs index 1178b309f6..afadc77491 100644 --- a/examples/manual/passing/ModuleDeps.purs +++ b/examples/manual/passing/ModuleDeps.purs @@ -14,4 +14,4 @@ baz = 1 module Main where -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/passing/RedefinedFixity.purs b/examples/manual/passing/RedefinedFixity.purs index 769467bebb..9dbe701957 100644 --- a/examples/manual/passing/RedefinedFixity.purs +++ b/examples/manual/passing/RedefinedFixity.purs @@ -21,4 +21,4 @@ import M2 module Main where -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/manual/passing/ShadowedName.purs b/examples/manual/passing/ShadowedName.purs index 7065e8781c..b0ae4d2ed5 100644 --- a/examples/manual/passing/ShadowedName.purs +++ b/examples/manual/passing/ShadowedName.purs @@ -1,10 +1,10 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console done :: String done = let str = "Not yet done" in let str = "Done" in str -main = Debug.Trace.trace done +main = Control.Monad.Eff.Console.log done diff --git a/examples/manual/passing/TransitiveImport.purs b/examples/manual/passing/TransitiveImport.purs index 4267c55e7e..0274cbe250 100644 --- a/examples/manual/passing/TransitiveImport.purs +++ b/examples/manual/passing/TransitiveImport.purs @@ -16,7 +16,7 @@ module Main where import Prelude import Middle - import Debug.Trace + import Control.Monad.Eff.Console main = do print (middle unit) diff --git a/examples/manual/passing/WildcardType.purs b/examples/manual/passing/WildcardType.purs index 15af38843f..557500e9de 100644 --- a/examples/manual/passing/WildcardType.purs +++ b/examples/manual/passing/WildcardType.purs @@ -1,7 +1,7 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console f1 :: (_ -> _) -> _ f1 g = g 1 @@ -9,5 +9,5 @@ f1 g = g 1 f2 :: _ -> _ f2 _ = "Done" -main = Debug.Trace.trace $ f1 f2 +main = Control.Monad.Eff.Console.log $ f1 f2 diff --git a/examples/passing/652.purs b/examples/passing/652.purs index 66443ab7d1..43e49ad981 100644 --- a/examples/passing/652.purs +++ b/examples/passing/652.purs @@ -14,4 +14,4 @@ instance bar :: Bar (a -> b) b instance baz :: (Eq a) => Baz (a -> b) a b -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/810.purs b/examples/passing/810.purs index 2ba3428148..256d2c695e 100644 --- a/examples/passing/810.purs +++ b/examples/passing/810.purs @@ -10,4 +10,4 @@ test m = o.x o = case m of Nothing -> { x : Nothing } Just a -> { x : Just a } -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Applicative.purs b/examples/passing/Applicative.purs index 7c77c7e7ca..fa47117c6a 100644 --- a/examples/passing/Applicative.purs +++ b/examples/passing/Applicative.purs @@ -4,13 +4,13 @@ import Prelude () class Applicative f where pure :: forall a. a -> f a - (<*>) :: forall a b. f (a -> b) -> f a -> f b + apply :: forall a b. f (a -> b) -> f a -> f b data Maybe a = Nothing | Just a instance applicativeMaybe :: Applicative Maybe where pure = Just - (<*>) (Just f) (Just a) = Just (f a) - (<*>) _ _ = Nothing + apply (Just f) (Just a) = Just (f a) + apply _ _ = Nothing -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/ArrayType.purs b/examples/passing/ArrayType.purs index eddf257a9d..889fcd3443 100644 --- a/examples/passing/ArrayType.purs +++ b/examples/passing/ArrayType.purs @@ -8,4 +8,4 @@ class Pointed p where instance pointedArray :: Pointed Array where point a = [a] -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Auto.purs b/examples/passing/Auto.purs index 070d4aaa25..c3500eb6ae 100644 --- a/examples/passing/Auto.purs +++ b/examples/passing/Auto.purs @@ -12,4 +12,4 @@ exists = \state step f -> f (Auto { state: state, step: step }) run :: forall i o. SomeAuto i o -> i -> o run = \s i -> s (\a -> case a of Auto a -> a.step a.state i) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/AutoPrelude.purs b/examples/passing/AutoPrelude.purs index 1f8bcdff96..a69b4853ee 100644 --- a/examples/passing/AutoPrelude.purs +++ b/examples/passing/AutoPrelude.purs @@ -1,9 +1,9 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console f x = x * 10.0 g y = y - 10.0 -main = trace $ show $ (f <<< g) 100.0 +main = log $ show $ (f <<< g) 100.0 diff --git a/examples/passing/AutoPrelude2.purs b/examples/passing/AutoPrelude2.purs index 4a8c51ad48..373c38079b 100644 --- a/examples/passing/AutoPrelude2.purs +++ b/examples/passing/AutoPrelude2.purs @@ -2,9 +2,9 @@ module Main where import Prelude import qualified Prelude as P -import Debug.Trace +import Control.Monad.Eff.Console f :: forall a. a -> a f = P.id -main = P.($) trace ((f P.<<< f) "Done") +main = P.($) log ((f P.<<< f) "Done") diff --git a/examples/passing/BindersInFunctions.purs b/examples/passing/BindersInFunctions.purs index 13acfc5539..d1a504bf06 100644 --- a/examples/passing/BindersInFunctions.purs +++ b/examples/passing/BindersInFunctions.purs @@ -1,12 +1,11 @@ module Main where import Prelude -import Assert +import Test.Assert snd = \[_, y] -> y -main = - let ts = snd [1.0, 2.0] in - if ts == 2.0 - then Debug.Trace.trace "Done" - else error "Incorrect result from 'snd'." +main = do + let ts = snd [1.0, 2.0] + assert' "Incorrect result from 'snd'." (ts == 2.0) + Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/BindingGroups.purs b/examples/passing/BindingGroups.purs index 903579d3fe..fb7ceb2d2e 100644 --- a/examples/passing/BindingGroups.purs +++ b/examples/passing/BindingGroups.purs @@ -7,4 +7,4 @@ foo = bar r = foo 2.0 -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/BlockString.purs b/examples/passing/BlockString.purs index 721612c9a1..23f039e4f3 100644 --- a/examples/passing/BlockString.purs +++ b/examples/passing/BlockString.purs @@ -5,4 +5,4 @@ import Prelude foo :: String foo = """foo""" -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/CaseInDo.purs b/examples/passing/CaseInDo.purs index 844d025c2c..574b69424e 100644 --- a/examples/passing/CaseInDo.purs +++ b/examples/passing/CaseInDo.purs @@ -1,14 +1,14 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console import Control.Monad.Eff doIt :: forall eff. Eff eff Boolean doIt = return true set = do - trace "Testing..." + log "Testing..." case 0 of 0 -> doIt _ -> return false @@ -16,4 +16,4 @@ set = do main = do b <- set case b of - true -> trace "Done" + true -> log "Done" diff --git a/examples/passing/CaseStatement.purs b/examples/passing/CaseStatement.purs index 74b4b931fd..6ed934635e 100644 --- a/examples/passing/CaseStatement.purs +++ b/examples/passing/CaseStatement.purs @@ -18,4 +18,4 @@ h f N a = a h f a N = a h f (J a) (J b) = J (f a b) -main = Debug.Trace.trace $ f "Done" "Failed" A +main = Control.Monad.Eff.Console.log $ f "Done" "Failed" A diff --git a/examples/passing/CheckFunction.purs b/examples/passing/CheckFunction.purs index 6504256ccb..187c5776fc 100644 --- a/examples/passing/CheckFunction.purs +++ b/examples/passing/CheckFunction.purs @@ -4,4 +4,4 @@ import Prelude test = ((\x -> x+1.0) >>> (\x -> x*2.0)) 4.0 -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/CheckSynonymBug.purs b/examples/passing/CheckSynonymBug.purs index 09c6161fc5..3f565c2a02 100644 --- a/examples/passing/CheckSynonymBug.purs +++ b/examples/passing/CheckSynonymBug.purs @@ -2,8 +2,11 @@ module Main where import Prelude +length :: forall a. Array a -> Int +length _ = 0 + type Foo a = Array a foo _ = length ([] :: Foo Number) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/CheckTypeClass.purs b/examples/passing/CheckTypeClass.purs index 45f59ad88e..81e86a1a85 100644 --- a/examples/passing/CheckTypeClass.purs +++ b/examples/passing/CheckTypeClass.purs @@ -14,5 +14,5 @@ foo_ x = foo ((mkBar :: forall a. (Foo a) => a -> Bar a) x) mkBar :: forall a. a -> Bar a mkBar _ = Bar -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Church.purs b/examples/passing/Church.purs index bda8fb721e..fd9cde8bf1 100644 --- a/examples/passing/Church.purs +++ b/examples/passing/Church.purs @@ -15,4 +15,4 @@ append = \l1 l2 r f -> l2 (l1 r f) f test = append (cons 1 empty) (cons 2 empty) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Collatz.purs b/examples/passing/Collatz.purs index 37f51e977e..80a3d1ecca 100644 --- a/examples/passing/Collatz.purs +++ b/examples/passing/Collatz.purs @@ -4,15 +4,15 @@ import Prelude import Control.Monad.Eff import Control.Monad.ST -collatz :: Number -> Number +collatz :: Int -> Int collatz n = runPure (runST (do r <- newSTRef n - count <- newSTRef 0.0 + count <- newSTRef 0 untilE $ do - modifySTRef count $ (+) 1.0 + modifySTRef count $ (+) 1 m <- readSTRef r - writeSTRef r $ if m % 2.0 == 0.0 then m / 2.0 else 3.0 * m + 1.0 - return $ m == 1.0 + writeSTRef r $ if m `mod` 2 == 0 then m / 2 else 3 * m + 1 + return $ m == 1 readSTRef count)) -main = Debug.Trace.print $ collatz 1000.0 +main = Control.Monad.Eff.Console.print $ collatz 1000 diff --git a/examples/passing/Comparisons.purs b/examples/passing/Comparisons.purs index ab353185df..f98dca0505 100644 --- a/examples/passing/Comparisons.purs +++ b/examples/passing/Comparisons.purs @@ -2,8 +2,8 @@ module Main where import Prelude import Control.Monad.Eff -import Debug.Trace -import Assert +import Control.Monad.Eff.Console +import Test.Assert main = do assert (1.0 < 2.0) @@ -12,4 +12,4 @@ main = do assert ("a" < "b") assert ("a" == "a") assert ("z" > "a") - trace "Done!" + log "Done!" diff --git a/examples/passing/Conditional.purs b/examples/passing/Conditional.purs index 6d39f7fd00..303f5a6c72 100644 --- a/examples/passing/Conditional.purs +++ b/examples/passing/Conditional.purs @@ -6,4 +6,4 @@ fns = \f -> if f true then f else \x -> x not = \x -> if x then false else true -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Console.purs b/examples/passing/Console.purs index e9e5c91e0d..a828773d01 100644 --- a/examples/passing/Console.purs +++ b/examples/passing/Console.purs @@ -2,7 +2,7 @@ module Main where import Prelude import Control.Monad.Eff -import Debug.Trace +import Control.Monad.Eff.Console replicateM_ :: forall m a. (Monad m) => Number -> m a -> m {} replicateM_ 0.0 _ = return {} @@ -10,4 +10,4 @@ replicateM_ n act = do act replicateM_ (n - 1.0) act -main = replicateM_ 10.0 (trace "Hello World!") +main = replicateM_ 10.0 (log "Hello World!") diff --git a/examples/passing/DataAndType.purs b/examples/passing/DataAndType.purs index d7b0d2f07a..4ce7527ad4 100644 --- a/examples/passing/DataAndType.purs +++ b/examples/passing/DataAndType.purs @@ -6,4 +6,4 @@ data A = A B type B = A -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/DeepArrayBinder.purs b/examples/passing/DeepArrayBinder.purs index a5e7476593..d34bfaac02 100644 --- a/examples/passing/DeepArrayBinder.purs +++ b/examples/passing/DeepArrayBinder.purs @@ -2,7 +2,7 @@ module Main where import Prelude import Control.Monad.Eff -import Assert +import Test.Assert data List a = Cons a (List a) | Nil @@ -10,6 +10,7 @@ match2 :: List Number -> Number match2 (Cons x (Cons y xs)) = x * y + match2 xs match2 _ = 0.0 -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 - 100.0 -> Debug.Trace.trace "Done" - _ -> error "Incorrect result!" +main = do + 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))))))))) + assert' "Incorrect result!" (result == 100.0) + Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/DeepCase.purs b/examples/passing/DeepCase.purs index 741e09a3f9..dce5f23c6c 100644 --- a/examples/passing/DeepCase.purs +++ b/examples/passing/DeepCase.purs @@ -1,7 +1,7 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console import Control.Monad.Eff import Control.Monad.ST diff --git a/examples/passing/Do.purs b/examples/passing/Do.purs index 9e63f9bb77..08c559d98e 100644 --- a/examples/passing/Do.purs +++ b/examples/passing/Do.purs @@ -5,12 +5,12 @@ import Prelude data Maybe a = Nothing | Just a instance functorMaybe :: Functor Maybe where - (<$>) f Nothing = Nothing - (<$>) f (Just x) = Just (f x) + map f Nothing = Nothing + map f (Just x) = Just (f x) instance applyMaybe :: Apply Maybe where - (<*>) (Just f) (Just x) = Just (f x) - (<*>) _ _ = Nothing + apply (Just f) (Just x) = Just (f x) + apply _ _ = Nothing instance applicativeMaybe :: Applicative Maybe where pure = Just @@ -64,4 +64,4 @@ test10 _ = do g x = f x / 2.0 Just (f 10.0) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Dollar.purs b/examples/passing/Dollar.purs index 6d5149996d..88be68feb6 100644 --- a/examples/passing/Dollar.purs +++ b/examples/passing/Dollar.purs @@ -13,4 +13,4 @@ test1 x = id $ id $ id $ id $ x test2 x = id id $ id x -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Eff.purs b/examples/passing/Eff.purs index c269512103..3d7c2cd2c0 100644 --- a/examples/passing/Eff.purs +++ b/examples/passing/Eff.purs @@ -3,11 +3,11 @@ module Main where import Prelude import Control.Monad.Eff import Control.Monad.ST -import Debug.Trace +import Control.Monad.Eff.Console test1 = do - trace "Line 1" - trace "Line 2" + log "Line 1" + log "Line 2" test2 = runPure (runST (do ref <- newSTRef 0.0 @@ -21,5 +21,5 @@ test3 = pureST (do main = do test1 - Debug.Trace.print test2 - Debug.Trace.print test3 + Control.Monad.Eff.Console.print test2 + Control.Monad.Eff.Console.print test3 diff --git a/examples/passing/EmptyDataDecls.purs b/examples/passing/EmptyDataDecls.purs index e19cc65bcc..40d77ee846 100644 --- a/examples/passing/EmptyDataDecls.purs +++ b/examples/passing/EmptyDataDecls.purs @@ -1,7 +1,7 @@ module Main where import Prelude -import Assert +import Test.Assert data Z data S n @@ -12,8 +12,8 @@ nil :: forall a. ArrayBox Z a nil = ArrayBox [] cons' :: forall a n. a -> ArrayBox n a -> ArrayBox (S n) a -cons' x (ArrayBox xs) = ArrayBox $ concat [x] xs +cons' x (ArrayBox xs) = ArrayBox $ append [x] xs main = case cons' 1 $ cons' 2 $ cons' 3 nil of - ArrayBox [1, 2, 3] -> Debug.Trace.trace "Done" - _ -> error "Failed" + ArrayBox [1, 2, 3] -> Control.Monad.Eff.Console.log "Done" + _ -> assert' "Failed" false diff --git a/examples/passing/EmptyRow.purs b/examples/passing/EmptyRow.purs index 3b2532da6a..9f738fb42d 100644 --- a/examples/passing/EmptyRow.purs +++ b/examples/passing/EmptyRow.purs @@ -7,4 +7,4 @@ data Foo r = Foo { | r } test :: Foo () test = Foo {} -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/EmptyTypeClass.purs b/examples/passing/EmptyTypeClass.purs index 08aa4f3f95..81d5ab3155 100644 --- a/examples/passing/EmptyTypeClass.purs +++ b/examples/passing/EmptyTypeClass.purs @@ -9,4 +9,4 @@ head [x] = x instance allowPartials :: Partial -main = Debug.Trace.trace $ head ["Done"] +main = Control.Monad.Eff.Console.log $ head ["Done"] diff --git a/examples/passing/EqOrd.purs b/examples/passing/EqOrd.purs index 1c03c70581..9ed10b2a3e 100644 --- a/examples/passing/EqOrd.purs +++ b/examples/passing/EqOrd.purs @@ -10,7 +10,6 @@ instance ordPair :: (Ord a, Ord b) => Ord (Pair a b) where r -> r instance eqPair :: (Eq a, Eq b) => Eq (Pair a b) where - (==) (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2 - (/=) (Pair a1 b1) (Pair a2 b2) = a1 /= a2 || b1 /= b2 + eq (Pair a1 b1) (Pair a2 b2) = a1 == a2 && b1 == b2 -main = Debug.Trace.print $ Pair 1.0 2.0 == Pair 1.0 2.0 +main = Control.Monad.Eff.Console.print $ Pair 1.0 2.0 == Pair 1.0 2.0 diff --git a/examples/passing/ExtendedInfixOperators.purs b/examples/passing/ExtendedInfixOperators.purs index 5771b8adf0..276d7d9d70 100644 --- a/examples/passing/ExtendedInfixOperators.purs +++ b/examples/passing/ExtendedInfixOperators.purs @@ -11,4 +11,4 @@ null _ = false test = [1.0, 2.0, 3.0] `comparing null` [4.0, 5.0, 6.0] main = do - Debug.Trace.print test + Control.Monad.Eff.Console.print test diff --git a/examples/passing/Fib.purs b/examples/passing/Fib.purs index 1f27ecd617..bf6d5223df 100644 --- a/examples/passing/Fib.purs +++ b/examples/passing/Fib.purs @@ -12,4 +12,4 @@ main = runST (do n2' <- readSTRef n2 writeSTRef n2 $ n1' + n2' writeSTRef n1 n2' - Debug.Trace.print n2') + Control.Monad.Eff.Console.print n2') diff --git a/examples/passing/FinalTagless.purs b/examples/passing/FinalTagless.purs index 80edd29ce8..5347153759 100644 --- a/examples/passing/FinalTagless.purs +++ b/examples/passing/FinalTagless.purs @@ -1,6 +1,6 @@ module Main where -import Prelude +import Prelude hiding (add) class E e where num :: Number -> e Number @@ -19,4 +19,4 @@ runId (Id a) = a three :: Expr Number three = add (num 1.0) (num 2.0) -main = Debug.Trace.print $ runId three +main = Control.Monad.Eff.Console.print $ runId three diff --git a/examples/passing/FunctionScope.purs b/examples/passing/FunctionScope.purs index 00f7ee2f42..3506153482 100644 --- a/examples/passing/FunctionScope.purs +++ b/examples/passing/FunctionScope.purs @@ -1,13 +1,12 @@ module Main where import Prelude -import Assert +import Test.Assert mkValue :: Number -> Number mkValue id = id main = do let value = mkValue 1.0 - if value == 1.0 - then Debug.Trace.trace "Done" - else error "Not done" + assert $ value == 1.0 + Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Functions.purs b/examples/passing/Functions.purs index d2fcad5c49..f0e3162aa8 100644 --- a/examples/passing/Functions.purs +++ b/examples/passing/Functions.purs @@ -12,4 +12,4 @@ test4 = \(%%) -> 1.0 %% 2.0 test5 = \(+++) (***) -> 1.0 +++ 2.0 *** 3.0 -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Functions2.purs b/examples/passing/Functions2.purs index ef2db66814..e43d88e7ef 100644 --- a/examples/passing/Functions2.purs +++ b/examples/passing/Functions2.purs @@ -1,13 +1,12 @@ module Main where import Prelude -import Assert +import Test.Assert test :: forall a b. a -> b -> a test = \const _ -> const main = do let value = test "Done" {} - if value == "Done" - then Debug.Trace.trace "Done" - else error "Not done" + assert' "Not done" $ value == "Done" + Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Guards.purs b/examples/passing/Guards.purs index 44234f2b94..81fdc2ec71 100644 --- a/examples/passing/Guards.purs +++ b/examples/passing/Guards.purs @@ -3,7 +3,7 @@ module Main where import Prelude collatz = \x -> case x of - y | y % 2.0 == 0.0 -> y / 2.0 + y | y `mod` 2.0 == 0.0 -> y / 2.0 y -> y * 3.0 + 1.0 -- Guards have access to current scope @@ -26,4 +26,4 @@ testIndentation x y | x > 0.0 | otherwise = y - x -main = Debug.Trace.trace $ min "Done" "ZZZZ" +main = Control.Monad.Eff.Console.log $ min "Done" "ZZZZ" diff --git a/examples/passing/HoistError.purs b/examples/passing/HoistError.purs index 25f123ad43..5128a754b2 100644 --- a/examples/passing/HoistError.purs +++ b/examples/passing/HoistError.purs @@ -2,11 +2,11 @@ module Main where import Prelude import Control.Monad.Eff -import Debug.Trace -import Assert +import Control.Monad.Eff.Console +import Test.Assert main = do let x = 0.0 assert $ x == 0.0 let x = 1.0 + 1.0 - trace "Done" + log "Done" diff --git a/examples/passing/IfThenElseMaybe.purs b/examples/passing/IfThenElseMaybe.purs index 2419dc7658..77da0234e7 100644 --- a/examples/passing/IfThenElseMaybe.purs +++ b/examples/passing/IfThenElseMaybe.purs @@ -8,4 +8,4 @@ test1 = if true then Just 10 else Nothing test2 = if true then Nothing else Just 10 -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/ImplicitEmptyImport.purs b/examples/passing/ImplicitEmptyImport.purs index 3a452d694c..82261f704e 100644 --- a/examples/passing/ImplicitEmptyImport.purs +++ b/examples/passing/ImplicitEmptyImport.purs @@ -3,6 +3,6 @@ module Main where import Prelude main = do - Debug.Trace.trace "Hello" - Debug.Trace.trace "Goodbye" - Debug.Trace.trace "Done" + Control.Monad.Eff.Console.log "Hello" + Control.Monad.Eff.Console.log "Goodbye" + Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/ImportHiding.purs b/examples/passing/ImportHiding.purs index 093e206fab..4abac7a82e 100644 --- a/examples/passing/ImportHiding.purs +++ b/examples/passing/ImportHiding.purs @@ -1,6 +1,6 @@ module Main where -import Debug.Trace +import Control.Monad.Eff.Console import Prelude hiding ( show, -- a value Show, -- a type class diff --git a/examples/passing/InferRecFunWithConstrainedArgument.purs b/examples/passing/InferRecFunWithConstrainedArgument.purs index e96285d717..2a10977698 100644 --- a/examples/passing/InferRecFunWithConstrainedArgument.purs +++ b/examples/passing/InferRecFunWithConstrainedArgument.purs @@ -5,4 +5,4 @@ import Prelude test 100.0 = 100.0 test n = test(1.0 + n) -main = Debug.Trace.print $ test 0.0 +main = Control.Monad.Eff.Console.print $ test 0.0 diff --git a/examples/passing/InstanceBeforeClass.purs b/examples/passing/InstanceBeforeClass.purs index 2302f50690..80690e9cd0 100644 --- a/examples/passing/InstanceBeforeClass.purs +++ b/examples/passing/InstanceBeforeClass.purs @@ -8,4 +8,4 @@ instance fooNumber :: Foo Number where class Foo a where foo :: a -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/IntAndChar.purs b/examples/passing/IntAndChar.purs index 68cf54fad0..aac7eddc36 100644 --- a/examples/passing/IntAndChar.purs +++ b/examples/passing/IntAndChar.purs @@ -2,7 +2,7 @@ module Main where import Prelude import Control.Monad.Eff -import Assert +import Test.Assert f 1 = 1 f _ = 0 @@ -15,4 +15,4 @@ main = do assert $ f 0 == 0 assert $ g 'a' == 'a' assert $ g 'b' == 'b' - Debug.Trace.trace "Done" + Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/JSReserved.purs b/examples/passing/JSReserved.purs index 0761059aa9..ee552ca48b 100644 --- a/examples/passing/JSReserved.purs +++ b/examples/passing/JSReserved.purs @@ -9,4 +9,4 @@ public = \return -> return this catch = catch -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/KindedType.purs b/examples/passing/KindedType.purs index 70c48df17a..adff8bb4ed 100644 --- a/examples/passing/KindedType.purs +++ b/examples/passing/KindedType.purs @@ -30,4 +30,4 @@ class Clazz (a :: *) where instance clazzString :: Clazz String where def = "test" -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Let.purs b/examples/passing/Let.purs index 560c1cb9df..d1aac9d023 100644 --- a/examples/passing/Let.purs +++ b/examples/passing/Let.purs @@ -44,10 +44,10 @@ test10 _ = in f 10.0 main = do - Debug.Trace.print (test1 1.0) - Debug.Trace.print (test2 1.0 2.0) - Debug.Trace.print test3 - Debug.Trace.print test4 - Debug.Trace.print test5 - Debug.Trace.print test7 - Debug.Trace.print (test8 100.0) + Control.Monad.Eff.Console.print (test1 1.0) + Control.Monad.Eff.Console.print (test2 1.0 2.0) + Control.Monad.Eff.Console.print test3 + Control.Monad.Eff.Console.print test4 + Control.Monad.Eff.Console.print test5 + Control.Monad.Eff.Console.print test7 + Control.Monad.Eff.Console.print (test8 100.0) diff --git a/examples/passing/Let2.purs b/examples/passing/Let2.purs index ad112f9eab..8da1344682 100644 --- a/examples/passing/Let2.purs +++ b/examples/passing/Let2.purs @@ -14,4 +14,4 @@ test = x = f 1.0 in not x -main = Debug.Trace.print test +main = Control.Monad.Eff.Console.print test diff --git a/examples/passing/LetInInstance.purs b/examples/passing/LetInInstance.purs index b72f255b37..d3e71bfe13 100644 --- a/examples/passing/LetInInstance.purs +++ b/examples/passing/LetInInstance.purs @@ -11,4 +11,4 @@ instance fooString :: Foo String where go :: String -> String go s = s -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/LiberalTypeSynonyms.purs b/examples/passing/LiberalTypeSynonyms.purs index defe959d0a..61f2ebf48e 100644 --- a/examples/passing/LiberalTypeSynonyms.purs +++ b/examples/passing/LiberalTypeSynonyms.purs @@ -18,4 +18,4 @@ f :: (forall r. F r) -> String f g = case g { x: "Hello" } of { x = x } -> x -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/MPTCs.purs b/examples/passing/MPTCs.purs index 276ec79d56..8b2fef22b9 100644 --- a/examples/passing/MPTCs.purs +++ b/examples/passing/MPTCs.purs @@ -17,4 +17,4 @@ instance coerceRefl :: Coerce a a where instance coerceShow :: (Prelude.Show a) => Coerce a String where coerce = show -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Match.purs b/examples/passing/Match.purs index 4f6b08e561..6df2a182ef 100644 --- a/examples/passing/Match.purs +++ b/examples/passing/Match.purs @@ -6,4 +6,4 @@ data Foo a = Foo foo = \f -> case f of Foo -> "foo" -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/ModuleExport.purs b/examples/passing/ModuleExport.purs index df54e20ce3..6c283e91e3 100644 --- a/examples/passing/ModuleExport.purs +++ b/examples/passing/ModuleExport.purs @@ -2,7 +2,7 @@ module A (module Prelude) where import Prelude module Main where - import Debug.Trace + import Control.Monad.Eff.Console import A main = do diff --git a/examples/passing/ModuleExportDupes.purs b/examples/passing/ModuleExportDupes.purs index 82d5347fc5..72f807bf55 100644 --- a/examples/passing/ModuleExportDupes.purs +++ b/examples/passing/ModuleExportDupes.purs @@ -9,7 +9,7 @@ module C (module Prelude, module A) where import A module Main where - import Debug.Trace + import Control.Monad.Eff.Console import A import B import C diff --git a/examples/passing/ModuleExportExcluded.purs b/examples/passing/ModuleExportExcluded.purs index 18ef14142d..fd0130a8b5 100644 --- a/examples/passing/ModuleExportExcluded.purs +++ b/examples/passing/ModuleExportExcluded.purs @@ -5,7 +5,7 @@ module A (module Prelude, foo) where foo _ = 0.0 module Main where - import Debug.Trace + import Control.Monad.Eff.Console import A (foo) otherwise = false diff --git a/examples/passing/ModuleExportHiding.purs b/examples/passing/ModuleExportHiding.purs index 4cea2221b1..3a59b71458 100644 --- a/examples/passing/ModuleExportHiding.purs +++ b/examples/passing/ModuleExportHiding.purs @@ -2,7 +2,7 @@ module A (module Prelude) where import Prelude module Main where - import Debug.Trace + import Control.Monad.Eff.Console import A hiding (module Prelude) otherwise = false diff --git a/examples/passing/ModuleExportQualified.purs b/examples/passing/ModuleExportQualified.purs index 7a84aec0a6..88fa20edf5 100644 --- a/examples/passing/ModuleExportQualified.purs +++ b/examples/passing/ModuleExportQualified.purs @@ -2,7 +2,7 @@ module A (module Prelude) where import Prelude module Main where - import Debug.Trace + import Control.Monad.Eff.Console import qualified A as B main = do diff --git a/examples/passing/ModuleExportSelf.purs b/examples/passing/ModuleExportSelf.purs index 42399a060c..cc2a0017a2 100644 --- a/examples/passing/ModuleExportSelf.purs +++ b/examples/passing/ModuleExportSelf.purs @@ -4,7 +4,7 @@ module A (module A, module Prelude) where type Foo = Boolean module Main where - import Debug.Trace + import Control.Monad.Eff.Console import A bar :: Foo diff --git a/examples/passing/Monad.purs b/examples/passing/Monad.purs index 731d7bbd05..96b2afdf83 100644 --- a/examples/passing/Monad.purs +++ b/examples/passing/Monad.purs @@ -29,4 +29,4 @@ test1 = test id test2 = test maybe -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/MonadState.purs b/examples/passing/MonadState.purs index 4218c88388..c2cd0e7107 100644 --- a/examples/passing/MonadState.purs +++ b/examples/passing/MonadState.purs @@ -13,10 +13,10 @@ data State s a = State (s -> Tuple s a) runState s (State f) = f s instance functorState :: Functor (State s) where - (<$>) = liftM1 + map = liftM1 instance applyState :: Apply (State s) where - (<*>) = ap + apply = ap instance applicativeState :: Applicative (State s) where pure a = State $ \s -> Tuple s a @@ -44,5 +44,5 @@ test = runState "" $ do main = do let t1 = test - Debug.Trace.trace "Done" + Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/MultiArgFunctions.purs b/examples/passing/MultiArgFunctions.purs index a15a363d11..999d527776 100644 --- a/examples/passing/MultiArgFunctions.purs +++ b/examples/passing/MultiArgFunctions.purs @@ -3,7 +3,7 @@ module Main where import Prelude import Data.Function import Control.Monad.Eff -import Debug.Trace +import Control.Monad.Eff.Console f = mkFn2 $ \a b -> runFn2 g a b + runFn2 g b a @@ -12,16 +12,16 @@ g = mkFn2 $ \a b -> case {} of _ -> runFn2 f (a - 0.0) (b - 0.0) main = do - runFn0 (mkFn0 $ \_ -> trace $ show 0.0) - runFn1 (mkFn1 $ \a -> trace $ show a) 0.0 - runFn2 (mkFn2 $ \a b -> trace $ show [a, b]) 0.0 0.0 - runFn3 (mkFn3 $ \a b c -> trace $ show [a, b, c]) 0.0 0.0 0.0 - runFn4 (mkFn4 $ \a b c d -> trace $ show [a, b, c, d]) 0.0 0.0 0.0 0.0 - runFn5 (mkFn5 $ \a b c d e -> trace $ show [a, b, c, d, e]) 0.0 0.0 0.0 0.0 0.0 - 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 - 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 - 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 - 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 - 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 + runFn0 (mkFn0 $ \_ -> log $ show 0.0) + runFn1 (mkFn1 $ \a -> log $ show a) 0.0 + runFn2 (mkFn2 $ \a b -> log $ show [a, b]) 0.0 0.0 + runFn3 (mkFn3 $ \a b c -> log $ show [a, b, c]) 0.0 0.0 0.0 + runFn4 (mkFn4 $ \a b c d -> log $ show [a, b, c, d]) 0.0 0.0 0.0 0.0 + runFn5 (mkFn5 $ \a b c d e -> log $ show [a, b, c, d, e]) 0.0 0.0 0.0 0.0 0.0 + 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 + 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 + 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 + 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 + 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 print $ runFn2 g 0.0 0.0 - trace "Done!" + log "Done!" diff --git a/examples/passing/MutRec.purs b/examples/passing/MutRec.purs index bdf179734e..afee9cd881 100644 --- a/examples/passing/MutRec.purs +++ b/examples/passing/MutRec.purs @@ -16,4 +16,4 @@ evenToNumber (Even n) = oddToNumber n + 0.0 oddToNumber (Odd n) = evenToNumber n + 0.0 -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/MutRec2.purs b/examples/passing/MutRec2.purs index 8a9863831a..762c67643e 100644 --- a/examples/passing/MutRec2.purs +++ b/examples/passing/MutRec2.purs @@ -16,4 +16,4 @@ g b = case b of B a -> f a showN :: A -> S showN a = f a -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/MutRec3.purs b/examples/passing/MutRec3.purs index 1150f4f12f..a22ac5de1e 100644 --- a/examples/passing/MutRec3.purs +++ b/examples/passing/MutRec3.purs @@ -16,4 +16,4 @@ g b = case b of B a -> f a showN :: A -> S showN a = f a -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/NamedPatterns.purs b/examples/passing/NamedPatterns.purs index 28dc1c2bf1..3e0d5575d0 100644 --- a/examples/passing/NamedPatterns.purs +++ b/examples/passing/NamedPatterns.purs @@ -6,4 +6,4 @@ foo = \x -> case x of y@{ foo = "Foo" } -> y y -> y -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/NegativeBinder.purs b/examples/passing/NegativeBinder.purs index 3433f5dc1b..63ba76aa78 100644 --- a/examples/passing/NegativeBinder.purs +++ b/examples/passing/NegativeBinder.purs @@ -6,4 +6,4 @@ test :: Number -> Boolean test -1.0 = false test _ = true -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Nested.purs b/examples/passing/Nested.purs index 5ac3ffc666..0f19014344 100644 --- a/examples/passing/Nested.purs +++ b/examples/passing/Nested.purs @@ -6,4 +6,4 @@ data Extend r a = Extend { prev :: r a, next :: a } data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/NestedTypeSynonyms.purs b/examples/passing/NestedTypeSynonyms.purs index 9f9f2d5e32..abb9ea7a5e 100644 --- a/examples/passing/NestedTypeSynonyms.purs +++ b/examples/passing/NestedTypeSynonyms.purs @@ -8,4 +8,4 @@ type Y = X -> X fn :: Y fn a = a -main = Debug.Trace.print (fn "Done") +main = Control.Monad.Eff.Console.print (fn "Done") diff --git a/examples/passing/NestedWhere.purs b/examples/passing/NestedWhere.purs index 85e3901b82..4867ae824b 100644 --- a/examples/passing/NestedWhere.purs +++ b/examples/passing/NestedWhere.purs @@ -9,4 +9,4 @@ f x = g x go x = go1 (x - 1.0) go1 x = go x -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Newtype.purs b/examples/passing/Newtype.purs index e6e310d079..c9edbda825 100644 --- a/examples/passing/Newtype.purs +++ b/examples/passing/Newtype.purs @@ -1,8 +1,8 @@ module Main where -import Prelude +import Prelude hiding (apply) import Control.Monad.Eff -import Debug.Trace +import Control.Monad.Eff.Console newtype Thing = Thing String @@ -20,4 +20,4 @@ main = do print $ Thing "hello" print $ Box 42.0 print $ apply Box 9000.0 - trace "Done" + log "Done" diff --git a/examples/passing/NewtypeEff.purs b/examples/passing/NewtypeEff.purs index 8054d4310f..ad9fdbf721 100644 --- a/examples/passing/NewtypeEff.purs +++ b/examples/passing/NewtypeEff.purs @@ -1,19 +1,19 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console import Control.Monad.Eff -newtype T a = T (Eff (trace :: Trace) a) +newtype T a = T (Eff (console :: CONSOLE) a) -runT :: forall a. T a -> Eff (trace :: Trace) a +runT :: forall a. T a -> Eff (console :: CONSOLE) a runT (T t) = t instance functorT :: Functor T where - (<$>) f (T t) = T (f <$> t) + map f (T t) = T (f <$> t) instance applyT :: Apply T where - (<*>) (T f) (T x) = T (f <*> x) + apply (T f) (T x) = T (f <*> x) instance applicativeT :: Applicative T where pure t = T (pure t) @@ -24,6 +24,6 @@ instance bindT :: Bind T where instance monadT :: Monad T main = runT do - T $ trace "Done" - T $ trace "Done" - T $ trace "Done" + T $ log "Done" + T $ log "Done" + T $ log "Done" diff --git a/examples/passing/NewtypeWithRecordUpdate.purs b/examples/passing/NewtypeWithRecordUpdate.purs index 4fd81cc370..1a68534f7e 100644 --- a/examples/passing/NewtypeWithRecordUpdate.purs +++ b/examples/passing/NewtypeWithRecordUpdate.purs @@ -3,7 +3,7 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console newtype NewType a = NewType (Object a) @@ -13,4 +13,4 @@ rec1 = { a: 0.0, b: 0.0, c: 0.0 } rec2 :: NewType (a :: Number, b :: Number, c :: Number) rec2 = NewType (rec1 { a = 1.0 }) -main = trace "Done" +main = log "Done" diff --git a/examples/passing/ObjectGetter.purs b/examples/passing/ObjectGetter.purs index 5224d793af..addb57f7de 100644 --- a/examples/passing/ObjectGetter.purs +++ b/examples/passing/ObjectGetter.purs @@ -7,7 +7,7 @@ getX = _.x point = { x: 1.0, y: 0.0 } main = do - Debug.Trace.print $ getX point - Debug.Trace.trace $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" } - Debug.Trace.trace $ (_.x >>> _.y) { x: { y: "Nested" } } - Debug.Trace.trace $ _.value { value: "Done!" } + Control.Monad.Eff.Console.print $ getX point + Control.Monad.Eff.Console.log $ _." 123 string Prop Name " { " 123 string Prop Name ": "OK" } + Control.Monad.Eff.Console.log $ (_.x >>> _.y) { x: { y: "Nested" } } + Control.Monad.Eff.Console.log $ _.value { value: "Done!" } diff --git a/examples/passing/ObjectSynonym.purs b/examples/passing/ObjectSynonym.purs index f9b60a6807..34fb7faaaf 100644 --- a/examples/passing/ObjectSynonym.purs +++ b/examples/passing/ObjectSynonym.purs @@ -12,4 +12,4 @@ type Outer = { inner :: Inner } outer :: Outer outer = { inner: inner } -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/ObjectUpdate.purs b/examples/passing/ObjectUpdate.purs index 98fc71e4e2..de6f358f49 100644 --- a/examples/passing/ObjectUpdate.purs +++ b/examples/passing/ObjectUpdate.purs @@ -17,4 +17,4 @@ polyUpdate = \o -> o { foo = "Foo" } inferPolyUpdate = \o -> o { foo = "Foo" } -main = Debug.Trace.trace ((update1 {foo: ""}).foo) +main = Control.Monad.Eff.Console.log ((update1 {foo: ""}).foo) diff --git a/examples/passing/ObjectUpdate2.purs b/examples/passing/ObjectUpdate2.purs index 610f4a5fc9..da2bf114a6 100644 --- a/examples/passing/ObjectUpdate2.purs +++ b/examples/passing/ObjectUpdate2.purs @@ -14,4 +14,4 @@ test = blah x { baz = "blah" } -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/ObjectUpdater.purs b/examples/passing/ObjectUpdater.purs index 929416c3b9..17246c603d 100644 --- a/examples/passing/ObjectUpdater.purs +++ b/examples/passing/ObjectUpdater.purs @@ -2,8 +2,8 @@ module Main where import Prelude import Control.Monad.Eff -import Debug.Trace -import Assert +import Control.Monad.Eff.Console +import Test.Assert getValue :: forall e. Eff (| e) Boolean getValue = return true diff --git a/examples/passing/ObjectWildcards.purs b/examples/passing/ObjectWildcards.purs index eea7236421..5a0d4c8b87 100644 --- a/examples/passing/ObjectWildcards.purs +++ b/examples/passing/ObjectWildcards.purs @@ -2,8 +2,8 @@ module Main where import Prelude import Control.Monad.Eff -import Debug.Trace -import Assert +import Control.Monad.Eff.Console +import Test.Assert mkRecord = { foo: _, bar: _, baz: "baz" } @@ -17,4 +17,4 @@ main = do point <- { x: _, y: x } <$> return 2.0 assert $ point.x == 2.0 assert $ point.y == 1.0 - trace (mkRecord 1.0 "Done!").bar + log (mkRecord 1.0 "Done!").bar diff --git a/examples/passing/Objects.purs b/examples/passing/Objects.purs index 3227c07d5c..810dc8033e 100644 --- a/examples/passing/Objects.purs +++ b/examples/passing/Objects.purs @@ -1,6 +1,6 @@ module Main where -import Prelude +import Prelude hiding (append) test = \x -> x.foo + x.bar + 1.0 @@ -32,4 +32,4 @@ test6 = case { "***": 1.0 } of test7 {a: snoog , b : blah } = blah -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/OneConstructor.purs b/examples/passing/OneConstructor.purs index bbbcef5704..149e1e2524 100644 --- a/examples/passing/OneConstructor.purs +++ b/examples/passing/OneConstructor.purs @@ -6,4 +6,4 @@ data One a = One a one' (One a) = a -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/OperatorAssociativity.purs b/examples/passing/OperatorAssociativity.purs index b73de61186..7ee50e6e08 100644 --- a/examples/passing/OperatorAssociativity.purs +++ b/examples/passing/OperatorAssociativity.purs @@ -2,8 +2,8 @@ module Main where import Prelude import Control.Monad.Eff -import Debug.Trace -import Assert +import Control.Monad.Eff.Console +import Test.Assert bug :: Number -> Number -> Number bug a b = 0.0 - (a - b) @@ -22,4 +22,4 @@ main = do assert (1.0 + 10.0 - 5.0 == 6.0) assert (1.0 + 10.0 * 5.0 == 51.0) assert (10.0 * 5.0 - 1.0 == 49.0) - trace "Success!" + log "Success!" diff --git a/examples/passing/OperatorInlining.purs b/examples/passing/OperatorInlining.purs index 83cb24cd84..172babd0e3 100644 --- a/examples/passing/OperatorInlining.purs +++ b/examples/passing/OperatorInlining.purs @@ -1,7 +1,7 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console main = do diff --git a/examples/passing/OperatorSections.purs b/examples/passing/OperatorSections.purs index 1b51c0e0ba..a9c426caed 100644 --- a/examples/passing/OperatorSections.purs +++ b/examples/passing/OperatorSections.purs @@ -1,11 +1,11 @@ module Main where import Prelude -import Assert +import Test.Assert main = do assert $ (/ 2.0) 4.0 == 2.0 assert $ (2.0 /) 4.0 == 0.5 assert $ (`const` 1.0) 2.0 == 2.0 assert $ (1.0 `const`) 2.0 == 1.0 - Debug.Trace.trace "Done!" + Control.Monad.Eff.Console.log "Done!" diff --git a/examples/passing/Operators.purs b/examples/passing/Operators.purs index b8b519fcf5..0d6d86ffea 100644 --- a/examples/passing/Operators.purs +++ b/examples/passing/Operators.purs @@ -2,7 +2,7 @@ module Main where import Prelude import Control.Monad.Eff -import Debug.Trace +import Control.Monad.Eff.Console (?!) :: forall a. a -> a -> a (?!) x _ = x @@ -96,4 +96,4 @@ main = do let t18 = test18 let t19 = test19 let t20 = test20 - trace "Done" + log "Done" diff --git a/examples/passing/OptimizerBug.purs b/examples/passing/OptimizerBug.purs index cdddb1f954..ea371de607 100644 --- a/examples/passing/OptimizerBug.purs +++ b/examples/passing/OptimizerBug.purs @@ -6,4 +6,4 @@ x a = 1.0 + y a y a = x a -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/PartialFunction.purs b/examples/passing/PartialFunction.purs index 03d0943fe5..f0c4fd311a 100644 --- a/examples/passing/PartialFunction.purs +++ b/examples/passing/PartialFunction.purs @@ -1,10 +1,10 @@ module Main where import Prelude -import Assert +import Test.Assert fn :: Number -> Number fn 0.0 = 0.0 fn 1.0 = 2.0 -main = assertPartial $ \_ -> fn 2.0 +main = assertThrows $ \_ -> fn 2.0 diff --git a/examples/passing/Patterns.purs b/examples/passing/Patterns.purs index 4a63ad5e4e..9606afa84b 100644 --- a/examples/passing/Patterns.purs +++ b/examples/passing/Patterns.purs @@ -19,4 +19,4 @@ isDesc :: Array Number -> Boolean isDesc [x, y] | x > y = true isDesc _ = false -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Person.purs b/examples/passing/Person.purs index fba54ae00c..fa3384e597 100644 --- a/examples/passing/Person.purs +++ b/examples/passing/Person.purs @@ -8,4 +8,4 @@ showPerson :: Person -> String showPerson = \p -> case p of Person o -> o.name ++ ", aged " ++ show o.age -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Rank2Data.purs b/examples/passing/Rank2Data.purs index 2326d67eb4..0f678037fd 100644 --- a/examples/passing/Rank2Data.purs +++ b/examples/passing/Rank2Data.purs @@ -1,6 +1,6 @@ module Main where -import Prelude +import Prelude hiding (add) data Id = Id forall a. a -> a @@ -26,4 +26,4 @@ two = succ zero' four = add two two fourNumber = runNat four -main = Debug.Trace.trace "Done'" +main = Control.Monad.Eff.Console.log "Done'" diff --git a/examples/passing/Rank2Object.purs b/examples/passing/Rank2Object.purs index e25516f8f3..c9651e695f 100644 --- a/examples/passing/Rank2Object.purs +++ b/examples/passing/Rank2Object.purs @@ -1,11 +1,11 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console data Foo = Foo { id :: forall a. a -> a } foo :: Foo -> Number foo (Foo { id = f }) = f 0.0 -main = trace "Done" +main = log "Done" diff --git a/examples/passing/Rank2TypeSynonym.purs b/examples/passing/Rank2TypeSynonym.purs index 11a51d21db..a1977da4b0 100644 --- a/examples/passing/Rank2TypeSynonym.purs +++ b/examples/passing/Rank2TypeSynonym.purs @@ -13,4 +13,4 @@ bar = foo 3.0 main = do x <- bar - Debug.Trace.print x + Control.Monad.Eff.Console.print x diff --git a/examples/passing/Rank2Types.purs b/examples/passing/Rank2Types.purs index fb92ed8882..7af12ae7df 100644 --- a/examples/passing/Rank2Types.purs +++ b/examples/passing/Rank2Types.purs @@ -8,4 +8,4 @@ test1 = \f -> f 0.0 forever :: forall m a b. (forall a b. m a -> (a -> m b) -> m b) -> m a -> m b forever = \bind action -> bind action $ \_ -> forever bind action -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/RebindableSyntax.purs b/examples/passing/RebindableSyntax.purs index 533e302920..df00ce1a19 100644 --- a/examples/passing/RebindableSyntax.purs +++ b/examples/passing/RebindableSyntax.purs @@ -20,10 +20,10 @@ runConst :: forall a b. Const a b -> a runConst (Const a) = a instance functorConst :: Functor (Const a) where - (<$>) _ (Const a) = Const a + map _ (Const a) = Const a instance applyConst :: (Semigroup a) => Apply (Const a) where - (<*>) (Const a1) (Const a2) = Const (a1 <> a2) + apply (Const a1) (Const a2) = Const (a1 <> a2) example2 :: Const String Unit example2 = do @@ -35,5 +35,5 @@ example2 = do bind x f = x *> f unit main = do - Debug.Trace.trace example1 - Debug.Trace.trace $ runConst example2 + Control.Monad.Eff.Console.log example1 + Control.Monad.Eff.Console.log $ runConst example2 diff --git a/examples/passing/Recursion.purs b/examples/passing/Recursion.purs index f6c88f9ad6..67d3094341 100644 --- a/examples/passing/Recursion.purs +++ b/examples/passing/Recursion.purs @@ -7,4 +7,4 @@ fib = \n -> case n of 1.0 -> 1.0 n -> fib (n - 1.0) + fib (n - 2.0) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/ReservedWords.purs b/examples/passing/ReservedWords.purs index 89f023e94d..ff233bf2e4 100644 --- a/examples/passing/ReservedWords.purs +++ b/examples/passing/ReservedWords.purs @@ -12,4 +12,4 @@ p = o { type = "p" } f :: forall r. { type :: String | r } -> String f { type = "p" } = "Done" -main = Debug.Trace.trace $ f { type: p.type, foo: "bar" } +main = Control.Monad.Eff.Console.log $ f { type: p.type, foo: "bar" } diff --git a/examples/passing/RowConstructors.purs b/examples/passing/RowConstructors.purs index 0ed416f315..593d94caa0 100644 --- a/examples/passing/RowConstructors.purs +++ b/examples/passing/RowConstructors.purs @@ -39,4 +39,4 @@ wildcard { w: w } = { x: w, y: w, z: w, w: w } wildcard' :: { | Quux _ } -> Number wildcard' { q: q } = q -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/RowPolyInstanceContext.purs b/examples/passing/RowPolyInstanceContext.purs index fe4ad533d8..f0543af36a 100644 --- a/examples/passing/RowPolyInstanceContext.purs +++ b/examples/passing/RowPolyInstanceContext.purs @@ -19,4 +19,4 @@ test2 = state $ \o -> o { foo = o.foo ++ "!" } main = do let t1 = test1 let t2 = test2 - Debug.Trace.trace "Done" + Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/RuntimeScopeIssue.purs b/examples/passing/RuntimeScopeIssue.purs index 24e7923b75..f6800c81b9 100644 --- a/examples/passing/RuntimeScopeIssue.purs +++ b/examples/passing/RuntimeScopeIssue.purs @@ -16,4 +16,4 @@ instance bNumber :: B Number where b 0.0 = false b n = a (n - 1.0) -main = Debug.Trace.print $ a 10.0 +main = Control.Monad.Eff.Console.print $ a 10.0 diff --git a/examples/passing/ScopedTypeVariables.purs b/examples/passing/ScopedTypeVariables.purs index bfc0590e8d..5526059732 100644 --- a/examples/passing/ScopedTypeVariables.purs +++ b/examples/passing/ScopedTypeVariables.purs @@ -33,4 +33,4 @@ test4 = h j x = x -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Sequence.purs b/examples/passing/Sequence.purs index 289a618ff6..692fbd0a73 100644 --- a/examples/passing/Sequence.purs +++ b/examples/passing/Sequence.purs @@ -12,4 +12,4 @@ instance sequenceList :: Sequence List where sequence Nil = pure Nil sequence (Cons x xs) = Cons <$> x <*> sequence xs -main = sequence $ Cons (Debug.Trace.trace "Done") Nil +main = sequence $ Cons (Control.Monad.Eff.Console.log "Done") Nil diff --git a/examples/passing/SequenceDesugared.purs b/examples/passing/SequenceDesugared.purs index fbc184cb74..622f1c3ba4 100644 --- a/examples/passing/SequenceDesugared.purs +++ b/examples/passing/SequenceDesugared.purs @@ -31,7 +31,7 @@ sequenceList''' = Sequence ((\val -> case val of Cons x xs -> Cons <$> x <*> sequence sequenceList''' xs) :: forall m a. (Monad m) => List (m a) -> m (List a)) main = do - sequence sequenceList $ Cons (Debug.Trace.trace "Done") Nil - sequence sequenceList' $ Cons (Debug.Trace.trace "Done") Nil - sequence sequenceList'' $ Cons (Debug.Trace.trace "Done") Nil - sequence sequenceList''' $ Cons (Debug.Trace.trace "Done") Nil + sequence sequenceList $ Cons (Control.Monad.Eff.Console.log "Done") Nil + sequence sequenceList' $ Cons (Control.Monad.Eff.Console.log "Done") Nil + sequence sequenceList'' $ Cons (Control.Monad.Eff.Console.log "Done") Nil + sequence sequenceList''' $ Cons (Control.Monad.Eff.Console.log "Done") Nil diff --git a/examples/passing/ShadowedRename.purs b/examples/passing/ShadowedRename.purs index 3c665c65c4..4b0c31798b 100644 --- a/examples/passing/ShadowedRename.purs +++ b/examples/passing/ShadowedRename.purs @@ -2,8 +2,8 @@ module Main where import Prelude import Control.Monad.Eff -import Debug.Trace -import Assert +import Control.Monad.Eff.Console +import Test.Assert foo foo = let foo_1 = \_ -> foo foo_2 = foo_1 unit + 1.0 @@ -11,4 +11,4 @@ foo foo = let foo_1 = \_ -> foo main = do assert $ foo 1.0 == 2.0 - trace "Done" + log "Done" diff --git a/examples/passing/ShadowedTCO.purs b/examples/passing/ShadowedTCO.purs index ceb9883f09..fa7e34db2d 100644 --- a/examples/passing/ShadowedTCO.purs +++ b/examples/passing/ShadowedTCO.purs @@ -1,6 +1,6 @@ module Main where -import Prelude +import Prelude hiding (add) runNat f = f 0.0 (\n -> n + 1.0) @@ -15,4 +15,4 @@ two = succ one' four = add two two fourNumber = runNat four -main = Debug.Trace.trace $ show fourNumber +main = Control.Monad.Eff.Console.log $ show fourNumber diff --git a/examples/passing/ShadowedTCOLet.purs b/examples/passing/ShadowedTCOLet.purs index 8c9c6a0166..e3c1c7e098 100644 --- a/examples/passing/ShadowedTCOLet.purs +++ b/examples/passing/ShadowedTCOLet.purs @@ -6,4 +6,4 @@ f x y z = let f 1.0 2.0 3.0 = 1.0 in f x z y -main = Debug.Trace.trace $ show $ f 1.0 3.0 2.0 +main = Control.Monad.Eff.Console.log $ show $ f 1.0 3.0 2.0 diff --git a/examples/passing/SignedNumericLiterals.purs b/examples/passing/SignedNumericLiterals.purs index 054f7a58e4..12937db0cc 100644 --- a/examples/passing/SignedNumericLiterals.purs +++ b/examples/passing/SignedNumericLiterals.purs @@ -14,4 +14,4 @@ f x = -x test1 = 2.0 - 1.0 -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/Superclasses1.purs b/examples/passing/Superclasses1.purs index db9a0396b1..cdf075f0fb 100644 --- a/examples/passing/Superclasses1.purs +++ b/examples/passing/Superclasses1.purs @@ -17,4 +17,4 @@ instance clNumber :: Cl Number where test :: forall a. (Cl a) => a -> a test a = su (cl a a) -main = Debug.Trace.print $ test 10.0 +main = Control.Monad.Eff.Console.print $ test 10.0 diff --git a/examples/passing/Superclasses2.purs b/examples/passing/Superclasses2.purs index 09dfb6319d..5f14df3c1a 100644 --- a/examples/passing/Superclasses2.purs +++ b/examples/passing/Superclasses2.purs @@ -1,7 +1,6 @@ module Main where import Prelude -import Prelude.Unsafe (unsafeIndex) class Su a where su :: a -> a @@ -21,4 +20,4 @@ instance clNumber :: Cl Number where test :: forall a. (Cl a) => a -> Array a test x = su [cl x x] -main = Debug.Trace.print $ test 10.0 `unsafeIndex` 0.0 +main = Control.Monad.Eff.Console.print $ test 10.0 diff --git a/examples/passing/Superclasses3.purs b/examples/passing/Superclasses3.purs index 7fa8ffa463..d1135a0bcb 100644 --- a/examples/passing/Superclasses3.purs +++ b/examples/passing/Superclasses3.purs @@ -1,7 +1,7 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console import Control.Monad.Eff class (Monad m) <= MonadWriter w m where @@ -16,16 +16,16 @@ test w = do tell w tell w -data MTrace a = MTrace (Eff (trace :: Trace) a) +data MTrace a = MTrace (Eff (console :: CONSOLE) a) -runMTrace :: forall a. MTrace a -> Eff (trace :: Trace) a +runMTrace :: forall a. MTrace a -> Eff (console :: CONSOLE) a runMTrace (MTrace a) = a instance functorMTrace :: Functor MTrace where - (<$>) = liftM1 + map = liftM1 instance applyMTrace :: Apply MTrace where - (<*>) = ap + apply = ap instance applicativeMTrace :: Applicative MTrace where pure = MTrace <<< return @@ -36,6 +36,6 @@ instance bindMTrace :: Bind MTrace where instance monadMTrace :: Monad MTrace instance writerMTrace :: MonadWriter String MTrace where - tell s = MTrace (trace s) + tell s = MTrace (log s) main = runMTrace $ test "Done" diff --git a/examples/passing/TCOCase.purs b/examples/passing/TCOCase.purs index 2f8454aa4b..654aa53986 100644 --- a/examples/passing/TCOCase.purs +++ b/examples/passing/TCOCase.purs @@ -4,7 +4,7 @@ import Prelude data Data = One | More Data -main = Debug.Trace.trace (from (to 10000.0 One)) +main = Control.Monad.Eff.Console.log (from (to 10000.0 One)) where to 0.0 a = a to n a = to (n - 1.0) (More a) diff --git a/examples/passing/TailCall.purs b/examples/passing/TailCall.purs index 505f38c9f7..1fad42378b 100644 --- a/examples/passing/TailCall.purs +++ b/examples/passing/TailCall.purs @@ -14,4 +14,4 @@ loop x = loop (x + 1.0) notATailCall = \x -> (\notATailCall -> notATailCall x) (\x -> x) -main = Debug.Trace.print (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N)))) +main = Control.Monad.Eff.Console.print (test 0.0 (1.0 `C` (2.0 `C` (3.0 `C` N)))) diff --git a/examples/passing/Tick.purs b/examples/passing/Tick.purs index 718420f8d3..6b8f19e251 100644 --- a/examples/passing/Tick.purs +++ b/examples/passing/Tick.purs @@ -4,4 +4,4 @@ import Prelude test' x = x -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/TopLevelCase.purs b/examples/passing/TopLevelCase.purs index 557ab6fcc7..1e11b7de08 100644 --- a/examples/passing/TopLevelCase.purs +++ b/examples/passing/TopLevelCase.purs @@ -5,8 +5,8 @@ import Prelude gcd :: Number -> Number -> Number gcd 0.0 x = x gcd x 0.0 = x -gcd x y | x > y = gcd (x % y) y -gcd x y = gcd (y % x) x +gcd x y | x > y = gcd (x `mod` y) y +gcd x y = gcd (y `mod` x) x guardsTest [x] | x > 0.0 = [] guardsTest xs = xs @@ -15,4 +15,4 @@ data A = A parseTest A 0.0 = 0.0 -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/TypeClassMemberOrderChange.purs b/examples/passing/TypeClassMemberOrderChange.purs index f05dcfe2c4..2e38b7d588 100644 --- a/examples/passing/TypeClassMemberOrderChange.purs +++ b/examples/passing/TypeClassMemberOrderChange.purs @@ -10,4 +10,4 @@ instance testBoolean :: Test Boolean where val = true fn x y = y -main = Debug.Trace.trace (show (fn true val)) +main = Control.Monad.Eff.Console.log (show (fn true val)) diff --git a/examples/passing/TypeClasses.purs b/examples/passing/TypeClasses.purs index a9b2f1c3c6..1dfdf51fc7 100644 --- a/examples/passing/TypeClasses.purs +++ b/examples/passing/TypeClasses.purs @@ -22,10 +22,10 @@ instance showData :: (Prelude.Show a) => Prelude.Show (Data a) where test3 = \_ -> show (Data "testing") instance functorData :: Functor Data where - (<$>) = liftM1 + map = liftM1 instance applyData :: Apply Data where - (<*>) = ap + apply = ap instance applicativeData :: Applicative Data where pure = Data @@ -38,10 +38,10 @@ instance monadData :: Monad Data data Maybe a = Nothing | Just a instance functorMaybe :: Functor Maybe where - (<$>) = liftM1 + map = liftM1 instance applyMaybe :: Apply Maybe where - (<*>) = ap + apply = ap instance applicativeMaybe :: Applicative Maybe where pure = Just @@ -65,5 +65,5 @@ test9 _ = runReader 0.0 $ do n <- ask return $ n + 1.0 -main = Debug.Trace.trace (test7 "Done") +main = Control.Monad.Eff.Console.log (test7 "Done") diff --git a/examples/passing/TypeClassesInOrder.purs b/examples/passing/TypeClassesInOrder.purs index d576a84597..a34db925b1 100644 --- a/examples/passing/TypeClassesInOrder.purs +++ b/examples/passing/TypeClassesInOrder.purs @@ -8,4 +8,4 @@ class Foo a where instance fooString :: Foo String where foo s = s -main = Debug.Trace.trace $ foo "Done" +main = Control.Monad.Eff.Console.log $ foo "Done" diff --git a/examples/passing/TypeClassesWithOverlappingTypeVariables.purs b/examples/passing/TypeClassesWithOverlappingTypeVariables.purs index 66b8b80d29..9b5c6a9596 100644 --- a/examples/passing/TypeClassesWithOverlappingTypeVariables.purs +++ b/examples/passing/TypeClassesWithOverlappingTypeVariables.purs @@ -5,7 +5,7 @@ import Prelude data Either a b = Left a | Right b instance functorEither :: Prelude.Functor (Either a) where - (<$>) _ (Left x) = Left x - (<$>) f (Right y) = Right (f y) + map _ (Left x) = Left x + map f (Right y) = Right (f y) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/TypeDecl.purs b/examples/passing/TypeDecl.purs index 9b78b38f61..76b32c4927 100644 --- a/examples/passing/TypeDecl.purs +++ b/examples/passing/TypeDecl.purs @@ -9,4 +9,4 @@ iterate :: forall a. Number -> (a -> a) -> a -> a iterate 0.0 f a = a iterate n f a = iterate (n - 1.0) f (f a) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/TypeSynonymInData.purs b/examples/passing/TypeSynonymInData.purs index 591ef53544..62da487f7c 100644 --- a/examples/passing/TypeSynonymInData.purs +++ b/examples/passing/TypeSynonymInData.purs @@ -8,4 +8,4 @@ data Foo a = Foo (A a) | Bar foo (Foo []) = Bar -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/TypeSynonyms.purs b/examples/passing/TypeSynonyms.purs index 4dbc27fd71..3cc4cf9631 100644 --- a/examples/passing/TypeSynonyms.purs +++ b/examples/passing/TypeSynonyms.purs @@ -24,4 +24,4 @@ fst = test1 :: forall a b c. Lens (Pair (Pair a b) c) a test1 = composeLenses fst fst -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/TypeWildcards.purs b/examples/passing/TypeWildcards.purs index fa3f7611c0..f6f3da2bcf 100644 --- a/examples/passing/TypeWildcards.purs +++ b/examples/passing/TypeWildcards.purs @@ -12,4 +12,4 @@ test f a = go (f a) a go a1 a2 | a1 == a2 = a1 go a1 _ = go (f a1) a1 -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/TypeWildcardsRecordExtension.purs b/examples/passing/TypeWildcardsRecordExtension.purs index 3a636f4494..615fe9edac 100644 --- a/examples/passing/TypeWildcardsRecordExtension.purs +++ b/examples/passing/TypeWildcardsRecordExtension.purs @@ -5,4 +5,4 @@ import Prelude foo :: forall a. {b :: Number | a} -> {b :: Number | _} foo f = f -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/TypedWhere.purs b/examples/passing/TypedWhere.purs index 690c6b9580..177369685e 100644 --- a/examples/passing/TypedWhere.purs +++ b/examples/passing/TypedWhere.purs @@ -14,4 +14,4 @@ lefts = go N go ls (C (L a) rest) = go (C a ls) rest go ls (C _ rest) = go ls rest -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/UnderscoreIdent.purs b/examples/passing/UnderscoreIdent.purs index c669f2e017..318bda34c8 100644 --- a/examples/passing/UnderscoreIdent.purs +++ b/examples/passing/UnderscoreIdent.purs @@ -8,4 +8,4 @@ type Type_name = Data_type done (Con_2 s) = s -main = Debug.Trace.trace (done (Con_2 "Done")) +main = Control.Monad.Eff.Console.log (done (Con_2 "Done")) diff --git a/examples/passing/Unit.purs b/examples/passing/Unit.purs index bda473cdba..5e555283b1 100644 --- a/examples/passing/Unit.purs +++ b/examples/passing/Unit.purs @@ -1,6 +1,6 @@ module Main where import Prelude -import Debug.Trace +import Control.Monad.Eff.Console main = print (const unit $ "Hello world") diff --git a/examples/passing/UnknownInTypeClassLookup.purs b/examples/passing/UnknownInTypeClassLookup.purs index 7b2cdc71e8..94f929f343 100644 --- a/examples/passing/UnknownInTypeClassLookup.purs +++ b/examples/passing/UnknownInTypeClassLookup.purs @@ -11,4 +11,4 @@ test _ _ = "Done" runTest a = test a a -main = Debug.Trace.trace $ runTest 0.0 +main = Control.Monad.Eff.Console.log $ runTest 0.0 diff --git a/examples/passing/Where.purs b/examples/passing/Where.purs index 1493f8ce48..942255fe5f 100644 --- a/examples/passing/Where.purs +++ b/examples/passing/Where.purs @@ -40,10 +40,10 @@ test7 x = go x go y = go $ (y + x / y) / 2.0 main = do - Debug.Trace.print (test1 1.0) - Debug.Trace.print (test2 1.0 2.0) - Debug.Trace.print test3 - Debug.Trace.print test4 - Debug.Trace.print test5 - Debug.Trace.print test6 - Debug.Trace.print (test7 100.0) + Control.Monad.Eff.Console.print (test1 1.0) + Control.Monad.Eff.Console.print (test2 1.0 2.0) + Control.Monad.Eff.Console.print test3 + Control.Monad.Eff.Console.print test4 + Control.Monad.Eff.Console.print test5 + Control.Monad.Eff.Console.print test6 + Control.Monad.Eff.Console.print (test7 100.0) diff --git a/examples/passing/iota.purs b/examples/passing/iota.purs index 48d98fb248..be0430ef8c 100644 --- a/examples/passing/iota.purs +++ b/examples/passing/iota.purs @@ -6,4 +6,4 @@ k = \x -> \y -> x iota = \x -> x s k -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/examples/passing/s.purs b/examples/passing/s.purs index c26a50e2d7..041b125d70 100644 --- a/examples/passing/s.purs +++ b/examples/passing/s.purs @@ -4,4 +4,4 @@ import Prelude s = \x y z -> x z (y z) -main = Debug.Trace.trace "Done" +main = Control.Monad.Eff.Console.log "Done" diff --git a/psci/Completion.hs b/psci/Completion.hs index 4bd0e27e3a..2936f47aa1 100644 --- a/psci/Completion.hs +++ b/psci/Completion.hs @@ -6,6 +6,7 @@ import Data.Char (isUpper) import Data.Function (on) import Data.Traversable (traverse) +import Control.Arrow (second) import Control.Applicative ((<$>), (<*>)) import Control.Monad.Trans.Reader (asks, runReaderT, ReaderT) import Control.Monad.Trans.State.Strict @@ -196,13 +197,15 @@ typeDecls = mapMaybe getTypeName . filter P.isDataDecl . P.exportedDeclarations getTypeName _ = Nothing identNames :: P.Module -> [(N.Ident, P.Declaration)] -identNames = nubOnFst . mapMaybe getDeclName . P.exportedDeclarations +identNames = nubOnFst . concatMap getDeclNames . P.exportedDeclarations where - getDeclName :: P.Declaration -> Maybe (P.Ident, P.Declaration) - getDeclName d@(P.ValueDeclaration ident _ _ _) = Just (ident, d) - getDeclName d@(P.ExternDeclaration ident _) = Just (ident, d) - getDeclName (P.PositionedDeclaration _ _ d) = getDeclName d - getDeclName _ = Nothing + getDeclNames :: P.Declaration -> [(P.Ident, P.Declaration)] + getDeclNames d@(P.ValueDeclaration ident _ _ _) = [(ident, d)] + getDeclNames d@(P.TypeDeclaration ident _ ) = [(ident, d)] + getDeclNames d@(P.ExternDeclaration ident _) = [(ident, d)] + getDeclNames d@(P.TypeClassDeclaration _ _ _ ds) = map (second (const d)) $ concatMap getDeclNames ds + getDeclNames (P.PositionedDeclaration _ _ d) = getDeclNames d + getDeclNames _ = [] dctorNames :: P.Module -> [(N.ProperName, P.Declaration)] dctorNames = nubOnFst . concatMap go . P.exportedDeclarations diff --git a/psci/tests/Main.hs b/psci/tests/Main.hs index 17fd3c7ea3..2fdbba025a 100644 --- a/psci/tests/Main.hs +++ b/psci/tests/Main.hs @@ -8,12 +8,13 @@ import Control.Applicative import Control.Monad.Writer (runWriterT) import Control.Monad.Trans.Except (runExceptT) -import Data.List (isSuffixOf, sort) +import Data.List (sort) import System.Exit (exitFailure) import System.Console.Haskeline import System.FilePath (()) -import System.Directory (getCurrentDirectory, getDirectoryContents) +import System.Directory (getCurrentDirectory) +import qualified System.FilePath.Glob as Glob import Test.HUnit @@ -48,9 +49,14 @@ completionTestData = , (":mo", [":module"]) , (":b", [":browse"]) - -- :browse should complete modules - , (":b Prel", [":b Prelude", ":b Prelude.Unsafe"]) - , (":b Prelude.", [":b Prelude.Unsafe"]) + -- :browse should complete module names + , (":b Control.Monad.E", map (":b Control.Monad.Eff" ++) ["", ".Unsafe", ".Class", ".Console"]) + , (":b Control.Monad.Eff.", map (":b Control.Monad.Eff" ++) [".Unsafe", ".Class", ".Console"]) + + -- import should complete module names + , ("import Control.Monad.E", map ("import Control.Monad.Eff" ++) ["", ".Unsafe", ".Class", ".Console"]) + , ("import Control.Monad.Eff.", map ("import Control.Monad.Eff" ++) [".Unsafe", ".Class", ".Console"]) + , ("import qualified Control.Monad.Eff.", map ("import qualified Control.Monad.Eff" ++) [".Unsafe", ".Class", ".Console"]) -- :load, :module should complete file paths , (":l psci/tests/data/", [":l psci/tests/data/Sample.purs"]) @@ -66,8 +72,8 @@ completionTestData = , (":show a", []) -- :type should complete values and data constructors in scope - , (":type Prelude.Unsafe.un", [":type Prelude.Unsafe.unsafeIndex"]) - , (":type un", [":type unit"]) + , (":type Control.Monad.Eff.Console.lo", [":type Control.Monad.Eff.Console.log"]) + , (":type uni", [":type unit"]) , (":type E", [":type EQ"]) -- :kind should complete types in scope @@ -79,25 +85,19 @@ completionTestData = , (":type EQ ", []) , (":kind Ordering ", []) - -- import should complete module names - , ("import Control.Monad.S", ["import Control.Monad.ST"]) - , ("import qualified Control.Monad.S", ["import qualified Control.Monad.ST"]) - , ("import Control.Monad.", map ("import Control.Monad." ++) - ["Eff", "ST"]) - -- a few other import tests , ("impor", ["import"]) , ("import q", ["import qualified"]) - , ("import ", map ("import " ++) allModuleNames ++ ["import qualified"]) - , ("import Prelude.Unsafe ", []) + , ("import ", map ("import " ++) supportModules ++ ["import qualified"]) + , ("import Prelude ", []) -- String and number literals should not be completed , ("\"hi", []) , ("34", []) -- Identifiers and data constructors should be completed - , ("un", ["unit"]) - , ("Debug.Trace.", map ("Debug.Trace." ++) ["print", "trace"]) + , ("uni", ["unit"]) + , ("Control.Monad.Eff.Class.", ["Control.Monad.Eff.Class.liftEff"]) , ("G", ["GT"]) , ("Prelude.L", ["Prelude.LT"]) @@ -107,14 +107,6 @@ completionTestData = , ("Control.Monad.ST.new", ["Control.Monad.ST.newSTRef"]) ] where - allModuleNames = [ "Assert" - , "Control.Monad.Eff" - , "Control.Monad.ST" - , "Data.Function" - , "Debug.Trace" - , "Prelude" - , "Prelude.Unsafe" - ] assertCompletedOk :: (String, [String]) -> Assertion assertCompletedOk (line, expecteds) = do @@ -131,10 +123,12 @@ runCM act = do getPSCiState :: IO PSCiState getPSCiState = do cwd <- getCurrentDirectory - let preludeDir = cwd "tests" "prelude" - jsDir = preludeDir "js" - modulesOrFirstError <- loadAllModules [ preludeDir "Prelude.purs" ] - jsFiles <- map (jsDir ) . filter (".js" `isSuffixOf`) <$> getDirectoryContents jsDir + let supportDir = cwd "tests" "support" "flattened" + let supportFiles ext = Glob.globDir1 (Glob.compile ("*." ++ ext)) supportDir + pursFiles <- supportFiles "purs" + jsFiles <- supportFiles "js" + + modulesOrFirstError <- loadAllModules pursFiles foreignFiles <- forM jsFiles (\f -> (f,) <$> readFile f) Right (foreigns, _) <- runExceptT $ runWriterT $ P.parseForeignModulesFromFiles foreignFiles case modulesOrFirstError of @@ -148,3 +142,15 @@ controlMonadSTasST :: ImportedModule controlMonadSTasST = (s "Control.Monad.ST", P.Implicit, Just (s "ST")) where s = P.moduleNameFromString + +supportModules :: [String] +supportModules = + [ "Control.Monad.Eff.Class" + , "Control.Monad.Eff.Console" + , "Control.Monad.Eff" + , "Control.Monad.Eff.Unsafe" + , "Control.Monad.ST" + , "Data.Function" + , "Prelude" + , "Test.Assert" + ] diff --git a/purescript.cabal b/purescript.cabal index dbd8d797a2..5dc99a34ac 100644 --- a/purescript.cabal +++ b/purescript.cabal @@ -20,8 +20,8 @@ tested-with: GHC==7.8 extra-source-files: examples/passing/*.purs , examples/failing/*.purs - , tests/prelude/*.purs - , tests/prelude/js/*.js + , tests/support/flattened/*.purs + , tests/support/flattened/*.js source-repository head type: git @@ -236,7 +236,8 @@ executable psc-bundle test-suite tests build-depends: base >=4 && <5, containers -any, directory -any, filepath -any, mtl -any, parsec -any, purescript -any, - transformers -any, process -any, transformers-compat -any, time -any + transformers -any, process -any, transformers-compat -any, time -any, + Glob -any type: exitcode-stdio-1.0 main-is: Main.hs buildable: True diff --git a/tests/Main.hs b/tests/Main.hs index 4bf2edd1ed..977f52d00c 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -13,7 +13,7 @@ ----------------------------------------------------------------------------- {-# LANGUAGE DataKinds #-} -{-# LANGUAGE DoAndIfThenElse #-} +{-# LANGUAGE DoAndIfThenElse #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleInstances #-} @@ -44,6 +44,7 @@ import System.Exit import System.Process import System.FilePath import System.Directory +import qualified System.FilePath.Glob as Glob import Text.Parsec (ParseError) @@ -60,31 +61,23 @@ makeActions :: M.Map P.ModuleName (FilePath, P.ForeignJS) -> P.MakeActions Test makeActions foreigns = P.MakeActions getInputTimestamp getOutputTimestamp readExterns codegen progress where getInputTimestamp :: P.ModuleName -> Test (Either P.RebuildPolicy (Maybe UTCTime)) - getInputTimestamp mn - | isPreludeModule (P.runModuleName mn) = return (Left P.RebuildNever) + getInputTimestamp mn + | isSupportModule (P.runModuleName mn) = return (Left P.RebuildNever) | otherwise = return (Left P.RebuildAlways) where - isPreludeModule = flip elem - [ "Prelude.Unsafe" - , "Prelude" - , "Data.Function" - , "Control.Monad.Eff" - , "Control.Monad.ST" - , "Debug.Trace" - , "Assert" - ] - + isSupportModule = flip elem supportModules + getOutputTimestamp :: P.ModuleName -> Test (Maybe UTCTime) getOutputTimestamp mn = do let filePath = modulesDir P.runModuleName mn exists <- liftIO $ doesDirectoryExist filePath return (if exists then Just (error "getOutputTimestamp: read timestamp") else Nothing) - + readExterns :: P.ModuleName -> Test (FilePath, String) readExterns mn = do let filePath = modulesDir P.runModuleName mn "externs.purs" (filePath, ) <$> readTextFile filePath - + codegen :: CF.Module CF.Ann -> P.Environment -> P.SupplyVar -> P.Externs -> Test () codegen m _ nextVar exts = do let mn = CF.moduleName m @@ -101,15 +94,15 @@ makeActions foreigns = P.MakeActions getInputTimestamp getOutputTimestamp readEx writeTextFile jsFile pjs maybe (return ()) (writeTextFile foreignFile . snd) $ CF.moduleName m `M.lookup` foreigns writeTextFile externsFile exts - + readTextFile :: FilePath -> Test String readTextFile path = liftIO $ readFile path - + writeTextFile :: FilePath -> String -> Test () writeTextFile path text = liftIO $ do createDirectoryIfMissing True (takeDirectory path) writeFile path text - + progress :: String -> Test () progress = liftIO . putStrLn @@ -124,9 +117,9 @@ compile inputFiles foreigns = runTest $ do ms <- P.parseModulesFromFiles id fs P.make (makeActions foreigns) (map (\(k, v) -> (Right k, v)) ms) -assert :: [FilePath] -> - M.Map P.ModuleName (FilePath, P.ForeignJS) -> - (Either P.MultipleErrors P.Environment -> IO (Maybe String)) -> +assert :: [FilePath] -> + M.Map P.ModuleName (FilePath, P.ForeignJS) -> + (Either P.MultipleErrors P.Environment -> IO (Maybe String)) -> IO () assert inputFiles foreigns f = do e <- compile inputFiles foreigns @@ -139,7 +132,7 @@ assertCompiles :: [FilePath] -> M.Map P.ModuleName (FilePath, P.ForeignJS) -> IO assertCompiles inputFiles foreigns = do putStrLn $ "Assert " ++ last inputFiles ++ " compiles successfully" assert inputFiles foreigns $ \e -> - case e of + case e of Left errs -> return . Just . P.prettyPrintMultipleErrors False $ errs Right _ -> do process <- findNodeProcess @@ -161,26 +154,49 @@ assertDoesNotCompile inputFiles foreigns = do findNodeProcess :: IO (Maybe String) findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names - where + where names = ["nodejs", "node"] main :: IO () main = do + fetchSupportCode cwd <- getCurrentDirectory - - let preludeDir = cwd "tests" "prelude" - preludePurs = preludeDir "Prelude.purs" - jsDir = preludeDir "js" - jsFiles <- map (jsDir ) . filter (".js" `isSuffixOf`) <$> getDirectoryContents jsDir - foreignFiles <- forM jsFiles (\f -> (f,) <$> readFile f) + + let supportDir = cwd "tests" "support" "flattened" + let supportFiles ext = Glob.globDir1 (Glob.compile ("*." ++ ext)) supportDir + + supportPurs <- supportFiles "purs" + supportJS <- supportFiles "js" + + foreignFiles <- forM supportJS (\f -> (f,) <$> readFile f) Right (foreigns, _) <- runExceptT $ runWriterT $ P.parseForeignModulesFromFiles foreignFiles - + let passing = cwd "examples" "passing" passingTestCases <- getDirectoryContents passing forM_ passingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $ - assertCompiles [preludePurs, passing inputFile] foreigns + assertCompiles (supportPurs ++ [passing inputFile]) foreigns let failing = cwd "examples" "failing" failingTestCases <- getDirectoryContents failing forM_ failingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $ - assertDoesNotCompile [preludePurs, failing inputFile] foreigns + assertDoesNotCompile (supportPurs ++ [failing inputFile]) foreigns exitSuccess + +fetchSupportCode :: IO () +fetchSupportCode = do + setCurrentDirectory "tests/support" + callProcess "npm" ["install"] + callProcess "bower" ["install"] + callProcess "node" ["setup.js"] + setCurrentDirectory "../.." + +supportModules :: [String] +supportModules = + [ "Control.Monad.Eff.Class" + , "Control.Monad.Eff.Console" + , "Control.Monad.Eff" + , "Control.Monad.Eff.Unsafe" + , "Control.Monad.ST" + , "Data.Function" + , "Prelude" + , "Test.Assert" + ] diff --git a/tests/prelude/Prelude.purs b/tests/prelude/Prelude.purs deleted file mode 100644 index e99eade6b5..0000000000 --- a/tests/prelude/Prelude.purs +++ /dev/null @@ -1,631 +0,0 @@ --- | This snapshot is provided for the purposes of running the test suite. --- | It is not necessarily kept up to date with the official PureScript Prelude, --- | and should not be used in user code. --- | The official Prelude can be found at https://github.com/purescript/purescript-prelude - -module Prelude - ( Unit(..), unit - , ($), (#) - , length - , flip - , const - , asTypeOf - , otherwise - , (:), cons, concat - , Semigroupoid, (<<<), (>>>) - , Category, id - , Functor, (<$>), (<#>), void - , Apply, (<*>) - , Applicative, pure, liftA1 - , Bind, bind, (>>=) - , Monad, return, liftM1, ap - , Semigroup, (<>), (++) - , Semiring, (+), zero, (*), one - , ModuloSemiring, (/), mod, jsMod, (%) - , Ring, (-), negate - , Num - , DivisionRing - , Eq, (==), (/=) - , Ordering(..), Ord, compare, (<), (>), (<=), (>=) - , Bounded, top, bottom - , Lattice, sup, inf, (||), (&&) - , BoundedLattice - , ComplementedLattice, not - , DistributiveLattice - , BooleanAlgebra - , Show, show - ) where - - newtype Unit = Unit {} - - unit :: Unit - unit = Unit {} - - foreign import length :: forall a. Array a -> Number - - infixr 0 $ - infixl 0 # - - ($) :: forall a b. (a -> b) -> a -> b - ($) f x = f x - - (#) :: forall a b. a -> (a -> b) -> b - (#) x f = f x - - flip :: forall a b c. (a -> b -> c) -> b -> a -> c - flip f b a = f a b - - const :: forall a b. a -> b -> a - const a _ = a - - asTypeOf :: forall a. a -> a -> a - asTypeOf x _ = x - - otherwise :: Boolean - otherwise = true - - foreign import cons :: forall a. a -> Array a -> Array a - - infixr 6 : - - (:) :: forall a. a -> Array a -> Array a - (:) = cons - - foreign import concat :: forall a. Array a -> Array a -> Array a - - infixr 9 >>> - infixr 9 <<< - - class Semigroupoid a where - (<<<) :: forall b c d. a c d -> a b c -> a b d - - instance semigroupoidArr :: Semigroupoid (->) where - (<<<) f g x = f (g x) - - (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d - (>>>) f g = g <<< f - - class (Semigroupoid a) <= Category a where - id :: forall t. a t t - - instance categoryArr :: Category (->) where - id x = x - - infixl 4 <$> - infixl 1 <#> - - class Functor f where - (<$>) :: forall a b. (a -> b) -> f a -> f b - - instance functorArr :: Functor ((->) r) where - (<$>) = (<<<) - - (<#>) :: forall f a b. (Functor f) => f a -> (a -> b) -> f b - (<#>) fa f = f <$> fa - - void :: forall f a. (Functor f) => f a -> f Unit - void fa = const unit <$> fa - - infixl 4 <*> - - class (Functor f) <= Apply f where - (<*>) :: forall a b. f (a -> b) -> f a -> f b - - instance applyArr :: Apply ((->) r) where - (<*>) f g x = f x (g x) - - class (Apply f) <= Applicative f where - pure :: forall a. a -> f a - - instance applicativeArr :: Applicative ((->) r) where - pure = const - - return :: forall m a. (Applicative m) => a -> m a - return = pure - - liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b - liftA1 f a = pure f <*> a - - infixl 1 >>= - - (>>=) :: forall m a b. (Bind m) => m a -> (a -> m b) -> m b - (>>=) = bind - - class (Apply m) <= Bind m where - bind :: forall a b. m a -> (a -> m b) -> m b - - instance bindArr :: Bind ((->) r) where - bind m f x = f (m x) x - - class (Applicative m, Bind m) <= Monad m - - instance monadArr :: Monad ((->) r) - - liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b - liftM1 f a = do - a' <- a - return (f a') - - ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b - ap f a = do - f' <- f - a' <- a - return (f' a') - - infixr 5 <> - infixr 5 ++ - - class Semigroup a where - (<>) :: a -> a -> a - - (++) :: forall s. (Semigroup s) => s -> s -> s - (++) = (<>) - - instance semigroupString :: Semigroup String where - (<>) = concatString - - instance semigroupUnit :: Semigroup Unit where - (<>) _ _ = unit - - instance semigroupArr :: (Semigroup s') => Semigroup (s -> s') where - (<>) f g = \x -> f x <> g x - - instance semigroupOrdering :: Semigroup Ordering where - (<>) LT _ = LT - (<>) GT _ = GT - (<>) EQ y = y - - foreign import concatString :: String -> String -> String - - infixl 6 + - infixl 7 * - - class Semiring a where - (+) :: a -> a -> a - zero :: a - (*) :: a -> a -> a - one :: a - - instance semiringNumber :: Semiring Number where - (+) = numAdd - zero = 0.0 - (*) = numMul - one = 1.0 - - instance semiringUnit :: Semiring Unit where - (+) _ _ = unit - zero = unit - (*) _ _ = unit - one = unit - - infixl 6 - - - class (Semiring a) <= Ring a where - (-) :: a -> a -> a - - instance ringNumber :: Ring Number where - (-) = numSub - - instance ringUnit :: Ring Unit where - (-) _ _ = unit - - negate :: forall a. (Ring a) => a -> a - negate a = zero - a - - infixl 7 / - - class (Semiring a) <= ModuloSemiring a where - (/) :: a -> a -> a - mod :: a -> a -> a - - instance moduloSemiringNumber :: ModuloSemiring Number where - (/) = numDiv - mod _ _ = 0.0 - - instance moduloSemiringUnit :: ModuloSemiring Unit where - (/) _ _ = unit - mod _ _ = unit - - foreign import jsMod :: Number -> Number -> Number - - infixl 7 % - - (%) = jsMod - - class (Ring a, ModuloSemiring a) <= DivisionRing a - - instance divisionRingNumber :: DivisionRing Number - - instance divisionRingUnit :: DivisionRing Unit - - class (DivisionRing a) <= Num a - - instance numNumber :: Num Number - - instance numUnit :: Num Unit - - foreign import numAdd :: Number -> Number -> Number - - foreign import numMul :: Number -> Number -> Number - - foreign import numDiv :: Number -> Number -> Number - - foreign import numSub :: Number -> Number -> Number - - infix 4 == - infix 4 /= - - class Eq a where - (==) :: a -> a -> Boolean - (/=) :: a -> a -> Boolean - - instance eqBoolean :: Eq Boolean where - (==) = refEq - (/=) = refIneq - - instance eqNumber :: Eq Number where - (==) = refEq - (/=) = refIneq - - instance eqInt :: Eq Int where - (==) = refEq - (/=) = refIneq - - instance eqChar :: Eq Char where - (==) = refEq - (/=) = refIneq - - instance eqString :: Eq String where - (==) = refEq - (/=) = refIneq - - instance eqUnit :: Eq Unit where - (==) _ _ = true - (/=) _ _ = false - - instance eqArray :: (Eq a) => Eq (Array a) where - (==) = eqArrayImpl (==) - (/=) xs ys = not (xs == ys) - - instance eqOrdering :: Eq Ordering where - (==) LT LT = true - (==) GT GT = true - (==) EQ EQ = true - (==) _ _ = false - (/=) x y = not (x == y) - - foreign import refEq :: forall a. a -> a -> Boolean - - foreign import refIneq :: forall a. a -> a -> Boolean - - foreign import eqArrayImpl :: forall a. (a -> a -> Boolean) -> Array a -> Array a -> Boolean - - data Ordering = LT | GT | EQ - - class (Eq a) <= Ord a where - compare :: a -> a -> Ordering - - instance ordBoolean :: Ord Boolean where - compare false false = EQ - compare false true = LT - compare true true = EQ - compare true false = GT - - instance ordNumber :: Ord Number where - compare = unsafeCompare - - instance ordString :: Ord String where - compare = unsafeCompare - - instance ordUnit :: Ord Unit where - compare _ _ = EQ - - instance ordArray :: (Ord a) => Ord (Array a) where - compare xs ys = compare 0.0 $ ordArrayImpl (\x y -> case compare x y of - EQ -> 0.0 - LT -> -1.0 - GT -> 1.0) xs ys - - foreign import ordArrayImpl :: forall a. (a -> a -> Number) -> Array a -> Array a -> Number - - instance ordOrdering :: Ord Ordering where - compare LT LT = EQ - compare EQ EQ = EQ - compare GT GT = EQ - compare LT _ = LT - compare EQ LT = GT - compare EQ GT = LT - compare GT _ = GT - - infixl 4 < - infixl 4 > - infixl 4 <= - infixl 4 >= - - (<) :: forall a. (Ord a) => a -> a -> Boolean - (<) a1 a2 = case a1 `compare` a2 of - LT -> true - _ -> false - - (>) :: forall a. (Ord a) => a -> a -> Boolean - (>) a1 a2 = case a1 `compare` a2 of - GT -> true - _ -> false - - (<=) :: forall a. (Ord a) => a -> a -> Boolean - (<=) a1 a2 = case a1 `compare` a2 of - GT -> false - _ -> true - - (>=) :: forall a. (Ord a) => a -> a -> Boolean - (>=) a1 a2 = case a1 `compare` a2 of - LT -> false - _ -> true - - unsafeCompare :: forall a. a -> a -> Ordering - unsafeCompare = unsafeCompareImpl LT EQ GT - - foreign import unsafeCompareImpl :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering - - class (Ord a) <= Bounded a where - top :: a - bottom :: a - - instance boundedBoolean :: Bounded Boolean where - top = true - bottom = false - - instance boundedUnit :: Bounded Unit where - top = unit - bottom = unit - - instance boundedOrdering :: Bounded Ordering where - top = GT - bottom = LT - - class (Ord a) <= Lattice a where - sup :: a -> a -> a - inf :: a -> a -> a - - instance latticeBoolean :: Lattice Boolean where - sup = boolOr - inf = boolAnd - - instance latticeUnit :: Lattice Unit where - sup _ _ = unit - inf _ _ = unit - - infixr 2 || - infixr 3 && - - (||) :: forall a. (Lattice a) => a -> a -> a - (||) = sup - - (&&) :: forall a. (Lattice a) => a -> a -> a - (&&) = inf - - class (Bounded a, Lattice a) <= BoundedLattice a - - instance boundedLatticeBoolean :: BoundedLattice Boolean - - instance boundedLatticeUnit :: BoundedLattice Unit - - class (BoundedLattice a) <= ComplementedLattice a where - not :: a -> a - - instance complementedLatticeBoolean :: ComplementedLattice Boolean where - not = boolNot - - instance complementedLatticeUnit :: ComplementedLattice Unit where - not _ = unit - - class (Lattice a) <= DistributiveLattice a - - instance distributiveLatticeBoolean :: DistributiveLattice Boolean - - instance distributiveLatticeUnit :: DistributiveLattice Unit - - class (ComplementedLattice a, DistributiveLattice a) <= BooleanAlgebra a - - instance booleanAlgebraBoolean :: BooleanAlgebra Boolean - - instance booleanAlgebraUnit :: BooleanAlgebra Unit - - foreign import boolOr :: Boolean -> Boolean -> Boolean - - foreign import boolAnd :: Boolean -> Boolean -> Boolean - - foreign import boolNot :: Boolean -> Boolean - - class Show a where - show :: a -> String - - instance showBoolean :: Show Boolean where - show true = "true" - show false = "false" - - instance showNumber :: Show Number where - show = showNumberImpl - - instance showString :: Show String where - show = showStringImpl - - instance showUnit :: Show Unit where - show _ = "unit" - - instance showArray :: (Show a) => Show (Array a) where - show = showArrayImpl show - - instance showOrdering :: Show Ordering where - show LT = "LT" - show GT = "GT" - show EQ = "EQ" - - foreign import showNumberImpl :: Number -> String - - foreign import showStringImpl :: String -> String - - foreign import showArrayImpl :: forall a. (a -> String) -> Array a -> String - -module Data.Function where - - import Prelude - - on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c - on f g x y = g x `f` g y - - foreign import data Fn0 :: * -> * - - foreign import data Fn1 :: * -> * -> * - - foreign import data Fn2 :: * -> * -> * -> * - - foreign import data Fn3 :: * -> * -> * -> * -> * - - foreign import data Fn4 :: * -> * -> * -> * -> * -> * - - foreign import data Fn5 :: * -> * -> * -> * -> * -> * -> * - - foreign import data Fn6 :: * -> * -> * -> * -> * -> * -> * -> * - - foreign import data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> * - - foreign import data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * - - foreign import data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * - - foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * - - foreign import mkFn0 :: forall a. (Unit -> a) -> Fn0 a - - foreign import mkFn1 :: forall a b. (a -> b) -> Fn1 a b - - foreign import mkFn2 :: forall a b c. (a -> b -> c) -> Fn2 a b c - - foreign import mkFn3 :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d - - foreign import mkFn4 :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e - - foreign import mkFn5 :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f - - 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 - - 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 - - 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 - - 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 - - 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 - - foreign import runFn0 :: forall a. Fn0 a -> a - - foreign import runFn1 :: forall a b. Fn1 a b -> a -> b - - foreign import runFn2 :: forall a b c. Fn2 a b c -> a -> b -> c - - foreign import runFn3 :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d - - foreign import runFn4 :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e - - foreign import runFn5 :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f - - 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 - - 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 - - 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 - - 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 - - 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 - -module Assert where - - import Prelude - import Control.Monad.Eff - - foreign import data Assert :: ! - - foreign import error :: forall a. String -> a - - foreign import assertPartial :: forall e a. (Unit -> a) -> Eff (assert :: Assert | e) Unit - - assert :: forall e. Boolean -> Eff (assert :: Assert | e) Unit - assert true = return unit - assert false = error "Assertion failed!" - -module Prelude.Unsafe where - - foreign import unsafeIndex :: forall a. Array a -> Number -> a - -module Control.Monad.Eff - ( Eff() - , Pure() - , runPure - , untilE, whileE - ) where - - import Prelude - - foreign import data Eff :: # ! -> * -> * - - foreign import returnE :: forall e a. a -> Eff e a - - foreign import bindE :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b - - type Pure a = forall e. Eff e a - - foreign import runPure :: forall a. Pure a -> a - - instance functorEff :: Functor (Eff e) where - (<$>) = liftA1 - - instance applyEff :: Apply (Eff e) where - (<*>) = ap - - instance applicativeEff :: Applicative (Eff e) where - pure = returnE - - instance bindEff :: Bind (Eff e) where - bind = bindE - - instance monadEff :: Monad (Eff e) - - foreign import untilE :: forall e. Eff e Boolean -> Eff e Unit - - foreign import whileE :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit - -module Debug.Trace where - - import Prelude - import Control.Monad.Eff - - foreign import data Trace :: ! - - foreign import trace :: forall r. String -> Eff (trace :: Trace | r) Unit - - print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit - print o = trace (show o) - -module Control.Monad.ST where - - import Prelude - import Control.Monad.Eff - - foreign import data ST :: * -> ! - - foreign import data STRef :: * -> * -> * - - foreign import newSTRef :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a) - - foreign import readSTRef :: forall a h r. STRef h a -> Eff (st :: ST h | r) a - - foreign import modifySTRef :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a - - foreign import writeSTRef :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a - - foreign import runST :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a - - pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a - pureST st = runPure (runST st) diff --git a/tests/prelude/js/Assert.js b/tests/prelude/js/Assert.js deleted file mode 100644 index 901afe43e7..0000000000 --- a/tests/prelude/js/Assert.js +++ /dev/null @@ -1,19 +0,0 @@ -/* global exports */ -"use strict"; - -// module Assert - -exports.error = function(msg) { - throw msg; -}; - -exports.assertPartial = function(f) { - return function() { - try { - return f(); - } catch (e) { - if (e instanceof Error) return; - throw new Error('Pattern match failure is not Error'); - } - }; -}; \ No newline at end of file diff --git a/tests/prelude/js/Control.Monad.Eff.js b/tests/prelude/js/Control.Monad.Eff.js deleted file mode 100644 index e44b66d1c3..0000000000 --- a/tests/prelude/js/Control.Monad.Eff.js +++ /dev/null @@ -1,40 +0,0 @@ -/* global exports */ -"use strict"; - -// module Control.Monad.Eff - -exports.returnE = function (a) { - return function () { - return a; - }; -}; - -exports.bindE = function (a) { - return function (f) { - return function () { - return f(a())(); - }; - }; -}; - -exports.runPure = function (f) { - return f(); -}; - -exports.untilE = function (f) { - return function () { - while (!f()); - return {}; - }; -}; - -exports.whileE = function (f) { - return function (a) { - return function () { - while (f()) { - a(); - } - return {}; - }; - }; -}; \ No newline at end of file diff --git a/tests/prelude/js/Control.Monad.ST.js b/tests/prelude/js/Control.Monad.ST.js deleted file mode 100644 index a7ccda3bb8..0000000000 --- a/tests/prelude/js/Control.Monad.ST.js +++ /dev/null @@ -1,38 +0,0 @@ -/* global exports */ -"use strict"; - -// module Control.Monad.ST - -exports.newSTRef = function (val) { - return function () { - return { value: val }; - }; -}; - -exports.readSTRef = function (ref) { - return function () { - return ref.value; - }; -}; - -exports.modifySTRef = function (ref) { - return function (f) { - return function () { - /* jshint boss: true */ - return ref.value = f(ref.value); - }; - }; -}; - -exports.writeSTRef = function (ref) { - return function (a) { - return function () { - /* jshint boss: true */ - return ref.value = a; - }; - }; -}; - -exports.runST = function (f) { - return f; -}; \ No newline at end of file diff --git a/tests/prelude/js/Data.Function.js b/tests/prelude/js/Data.Function.js deleted file mode 100644 index e13a843c42..0000000000 --- a/tests/prelude/js/Data.Function.js +++ /dev/null @@ -1,233 +0,0 @@ -/* global exports */ -"use strict"; - -// module Data.Function - -exports.mkFn0 = function (fn) { - return function () { - return fn({}); - }; -}; - -exports.mkFn1 = function (fn) { - return function (a) { - return fn(a); - }; -}; - -exports.mkFn2 = function (fn) { - /* jshint maxparams: 2 */ - return function (a, b) { - return fn(a)(b); - }; -}; - -exports.mkFn3 = function (fn) { - /* jshint maxparams: 3 */ - return function (a, b, c) { - return fn(a)(b)(c); - }; -}; - -exports.mkFn4 = function (fn) { - /* jshint maxparams: 4 */ - return function (a, b, c, d) { - return fn(a)(b)(c)(d); - }; -}; - -exports.mkFn5 = function (fn) { - /* jshint maxparams: 5 */ - return function (a, b, c, d, e) { - return fn(a)(b)(c)(d)(e); - }; -}; - -exports.mkFn6 = function (fn) { - /* jshint maxparams: 6 */ - return function (a, b, c, d, e, f) { - return fn(a)(b)(c)(d)(e)(f); - }; -}; - -exports.mkFn7 = function (fn) { - /* jshint maxparams: 7 */ - return function (a, b, c, d, e, f, g) { - return fn(a)(b)(c)(d)(e)(f)(g); - }; -}; - -exports.mkFn8 = function (fn) { - /* jshint maxparams: 8 */ - return function (a, b, c, d, e, f, g, h) { - return fn(a)(b)(c)(d)(e)(f)(g)(h); - }; -}; - -exports.mkFn9 = function (fn) { - /* jshint maxparams: 9 */ - return function (a, b, c, d, e, f, g, h, i) { - return fn(a)(b)(c)(d)(e)(f)(g)(h)(i); - }; -}; - -exports.mkFn10 = function (fn) { - /* jshint maxparams: 10 */ - return function (a, b, c, d, e, f, g, h, i, j) { - return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j); - }; -}; - -exports.runFn0 = function (fn) { - return fn(); -}; - -exports.runFn1 = function (fn) { - return function (a) { - return fn(a); - }; -}; - -exports.runFn2 = function (fn) { - return function (a) { - return function (b) { - return fn(a, b); - }; - }; -}; - -exports.runFn3 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return fn(a, b, c); - }; - }; - }; -}; - -exports.runFn4 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return function (d) { - return fn(a, b, c, d); - }; - }; - }; - }; -}; - -exports.runFn5 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return function (d) { - return function (e) { - return fn(a, b, c, d, e); - }; - }; - }; - }; - }; -}; - -exports.runFn6 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return function (d) { - return function (e) { - return function (f) { - return fn(a, b, c, d, e, f); - }; - }; - }; - }; - }; - }; -}; - -exports.runFn7 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return function (d) { - return function (e) { - return function (f) { - return function (g) { - return fn(a, b, c, d, e, f, g); - }; - }; - }; - }; - }; - }; - }; -}; - -exports.runFn8 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return function (d) { - return function (e) { - return function (f) { - return function (g) { - return function (h) { - return fn(a, b, c, d, e, f, g, h); - }; - }; - }; - }; - }; - }; - }; - }; -}; - -exports.runFn9 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return function (d) { - return function (e) { - return function (f) { - return function (g) { - return function (h) { - return function (i) { - return fn(a, b, c, d, e, f, g, h, i); - }; - }; - }; - }; - }; - }; - }; - }; - }; -}; - -exports.runFn10 = function (fn) { - return function (a) { - return function (b) { - return function (c) { - return function (d) { - return function (e) { - return function (f) { - return function (g) { - return function (h) { - return function (i) { - return function (j) { - return fn(a, b, c, d, e, f, g, h, i, j); - }; - }; - }; - }; - }; - }; - }; - }; - }; - }; -}; \ No newline at end of file diff --git a/tests/prelude/js/Debug.Trace.js b/tests/prelude/js/Debug.Trace.js deleted file mode 100644 index aec8fcd9d9..0000000000 --- a/tests/prelude/js/Debug.Trace.js +++ /dev/null @@ -1,11 +0,0 @@ -/* global exports */ -"use strict"; - -// module Debug.Trace - -exports.trace = function(s) { - return function() { - console.log(s); - return {}; - }; -}; \ No newline at end of file diff --git a/tests/prelude/js/Prelude.Unsafe.js b/tests/prelude/js/Prelude.Unsafe.js deleted file mode 100644 index 0ce41d9b05..0000000000 --- a/tests/prelude/js/Prelude.Unsafe.js +++ /dev/null @@ -1,10 +0,0 @@ -/* global exports */ -"use strict"; - -// module Prelude.Unsafe - -exports.unsafeIndex = function(xs) { - return function(n) { - return xs[n]; - }; -}; \ No newline at end of file diff --git a/tests/prelude/js/Prelude.js b/tests/prelude/js/Prelude.js deleted file mode 100644 index 2488a133fb..0000000000 --- a/tests/prelude/js/Prelude.js +++ /dev/null @@ -1,150 +0,0 @@ -/* global exports */ -"use strict"; - -// module Prelude - -exports.cons = function(e) { - return function(l) { - return [e].concat(l); - }; -}; - -exports.concat = function(l1) { - return function(l2) { - return l1.concat(l2); - }; -}; - -exports.length = function(a) { - return a.length; -}; - -exports.concatString = function(s1) { - return function(s2) { - return s1 + s2; - }; -}; - -exports.numAdd = function (n1) { - return function (n2) { - return n1 + n2; - }; -}; - -exports.numMul = function (n1) { - return function (n2) { - return n1 * n2; - }; -}; - -exports.numDiv = function (n1) { - return function (n2) { - return n1 / n2; - }; -}; - -exports.numSub = function (n1) { - return function (n2) { - return n1 - n2; - }; -}; - -exports.jsMod = function(x) { - return function (y) { - return x % y; - }; -}; - -exports.refEq = function(r1) { - return function(r2) { - return r1 === r2; - }; -}; - -exports.refIneq = function(r1) { - return function(r2) { - return r1 !== r2; - }; -}; - -exports.eqArrayImpl = function(f) { - return function(xs) { - return function(ys) { - if (xs.length !== ys.length) return false; - for (var i = 0; i < xs.length; i++) { - if (!f(xs[i])(ys[i])) return false; - } - return true; - }; - }; -}; - -exports.ordArrayImpl = function(f) { - return function (xs) { - return function (ys) { - var i = 0; - while (i < xs.length && i < ys.length) { - var x = xs[i]; - var y = ys[i]; - var o = f(x)(y); - if (o !== 0) { - return o; - } - } - if (xs.length == ys.length) { - return 0; - } else if (xs.length > ys.length) { - return 1; - } else { - return -1; - } - }; - }; -}; - -exports.unsafeCompareImpl = function(lt) { - return function(eq) { - return function(gt) { - return function(x) { - return function(y) { - return x < y ? lt : x > y ? gt : eq; - }; - }; - }; - }; -}; - -exports.boolOr = function (b1) { - return function (b2) { - return b1 || b2; - }; -}; - -exports.boolAnd = function (b1) { - return function (b2) { - return b1 && b2; - }; -}; - -exports.boolNot = function (b) { - return !b; -}; - -exports.showNumberImpl = function (n) { - /* jshint bitwise: false */ - return n === (n | 0) ? n + ".0" : n.toString(); -}; - -exports.showStringImpl = function (s) { - return JSON.stringify(s); -}; - -exports.showArrayImpl = function (f) { - return function (xs) { - var ss = []; - for (var i = 0, l = xs.length; i < l; i++) { - ss[i] = f(xs[i]); - } - return "[" + ss.join(",") + "]"; - }; -}; \ No newline at end of file diff --git a/tests/support/.gitignore b/tests/support/.gitignore new file mode 100644 index 0000000000..68b9e27759 --- /dev/null +++ b/tests/support/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +bower_components/ diff --git a/tests/support/bower.json b/tests/support/bower.json new file mode 100644 index 0000000000..9d1b7d2d98 --- /dev/null +++ b/tests/support/bower.json @@ -0,0 +1,11 @@ +{ + "name": "purescript-test-suite-support", + "dependencies": { + "purescript-eff": "0.1.0", + "purescript-prelude": "0.1.1", + "purescript-assert": "0.1.1", + "purescript-st": "0.1.0", + "purescript-console": "0.1.0", + "purescript-functions": "0.1.0" + } +} diff --git a/tests/support/package.json b/tests/support/package.json new file mode 100644 index 0000000000..fa082030a6 --- /dev/null +++ b/tests/support/package.json @@ -0,0 +1,7 @@ +{ + "private": true, + "dependencies": { + "bower": "^1.4.1", + "glob": "^5.0.14" + } +} diff --git a/tests/support/setup.js b/tests/support/setup.js new file mode 100644 index 0000000000..46b87b50f1 --- /dev/null +++ b/tests/support/setup.js @@ -0,0 +1,22 @@ +var glob = require("glob"); +var fs = require("fs"); + +try { + fs.mkdirSync("./flattened"); +} catch(e) { + // ignore the error if it already exists + if (e.code !== "EEXIST") { + throw(e); + } +} + +glob("bower_components/*/src/**/*.{js,purs}", function(err, files) { + if (err) throw err; + files.forEach(function(file) { + // We join with "-" because Cabal is weird about file extensions. + var dest = "./flattened/" + file.split("/").slice(3).join("-"); + console.log("Copying " + file + " to " + dest); + var content = fs.readFileSync(file, "utf-8"); + fs.writeFileSync(dest, content, "utf-8"); + }); +})