git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Speed up test suite
7fe90c8Phil Freeman
examples/failing/Arrays.purs+1−1
@@ -1,4 +1,4 @@
1−module Data.Array where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
examples/failing/Do.purs+1−1
@@ -1,4 +1,4 @@
1−module Do where
1+module Main where
2
2
3test1 = do let x = 1
3test1 = do let x = 1
4
4
examples/failing/ExportExplicit.pursdeleted−16
@@ -1,16 +0,0 @@
1−module M1 (X(..)) where
2−
3− data X = X | Y
4− data Z = Z
5−
6−module Main where
7−
8− import M1
9−
10− testX = X
11− testY = Y
12−
13− -- should fail as Z is not exported from M1
14− testZ = Z
15−
16− main = Debug.Trace.trace "Done"
examples/failing/ExportExplicit2.pursdeleted−13
@@ -1,13 +0,0 @@
1−module M1 (x) where
2−
3− x = 1
4− y = 0
5−
6−module Main where
7−
8− import M1
9−
10− -- should fail as y is not exported from M1
11− testY = y
12−
13− main = Debug.Trace.trace "Done"
examples/failing/Import.pursdeleted−3
@@ -1,3 +0,0 @@
1−module Module where
2−
3− import UndefinedModule
examples/failing/ImportExplicit.pursdeleted−14
@@ -1,14 +0,0 @@
1−module M1 where
2−
3− data X = X | Y
4− data Z = Z
5−
6−module Main where
7−
8− import M1 (X(..))
9−
10− testX = X
11− testY = Y
12− testZ = Z
13−
14− main = Debug.Trace.trace "Done"
examples/failing/KindError.purs+1−1
@@ -1,3 +1,3 @@
1−module KindError where
1+module Main where
2
2
3 data KindError f a = One f | Two (f a)
3 data KindError f a = One f | Two (f a)
examples/failing/ModuleDeps.pursdeleted−7
@@ -1,7 +0,0 @@
1−module M1 where
2−
3−import M2
4−
5−module M2 where
6−
7−import M1
examples/failing/MutRec2.purs+1−1
@@ -1,3 +1,3 @@
1−module MutRec2 where
1+module Main where
2
2
3x = x
3x = x
examples/failing/NullaryAbs.purs+1−1
@@ -1,3 +1,3 @@
1−module NullaryAbs where
1+module Main where
2
2
3 func = \ -> "no"
3 func = \ -> "no"
examples/failing/Object.purs+1−1
@@ -1,4 +1,4 @@
1−module Object where
1+module Main where
2
2
3test o = o.foo
3test o = o.foo
4
4
examples/failing/Rank2Types.purs+1−1
@@ -1,4 +1,4 @@
1−module Rank2Types where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
examples/failing/ReadShow.pursdeleted−7
@@ -1,7 +0,0 @@
1−module ReadShow where
2−
3− foreign import read :: forall a. String -> a
4−
5− foreign import show :: forall a. a -> String
6−
7− test = \x -> show (read x)
examples/failing/Reserved.purs+1−1
@@ -1,4 +1,4 @@
1−module Reserved where
1+module Main where
2
2
3(<) :: Number -> Number -> Number
3(<) :: Number -> Number -> Number
4(<) a b = !(a >= b)
4(<) a b = !(a >= b)
examples/failing/SkolemEscape.purs+1−1
@@ -1,4 +1,4 @@
1−module SkolemEscape where
1+module Main where
2
2
3 foreign import foo :: (forall a. a -> a) -> Number
3 foreign import foo :: (forall a. a -> a) -> Number
4
4
examples/failing/SkolemEscape2.purs+1−1
@@ -1,4 +1,4 @@
1−module SkolemEscape where
1+module Main where
2
2
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
examples/failing/TypeClassInstances.purs+1−1
@@ -1,4 +1,4 @@
1−module TypeClassInstances where
1+module Main where
2
2
3class A a where
3class A a where
4 a :: a -> String
4 a :: a -> String
examples/failing/TypeClasses2.purs+1−10
@@ -1,15 +1,6 @@
1−module TC1 where
1+module Main where
2
2
3class Show a where
3class Show a where
4 show :: a -> String
4 show :: a -> String
5
5
6−module TC2 where
7−
8−instance TC1.Show String where
9− show s = s
10−
11−module TC3 where
12−
13−import TC1
14−
15test = show "testing"
6test = show "testing"
examples/failing/TypeError.purs+1−1
@@ -1,4 +1,4 @@
1−module TypeError where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
examples/failing/TypeSynonyms.purs+1−1
@@ -1,4 +1,4 @@
1−module TypeSynonyms where
1+module Main where
2
2
3type T1 = [T2]
3type T1 = [T2]
4
4
examples/failing/TypeSynonyms2.purs+1−1
@@ -1,4 +1,4 @@
1−module TypeSynonyms2 where
1+module Main where
2
2
3class Foo a where
3class Foo a where
4 foo :: a -> String
4 foo :: a -> String
examples/failing/TypeSynonyms3.purs+2−6
@@ -1,13 +1,9 @@
1−module TypeSynonyms2 where
1+module Main where
2
2
3class Foo a where
3class Foo a where
4 foo :: a -> String
4 foo :: a -> String
5
5
6type Bar = String
6type Bar = String
7
7
8−module M where
9−
10−import TypeSynonyms2
11−
12−instance TypeSynonyms2.Foo Bar where
8+instance Foo Bar where
13 foo s = s
9 foo s = s
examples/passing/ExportExplicit.purs → examples/manual/ExportExplicit.pursrenamed

The content is the same.

examples/passing/ExportExplicit2.purs → examples/manual/ExportExplicit2.pursrenamed

The content is the same.

examples/failing/ExportExplicit3.purs → examples/manual/ExportExplicit3.pursrenamed

The content is the same.

examples/failing/ExportExplicit4.purs → examples/manual/ExportExplicit4.pursrenamed

The content is the same.

examples/failing/ExportExplicit5.purs → examples/manual/ExportExplicit5.pursrenamed

The content is the same.

examples/failing/ExportExplicit6.purs → examples/manual/ExportExplicit6.pursrenamed

The content is the same.

examples/passing/Import.purs → examples/manual/Import.pursrenamed

The content is the same.

examples/passing/ImportExplicit.purs → examples/manual/ImportExplicit.pursrenamed

The content is the same.

examples/failing/ImportExplicit2.purs → examples/manual/ImportExplicit2.pursrenamed

The content is the same.

examples/failing/ImportExplicit3.purs → examples/manual/ImportExplicit3.pursrenamed

The content is the same.

examples/failing/ImportModule.purs → examples/manual/ImportModule.pursrenamed

The content is the same.

examples/passing/Module.purs → examples/manual/Module.pursrenamed

The content is the same.

examples/passing/ModuleDeps.purs → examples/manual/ModuleDeps.pursrenamed

The content is the same.

examples/passing/RedefinedFixity.purs → examples/manual/RedefinedFixity.pursrenamed

The content is the same.

examples/passing/Applicative.purs+1−3
@@ -1,4 +1,4 @@
1−module Applicative where
1+module Main where
2
2
3class Applicative f where
3class Applicative f where
4 pure :: forall a. a -> f a
4 pure :: forall a. a -> f a
@@ -11,6 +11,4 @@ instance applicativeMaybe :: Applicative Maybe where
11 (<*>) (Just f) (Just a) = Just (f a)
11 (<*>) (Just f) (Just a) = Just (f a)
12 (<*>) _ _ = Nothing
12 (<*>) _ _ = Nothing
13
13
14−module Main where
15−
16main = Debug.Trace.trace "Done"
14main = Debug.Trace.trace "Done"
examples/passing/ArrayType.purs+3−5
@@ -1,4 +1,6 @@
1−module ArrayType where
1+module Main where
2+
3+import Data.Array
2
4
3test :: [] Number
5test :: [] Number
4test = [1, 2, 3]
6test = [1, 2, 3]
@@ -6,12 +8,8 @@ test = [1, 2, 3]
6class Functor f where
8class Functor f where
7 fmap :: forall a b. (a -> b) -> f a -> f b
9 fmap :: forall a b. (a -> b) -> f a -> f b
8
10
9−foreign import (:) :: forall a. a -> [a] -> [a]
10−
11instance functorArray :: Functor [] where
11instance functorArray :: Functor [] where
12 fmap _ [] = []
12 fmap _ [] = []
13 fmap f (x:xs) = f x : fmap f xs
13 fmap f (x:xs) = f x : fmap f xs
14−
15−module Main where
16
14
17main = Debug.Trace.trace "Done"
15main = Debug.Trace.trace "Done"
examples/passing/Arrays.purs+2−6
@@ -1,6 +1,7 @@
1−module Data.ArrayTests where
1+module Main where
2
2
3import Prelude
3import Prelude
4+import Data.Array
4
5
5test1 arr = arr !! 0 + arr !! 1 + 1
6test1 arr = arr !! 0 + arr !! 1 + 1
6
7
@@ -21,11 +22,6 @@ test4 = \arr -> case arr of
21 [_] -> 0
22 [_] -> 0
22 x : y : xs -> x * y + test4 xs
23 x : y : xs -> x * y + test4 xs
23
24
24−module Main where
25−
26−import Data.Array
27−import Prelude
28−
29main = do
25main = do
30 let x = [3,2,1]
26 let x = [3,2,1]
31 let y = sort x
27 let y = sort x
examples/passing/Auto.purs+2−4
@@ -1,4 +1,4 @@
1−module Auto where
1+module Main where
2
2
3 data Auto s i o = Auto { state :: s, step :: s -> i -> o }
3 data Auto s i o = Auto { state :: s, step :: s -> i -> o }
4
4
@@ -9,7 +9,5 @@ module Auto where
9
9
10 run :: forall i o. SomeAuto i o -> i -> o
10 run :: forall i o. SomeAuto i o -> i -> o
11 run = \s i -> s (\a -> case a of Auto a -> a.step a.state i)
11 run = \s i -> s (\a -> case a of Auto a -> a.step a.state i)
12−
13−module Main where
14
12
15−main = Debug.Trace.trace "Done"
13+ main = Debug.Trace.trace "Done"
examples/passing/CheckSynonymBug.purs+2−4
@@ -1,4 +1,4 @@
1−module Foo where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -6,6 +6,4 @@ module Foo where
6
6
7 foo _ = Data.Array.length ([] :: Foo Number)
7 foo _ = Data.Array.length ([] :: Foo Number)
8
8
9−module Main where
10−
11−main = Debug.Trace.trace "Done"
9+ main = Debug.Trace.trace "Done"
examples/passing/Church.purs+2−4
@@ -1,4 +1,4 @@
1−module Church where
1+module Main where
2
2
3 type List a = forall r. r -> (a -> r -> r) -> r
3 type List a = forall r. r -> (a -> r -> r) -> r
4
4
@@ -12,7 +12,5 @@ module Church where
12 append = \l1 l2 r f -> l2 (l1 r f) f
12 append = \l1 l2 r f -> l2 (l1 r f) f
13
13
14 test = append (cons 1 empty) (cons 2 empty)
14 test = append (cons 1 empty) (cons 2 empty)
15−
16−module Main where
17
15
18−main = Debug.Trace.trace "Done"
16+ main = Debug.Trace.trace "Done"
examples/passing/Conditional.purs+2−4
@@ -1,9 +1,7 @@
1−module Conditional where
1+module Main where
2
2
3 fns = \f -> if f true then f else \x -> x
3 fns = \f -> if f true then f else \x -> x
4
4
5 not = \x -> if x then false else true
5 not = \x -> if x then false else true
6−
7−module Main where
8
6
9−main = Debug.Trace.trace "Done"
7+ main = Debug.Trace.trace "Done"
examples/passing/Cons.purs+2−4
@@ -1,4 +1,4 @@
1−module Cons where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4 import Data.Array
4 import Data.Array
@@ -6,7 +6,5 @@ module Cons where
6 test1 = \xs -> 1 : xs
6 test1 = \xs -> 1 : xs
7
7
8 test2 = 1 : 2 : 3 : []
8 test2 = 1 : 2 : 3 : []
9−
10−module Main where
11
9
12−main = Debug.Trace.trace "Done"
10+ main = Debug.Trace.trace "Done"
examples/passing/DataAndType.purs+1−3
@@ -1,9 +1,7 @@
1−module DataAndType where
1+module Main where
2
2
3data A = A B
3data A = A B
4
4
5type B = A
5type B = A
6−
7−module Main where
8
6
9main = Debug.Trace.trace "Done"
7main = Debug.Trace.trace "Done"
examples/passing/DataImport.pursdeleted−13
@@ -1,13 +0,0 @@
1−module M1 where
2−
3−data Test = Test String
4−
5−module Main where
6−
7−import M1
8−
9−unTest (Test s) = s
10−
11−main = do
12− let x = unTest (Test "Done")
13− Debug.Trace.trace x
examples/passing/Do.purs+1−3
@@ -1,4 +1,4 @@
1−module Do where
1+module Main where
2
2
3import Prelude
3import Prelude
4
4
@@ -43,7 +43,5 @@ test8 = \_ -> do
43 Just 1)
43 Just 1)
44
44
45test9 = \_ -> (+) <$> Just 1 <*> Just 2
45test9 = \_ -> (+) <$> Just 1 <*> Just 2
46−
47−module Main where
48
46
49main = Debug.Trace.trace "Done"
47main = Debug.Trace.trace "Done"
examples/passing/Dollar.purs+1−3
@@ -1,4 +1,4 @@
1−module Dollar where
1+module Main where
2
2
3($) :: forall a b. (a -> b) -> a -> b
3($) :: forall a b. (a -> b) -> a -> b
4($) f x = f x
4($) f x = f x
@@ -11,6 +11,4 @@ test1 x = id $ id $ id $ id $ x
11
11
12test2 x = id id $ id x
12test2 x = id id $ id x
13
13
14−module Main where
15−
16main = Debug.Trace.trace "Done"
14main = Debug.Trace.trace "Done"
examples/passing/DottedModules.pursdeleted−20
@@ -1,20 +0,0 @@
1−module Some.Module.Name where
2−
3− class Foo a where
4− foo :: a -> a
5−
6− data Text = Text String
7−
8− x = Text "Done"
9−
10−module Main where
11−
12− import Prelude
13− import Some.Module.Name
14−
15− instance fooString :: Some.Module.Name.Foo String where
16− foo s = s
17−
18− unwrap (Text x) = x
19−
20− main = Debug.Trace.print $ foo $ unwrap x
examples/passing/Eff.purs+1−7
@@ -1,4 +1,4 @@
1−module TestEff where
1+module Main where
2
2
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
@@ -15,12 +15,6 @@ test2 = runPure (runST (do
15 modifySTRef ref $ \n -> n + 1
15 modifySTRef ref $ \n -> n + 1
16 readSTRef ref))
16 readSTRef ref))
17
17
18−module Main where
19−
20−import Prelude
21−import Control.Monad.Eff
22−import TestEff
23−
24main = do
18main = do
25 n <- test1
19 n <- test1
26 Debug.Trace.print n
20 Debug.Trace.print n
examples/passing/EmptyTypeClass.purs+4−10
@@ -1,18 +1,12 @@
1−module EmptyTypeClass where
1+module Main where
2+
3+import Prelude
2
4
3class Partial
5class Partial
4
6
5head :: forall a. (Partial) => [a] -> a
7head :: forall a. (Partial) => [a] -> a
6head (x:xs) = x
8head (x:xs) = x
7
9
8−module AllowPartialFns where
9−
10−instance allowPartials :: EmptyTypeClass.Partial
10+instance allowPartials :: Partial
11−
12−module Main where
13−
14−import Prelude
15−import AllowPartialFns
16−import EmptyTypeClass
17
11
18main = Debug.Trace.trace $ head ["Done"]
12main = Debug.Trace.trace $ head ["Done"]
examples/passing/ExternData.purs+6−12
@@ -1,19 +1,13 @@
1−module ExternData where
1+module Main where
2
2
3 foreign import data IO :: * -> *
3 foreign import data IO :: * -> *
4
4
5− foreign import fmap :: forall a b. IO a -> (a -> b) -> IO b
5+ foreign import bind "function bind() {}" :: forall a b. IO a -> (a -> IO b) -> IO b
6−
7− foreign import return :: forall a. a -> IO a
8
6
9− foreign import bind :: forall a b. IO a -> (a -> IO b) -> IO b
7+ foreign import showMessage "function showMessage() {}" :: String -> IO { }
10
8
11− foreign import showMessage :: String -> IO { }
9+ foreign import prompt "function prompt() {}" :: IO String
12
10
13− foreign import prompt :: IO String
14−
15− main = \_ -> prompt `bind` \s -> showMessage s
11+ test _ = prompt `bind` \s -> showMessage s
16−
17−module Main where
18
12
19−main = Debug.Trace.trace "Done"
13+ main = Debug.Trace.trace "Done"
examples/passing/ExternRaw.purs+1−3
@@ -1,4 +1,4 @@
1−module ExternRaw where
1+module Main where
2
2
3foreign import first "function first(xs) { return xs[0]; }" :: forall a. [a] -> a
3foreign import first "function first(xs) { return xs[0]; }" :: forall a. [a] -> a
4
4
@@ -9,7 +9,5 @@ foreign import concat "function concat(xs) { \
9 \ return xs.concat(ys); \
9 \ return xs.concat(ys); \
10 \ };\
10 \ };\
11 \}" :: forall a. [a] -> [a] -> [a]
11 \}" :: forall a. [a] -> [a] -> [a]
12−
13−module Main where
14
12
15main = Debug.Trace.trace "Done"
13main = Debug.Trace.trace "Done"
examples/passing/FFI.purs+5−10
@@ -1,16 +1,11 @@
1−module FFI where
1+module Main where
2
2
3−foreign import foo :: String -> String
3+foreign import foo
4+ "function foo(s) {\
5+ \ return s;\
6+ \}" :: String -> String
4
7
5bar :: String -> String
8bar :: String -> String
6bar _ = foo "test"
9bar _ = foo "test"
7
10
8−module FFIModuleTest where
9−
10−import FFI
11−
12−baz _ = foo "test"
13−
14−module Main where
15−
16main = Debug.Trace.trace "Done"
11main = Debug.Trace.trace "Done"
examples/passing/ForeignInstance.purs+2−9
@@ -1,18 +1,11 @@
1−module Foo where
1+module Main where
2
2
3class Foo a where
3class Foo a where
4 foo :: a -> String
4 foo :: a -> String
5
5
6foreign import instance fooArray :: (Foo a) => Foo [a]
6foreign import instance fooArray :: (Foo a) => Foo [a]
7
7
8−module M1 where
9−
10−foreign import instance fooNumber :: Foo.Foo Number
8+foreign import instance fooNumber :: Foo Number
11−
12−module Main where
13−
14−import M1
15−import Foo
16
9
17foreign import instance fooString :: Foo String
10foreign import instance fooString :: Foo String
18
11
examples/passing/FunctionScope.purs+2−7
@@ -1,17 +1,12 @@
1−module FunctionScope where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
5 mkValue :: Number -> Number
5 mkValue :: Number -> Number
6 mkValue id = id
6 mkValue id = id
7−
8−module Main where
9−
10− import Prelude
11− import FunctionScope
12
7
13 main = do
8 main = do
14 let value = mkValue 1
9 let value = mkValue 1
15 if value == 1
10 if value == 1
16 then Debug.Trace.trace "Done"
11 then Debug.Trace.trace "Done"
17− else Control.Monad.Eff.Error.throwError "Not done"
12+ else Control.Monad.Eff.Error.throwError "Not done"
examples/passing/Functions.purs+2−4
@@ -1,4 +1,4 @@
1−module Functions where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -11,7 +11,5 @@ module Functions where
11 test4 = \(%%) -> 1 %% 2
11 test4 = \(%%) -> 1 %% 2
12
12
13 test5 = \(+++) (***) -> 1 +++ 2 *** 3
13 test5 = \(+++) (***) -> 1 +++ 2 *** 3
14−
15−module Main where
16
14
17−main = Debug.Trace.trace "Done"
15+ main = Debug.Trace.trace "Done"
examples/passing/Functions2.purs+1−6
@@ -1,15 +1,10 @@
1−module Functions2 where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
5 test :: forall a b. a -> b -> a
5 test :: forall a b. a -> b -> a
6 test = \const _ -> const
6 test = \const _ -> const
7
7
8−module Main where
9−
10− import Prelude
11− import Functions2
12−
13 main = do
8 main = do
14 let value = test "Done" {}
9 let value = test "Done" {}
15 if value == "Done"
10 if value == "Done"
examples/passing/Guards.purs+2−4
@@ -1,4 +1,4 @@
1−module Guards where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -10,7 +10,5 @@ module Guards where
10 collatz2 = \x y -> case x of
10 collatz2 = \x y -> case x of
11 z | y > 0 -> z / 2
11 z | y > 0 -> z / 2
12 z -> z * 3 + 1
12 z -> z * 3 + 1
13−
14−module Main where
15
13
16−main = Debug.Trace.trace "Done"
14+ main = Debug.Trace.trace "Done"
examples/passing/JSReserved.purs+2−7
@@ -1,6 +1,7 @@
1−module JSReserved where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4+ import Data.Array
4
5
5 yield = 0
6 yield = 0
6 member = 1
7 member = 1
@@ -9,12 +10,6 @@ module JSReserved where
9
10
10 this catch = catch
11 this catch = catch
11
12
12−module Main where
13−
14− import Prelude
15− import Data.Array
16− import JSReserved
17−
18 main = Debug.Trace.print [ yield
13 main = Debug.Trace.print [ yield
19 , member
14 , member
20 , this 1
15 , this 1
examples/passing/Match.purs+2−4
@@ -1,9 +1,7 @@
1−module Match where
1+module Main where
2
2
3 data Foo a = Foo
3 data Foo a = Foo
4
4
5 foo = \f -> case f of Foo -> "foo"
5 foo = \f -> case f of Foo -> "foo"
6−
7−module Main where
8
6
9−main = Debug.Trace.trace "Done"
7+ main = Debug.Trace.trace "Done"
examples/passing/Monad.purs+2−4
@@ -1,4 +1,4 @@
1−module MonadTest where
1+module Main where
2
2
3 type Monad m = { return :: forall a. a -> m a
3 type Monad m = { return :: forall a. a -> m a
4 , bind :: forall a b. m a -> (a -> m b) -> m b }
4 , bind :: forall a b. m a -> (a -> m b) -> m b }
@@ -26,7 +26,5 @@ module MonadTest where
26 test1 = test id
26 test1 = test id
27
27
28 test2 = test maybe
28 test2 = test maybe
29−
30−module Main where
31
29
32−main = Debug.Trace.trace "Done"
30+ main = Debug.Trace.trace "Done"
examples/passing/MultipleConstructorArgs.purs+4−9
@@ -1,5 +1,8 @@
1−module MultipleConstructorArgs where
1+module Main where
2
2
3+import Prelude
4+import Global
5+import Control.Monad.Eff
3import Data.Array
6import Data.Array
4
7
5data P a b = P a b
8data P a b = P a b
@@ -15,14 +18,6 @@ testCase = \p -> case p of
15
18
16test1 = testCase (P [1, 2, 3] [4, 5, 6])
19test1 = testCase (P [1, 2, 3] [4, 5, 6])
17
20
18−module Main where
19−
20−import Prelude
21−import MultipleConstructorArgs
22−import Global
23−import Control.Monad.Eff
24−import Data.Array
25−
26main = do
21main = do
27 Debug.Trace.trace (runP (\s n -> s ++ show n) (P "Test" 1))
22 Debug.Trace.trace (runP (\s n -> s ++ show n) (P "Test" 1))
28 Debug.Trace.print test1
23 Debug.Trace.print test1
examples/passing/MutRec.purs+2−4
@@ -1,4 +1,4 @@
1−module MutRec where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -15,7 +15,5 @@ module MutRec where
15 evenToNumber (Even n) = oddToNumber n + 1
15 evenToNumber (Even n) = oddToNumber n + 1
16
16
17 oddToNumber (Odd n) = evenToNumber n + 1
17 oddToNumber (Odd n) = evenToNumber n + 1
18−
19−module Main where
20
18
21−main = Debug.Trace.trace "Done"
19+ main = Debug.Trace.trace "Done"
examples/passing/NamedPatterns.purs+2−4
@@ -1,9 +1,7 @@
1−module NamedPatterns where
1+module Main where
2
2
3 foo = \x -> case x of
3 foo = \x -> case x of
4 y@{ foo = "Foo" } -> y
4 y@{ foo = "Foo" } -> y
5 y -> y
5 y -> y
6−
7−module Main where
8
6
9−main = Debug.Trace.trace "Done"
7+ main = Debug.Trace.trace "Done"
examples/passing/Nested.purs+2−4
@@ -1,9 +1,7 @@
1−module Nested where
1+module Main where
2
2
3 data Extend r a = Extend { prev :: r a, next :: a }
3 data Extend r a = Extend { prev :: r a, next :: a }
4
4
5 data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
5 data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
6−
7−module Main where
8
6
9−main = Debug.Trace.trace "Done"
7+ main = Debug.Trace.trace "Done"
examples/passing/NestedTypeSynonyms.purs+4−6
@@ -1,4 +1,6 @@
1−module NestedTypeSynonyms where
1+module Main where
2+
3+ import Prelude
2
4
3 type X = String
5 type X = String
4 type Y = X -> X
6 type Y = X -> X
@@ -6,8 +8,4 @@ module NestedTypeSynonyms where
6 fn :: Y
8 fn :: Y
7 fn a = a
9 fn a = a
8
10
9−module Main where
10−
11− import Prelude
12−
13− main = Debug.Trace.print (NestedTypeSynonyms.fn "Done")
11+ main = Debug.Trace.print (fn "Done")
examples/passing/ObjectSynonym.purs+1−3
@@ -1,4 +1,4 @@
1−module ObjectSynonym where
1+module Main where
2
2
3type Inner = Number
3type Inner = Number
4
4
@@ -10,6 +10,4 @@ type Outer = { inner :: Inner }
10outer :: Outer
10outer :: Outer
11outer = { inner: inner }
11outer = { inner: inner }
12
12
13−module Main where
14−
15main = Debug.Trace.trace "Done"
13main = Debug.Trace.trace "Done"
examples/passing/ObjectUpdate.purs+2−6
@@ -1,4 +1,4 @@
1−module ObjectUpdate where
1+module Main where
2
2
3 update1 = \o -> o { foo = "Foo" }
3 update1 = \o -> o { foo = "Foo" }
4
4
@@ -15,8 +15,4 @@ module ObjectUpdate where
15
15
16 inferPolyUpdate = \o -> o { foo = "Foo" }
16 inferPolyUpdate = \o -> o { foo = "Foo" }
17
17
18−module Main where
19−
20−import ObjectUpdate
21−
22−main = Debug.Trace.trace ((update1 {foo: ""}).foo)
18+ main = Debug.Trace.trace ((update1 {foo: ""}).foo)
examples/passing/Objects.purs+2−4
@@ -1,4 +1,4 @@
1−module Objects where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -15,6 +15,4 @@ module Objects where
15 typed :: { foo :: Number }
15 typed :: { foo :: Number }
16 typed = { foo: 0 }
16 typed = { foo: 0 }
17
17
18−module Main where
19−
20−main = Debug.Trace.trace "Done"
18+ main = Debug.Trace.trace "Done"
examples/passing/OneConstructor.purs+1−3
@@ -1,9 +1,7 @@
1−module OneConstructor where
1+module Main where
2
2
3data One a = One a
3data One a = One a
4
4
5one (One a) = a
5one (One a) = a
6−
7−module Main where
8
6
9main = Debug.Trace.trace "Done"
7main = Debug.Trace.trace "Done"
examples/passing/Operators.purs+17−30
@@ -1,22 +1,13 @@
1−module Operators1 where
1+module Main where
2−
3− import Prelude ((++))
4−
5− (@@) :: forall a b. (a -> b) -> a -> b
6− (@@) = \f x -> f x
7
2
8− foo :: String -> String
3+ import Prelude
9− foo = \s -> s
4+ import Control.Monad.Eff
10−
5+ import Debug.Trace
11− test8 = foo @@ "Hello World"
6+ import Global
7+ import Data.Array
12
8
13 bar = \s1 s2 -> s1 ++ s2
9 bar = \s1 s2 -> s1 ++ s2
14
10
15−module Operators2 where
16−
17− import Prelude
18− import Operators1 ((@@))
19−
20 test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n
11 test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n
21 test1 x y z = x * y + z x y
12 test1 x y z = x * y + z x y
22
13
@@ -41,9 +32,17 @@ module Operators2 where
41
32
42 test7 = "Hello" <> "World!"
33 test7 = "Hello" <> "World!"
43
34
35+ (@@) :: forall a b. (a -> b) -> a -> b
36+ (@@) = \f x -> f x
37+
38+ foo :: String -> String
39+ foo = \s -> s
40+
41+ test8 = foo @@ "Hello World"
42+
44− test9 = Operators1.foo @@ "Hello World"
43+ test9 = Main.foo @@ "Hello World"
45
44
46− test10 = "Hello" `Operators1.bar` "World"
45+ test10 = "Hello" `Main.bar` "World"
47
46
48 (...) :: forall a. [a] -> [a] -> [a]
47 (...) :: forall a. [a] -> [a] -> [a]
49 (...) = \as -> \bs -> as
48 (...) = \as -> \bs -> as
@@ -60,19 +59,7 @@ module Operators2 where
60 test15 :: Number -> Number -> Boolean
59 test15 :: Number -> Number -> Boolean
61 test15 a b = const false $ a `test14` b
60 test15 a b = const false $ a `test14` b
62
61
63−module Main where
64−
65−import Operators1
66−import Operators2
67−
68−import Prelude
69−import Control.Monad.Eff
70−import Debug.Trace
71−import Global
72−import Data.Array
73−
74−main =
75− print [ show $ test1 1 2 $ \x y -> x + y
62+ main = print [ show $ test1 1 2 $ \x y -> x + y
76 , show test2
63 , show test2
77 , show test3
64 , show test3
78 , show test4
65 , show test4
examples/passing/OptimizerBug.purs+1−3
@@ -1,4 +1,4 @@
1−module OptimizerBug where
1+module Main where
2
2
3import Prelude
3import Prelude
4
4
@@ -6,6 +6,4 @@ x a = 1 + y a
6
6
7y a = x a
7y a = x a
8
8
9−module Main where
10−
11main = Debug.Trace.trace "Done"
9main = Debug.Trace.trace "Done"
examples/passing/Patterns.purs+2−4
@@ -1,4 +1,4 @@
1−module Patterns where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -25,6 +25,4 @@ module Patterns where
25 isDesc [x, y] | x > y = true
25 isDesc [x, y] | x > y = true
26 isDesc _ = false
26 isDesc _ = false
27
27
28−module Main where
29−
30−main = Debug.Trace.trace "Done"
28+ main = Debug.Trace.trace "Done"
examples/passing/Person.purs+6−5
@@ -1,15 +1,16 @@
1−module Person where
1+module Main where
2
2
3 import Prelude ((++))
3 import Prelude ((++))
4
4
5 data Person = Person { name :: String, age :: Number }
5 data Person = Person { name :: String, age :: Number }
6
6
7− foreign import itoa :: Number -> String
7+ foreign import itoa
8+ "function itoa(n) {\
9+ \ return n.toString();\
10+ \}" :: Number -> String
8
11
9 showPerson :: Person -> String
12 showPerson :: Person -> String
10 showPerson = \p -> case p of
13 showPerson = \p -> case p of
11 Person o -> o.name ++ ", aged " ++ itoa(o.age)
14 Person o -> o.name ++ ", aged " ++ itoa(o.age)
12
15
13−module Main where
14−
15−main = Debug.Trace.trace "Done"
16+ main = Debug.Trace.trace "Done"
examples/passing/Rank2Data.purs+3−5
@@ -1,4 +1,4 @@
1−module Rank2Data where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -25,7 +25,5 @@ module Rank2Data where
25 two = succ zero
25 two = succ zero
26 four = add two two
26 four = add two two
27 fourNumber = runNat four
27 fourNumber = runNat four
28−
28+
29−module Main where
30−
31−main = Debug.Trace.trace "Done"
29+ main = Debug.Trace.trace "Done"
examples/passing/Rank2Types.purs+4−15
@@ -1,25 +1,14 @@
1−module Rank2Types where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4+ import Data.Array
4
5
5 test1 :: (forall a. (a -> a)) -> Number
6 test1 :: (forall a. (a -> a)) -> Number
6 test1 = \f -> f 0
7 test1 = \f -> f 0
7
8
8− foreign import data ST :: * -> * -> *
9−
10− foreign import runST :: forall a. (forall s. ST s a) -> a
11−
12− foreign import exampleST :: forall s. ST s Number
13−
14− testST = \_ -> runST exampleST
15−
16− foreign import push :: forall el. el -> [el] -> [el]
17−
18 replicateM :: forall m a. (forall a. a -> m a) -> (forall a b. m a -> (a -> m b) -> m b) -> Number -> m a -> m [a]
9 replicateM :: forall m a. (forall a. a -> m a) -> (forall a b. m a -> (a -> m b) -> m b) -> Number -> m a -> m [a]
19 replicateM = \return bind n m -> case n of
10 replicateM = \return bind n m -> case n of
20 0 -> return []
11 0 -> return []
21− n -> bind m (\x -> bind (replicateM return bind (n - 1) m) (\xs -> return (push x xs)))
12+ n -> bind m (\x -> bind (replicateM return bind (n - 1) m) (\xs -> return (x : xs)))
22
13
23−module Main where
24−
25−main = Debug.Trace.trace "Done"
14+ main = Debug.Trace.trace "Done"
examples/passing/Recursion.purs+3−5
@@ -1,4 +1,4 @@
1−module Recursion where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -6,7 +6,5 @@ module Recursion where
6 0 -> 1
6 0 -> 1
7 1 -> 1
7 1 -> 1
8 n -> fib (n - 1) + fib (n - 2)
8 n -> fib (n - 1) + fib (n - 2)
9−
9+
10−module Main where
11−
12−main = Debug.Trace.trace "Done"
10+ main = Debug.Trace.trace "Done"
examples/passing/RuntimeScopeIssue.purs+1−7
@@ -1,4 +1,4 @@
1−module RuntimeScopeIssue where
1+module Main where
2
2
3import Prelude
3import Prelude
4
4
@@ -16,10 +16,4 @@ instance bNumber :: B Number where
16 b 0 = false
16 b 0 = false
17 b n = a (n - 1)
17 b n = a (n - 1)
18
18
19−module Main where
20−
21−import RuntimeScopeIssue
22−
23−import Prelude
24−
25main = Debug.Trace.print $ a 10
19main = Debug.Trace.print $ a 10
examples/passing/TailCall.purs+1−6
@@ -1,4 +1,4 @@
1−module TailCall where
1+module Main where
2
2
3import Prelude
3import Prelude
4
4
@@ -12,9 +12,4 @@ loop x = loop (x + 1)
12notATailCall = \x ->
12notATailCall = \x ->
13 (\notATailCall -> notATailCall x) (\x -> x)
13 (\notATailCall -> notATailCall x) (\x -> x)
14
14
15−module Main where
16−
17−import Prelude
18−import TailCall
19−
20main = Debug.Trace.print (test 0 [1, 2, 3])
15main = Debug.Trace.print (test 0 [1, 2, 3])
examples/passing/Tick.purs+1−3
@@ -1,7 +1,5 @@
1−module Tick where
1+module Main where
2
2
3test' x = x
3test' x = x
4
4
5−module Main where
6−
7main = Debug.Trace.trace "Done"
5main = Debug.Trace.trace "Done"
examples/passing/TopLevelCase.purs+2−4
@@ -1,4 +1,4 @@
1−module TopLevelCase where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -15,6 +15,4 @@ module TopLevelCase where
15
15
16 parseTest A 0 = 0
16 parseTest A 0 = 0
17
17
18−module Main where
19−
20−main = Debug.Trace.trace "Done"
18+ main = Debug.Trace.trace "Done"
examples/passing/TypeClasses.purs+1−11
@@ -1,4 +1,4 @@
1−module TypeClasses where
1+module Main where
2
2
3import Prelude
3import Prelude
4
4
@@ -37,11 +37,6 @@ test4 = \_ -> return 1
37
37
38test5 = \_ -> Just 1 >>= \n -> return (n + 1)
38test5 = \_ -> Just 1 >>= \n -> return (n + 1)
39
39
40−module TypeClasses2 where
41−
42−import Prelude
43−import TypeClasses
44−
45instance showArray :: (Prelude.Show a) => Prelude.Show [a] where
40instance showArray :: (Prelude.Show a) => Prelude.Show [a] where
46 show [] = "[]"
41 show [] = "[]"
47 show (x:xs) = show x ++ ", " ++ show xs
42 show (x:xs) = show x ++ ", " ++ show xs
@@ -60,10 +55,5 @@ test9 _ = runReader 0 $ do
60 n <- ask
55 n <- ask
61 return $ n + 1
56 return $ n + 1
62
57
63−module Main where
64−
65−import Prelude
66−import TypeClasses
67−
68main = Debug.Trace.trace (test7 "Done")
58main = Debug.Trace.trace (test7 "Done")
69
59
examples/passing/TypeDecl.purs+2−4
@@ -1,4 +1,4 @@
1−module TypeDecl where
1+module Main where
2
2
3 import Prelude
3 import Prelude
4
4
@@ -9,6 +9,4 @@ module TypeDecl where
9 iterate 0 f a = a
9 iterate 0 f a = a
10 iterate n f a = iterate (n - 1) f (f a)
10 iterate n f a = iterate (n - 1) f (f a)
11
11
12−module Main where
13−
14−main = Debug.Trace.trace "Done"
12+ main = Debug.Trace.trace "Done"
examples/passing/TypeSynonyms.purs+2−4
@@ -1,4 +1,4 @@
1−module TypeSynonyms where
1+module Main where
2
2
3 type Lens a b =
3 type Lens a b =
4 { get :: a -> b
4 { get :: a -> b
@@ -34,7 +34,5 @@ module TypeSynonyms where
34
34
35 test2 :: forall a b c. Lens (Pair [Pair a b] c) a
35 test2 :: forall a b c. Lens (Pair [Pair a b] c) a
36 test2 = composeLenses fst (composeLenses headLens fst)
36 test2 = composeLenses fst (composeLenses headLens fst)
37−
38−module Main where
39
37
40−main = Debug.Trace.trace "Done"
38+ main = Debug.Trace.trace "Done"
examples/passing/iota.purs+2−4
@@ -1,11 +1,9 @@
1−module Iota where
1+module Main where
2
2
3 s = \x -> \y -> \z -> x z (y z)
3 s = \x -> \y -> \z -> x z (y z)
4
4
5 k = \x -> \y -> x
5 k = \x -> \y -> x
6
6
7 iota = \x -> x s k
7 iota = \x -> x s k
8−
9−module Main where
10
8
11−main = Debug.Trace.trace "Done"
9+ main = Debug.Trace.trace "Done"
examples/passing/s.purs+2−4
@@ -1,7 +1,5 @@
1−module S where
1+module Main where
2
2
3 s = \x y z -> x z (y z)
3 s = \x y z -> x z (y z)
4
4
5−module Main where
6−
7−main = Debug.Trace.trace "Done"
5+ main = Debug.Trace.trace "Done"
src/Language/PureScript.hs+10−7
@@ -13,7 +13,7 @@
13--
13--
14-----------------------------------------------------------------------------
14-----------------------------------------------------------------------------
15
15
16−module Language.PureScript (module P, compile, MonadMake(..), make) where
16+module Language.PureScript (module P, compile, compile', MonadMake(..), make) where
17
17
18import Language.PureScript.Values as P
18import Language.PureScript.Values as P
19import Language.PureScript.Types as P
19import Language.PureScript.Types as P
@@ -61,10 +61,13 @@ import System.FilePath (pathSeparator)
61-- * Pretty-print the generated Javascript
61-- * Pretty-print the generated Javascript
62--
62--
63compile :: Options -> [Module] -> Either String (String, String, Environment)
63compile :: Options -> [Module] -> Either String (String, String, Environment)
64+compile = compile' initEnvironment
65+
66+compile' :: Environment -> Options -> [Module] -> Either String (String, String, Environment)
64−compile opts ms = do
67+compile' env opts ms = do
65 sorted <- sortModules ms
68 sorted <- sortModules ms
66 desugared <- desugar sorted
69 desugared <- desugar sorted
67− (elaborated, env) <- runCheck $ forM desugared $ \(Module moduleName' decls exps) -> do
70+ (elaborated, env') <- runCheck' env $ forM desugared $ \(Module moduleName' decls exps) -> do
68 modify (\s -> s { checkCurrentModule = Just moduleName' })
71 modify (\s -> s { checkCurrentModule = Just moduleName' })
69 Module moduleName' <$> typeCheckAll mainModuleIdent moduleName' decls <*> pure exps
72 Module moduleName' <$> typeCheckAll mainModuleIdent moduleName' decls <*> pure exps
70 regrouped <- createBindingGroupsModule . collapseBindingGroupsModule $ elaborated
73 regrouped <- createBindingGroupsModule . collapseBindingGroupsModule $ elaborated
@@ -72,10 +75,10 @@ compile opts ms = do
72 let elim = if null entryPoints then regrouped else eliminateDeadCode entryPoints regrouped
75 let elim = if null entryPoints then regrouped else eliminateDeadCode entryPoints regrouped
73 let codeGenModules = moduleNameFromString `map` optionsCodeGenModules opts
76 let codeGenModules = moduleNameFromString `map` optionsCodeGenModules opts
74 let modulesToCodeGen = if null codeGenModules then elim else filter (\(Module mn _ _) -> mn `elem` codeGenModules) elim
77 let modulesToCodeGen = if null codeGenModules then elim else filter (\(Module mn _ _) -> mn `elem` codeGenModules) elim
75− let js = mapMaybe (flip (moduleToJs opts) env) modulesToCodeGen
78+ let js = mapMaybe (flip (moduleToJs opts) env') modulesToCodeGen
76− let exts = intercalate "\n" . map (`moduleToPs` env) $ modulesToCodeGen
79+ let exts = intercalate "\n" . map (`moduleToPs` env') $ modulesToCodeGen
77− js' <- generateMain env opts js
80+ js' <- generateMain env' opts js
78− return (prettyPrintJS [wrapExportsContainer opts js'], exts, env)
81+ return (prettyPrintJS [wrapExportsContainer opts js'], exts, env')
79 where
82 where
80 mainModuleIdent = moduleNameFromString <$> optionsMain opts
83 mainModuleIdent = moduleNameFromString <$> optionsMain opts
81
84
tests/Main.hs+41−37
@@ -25,7 +25,7 @@ import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
25import System.Exit
25import System.Exit
26import System.Process
26import System.Process
27import System.FilePath (pathSeparator)
27import System.FilePath (pathSeparator)
28−import System.Directory (getCurrentDirectory, getDirectoryContents, findExecutable)
28+import System.Directory (getCurrentDirectory, getTemporaryDirectory, getDirectoryContents, findExecutable)
29import Text.Parsec (ParseError)
29import Text.Parsec (ParseError)
30import qualified Paths_purescript as Paths
30import qualified Paths_purescript as Paths
31import qualified System.IO.UTF8 as U
31import qualified System.IO.UTF8 as U
@@ -38,62 +38,66 @@ readInput inputFiles = fmap (fmap concat . sequence) $ forM inputFiles $ \inputF
38 text <- U.readFile inputFile
38 text <- U.readFile inputFile
39 return $ P.runIndentParser inputFile P.parseModules text
39 return $ P.runIndentParser inputFile P.parseModules text
40
40
41−compile :: P.Options -> [FilePath] -> IO (Either String String)
41+compile :: P.Options -> [FilePath] -> IO (Either String (String, String, P.Environment))
42compile opts inputFiles = do
42compile opts inputFiles = do
43 modules <- readInput inputFiles
43 modules <- readInput inputFiles
44 case modules of
44 case modules of
45 Left parseError ->
45 Left parseError ->
46 return (Left $ show parseError)
46 return (Left $ show parseError)
47− Right ms ->
48− case P.compile opts ms of
47+ Right ms -> return $ P.compile opts ms
49− Left typeError ->
50− return (Left typeError)
51− Right (js, _, _) ->
52− return (Right js)
53
48
54−assert :: P.Options -> [FilePath] -> (Either String String -> IO (Maybe String)) -> IO ()
49+assert :: FilePath -> P.Options -> FilePath -> (Either String (String, String, P.Environment) -> IO (Maybe String)) -> IO ()
55−assert opts inputFiles f = do
50+assert preludeExterns opts inputFile f = do
56− e <- compile opts inputFiles
51+ e <- compile opts [preludeExterns, inputFile]
57 maybeErr <- f e
52 maybeErr <- f e
58 case maybeErr of
53 case maybeErr of
59 Just err -> putStrLn err >> exitFailure
54 Just err -> putStrLn err >> exitFailure
60 Nothing -> return ()
55 Nothing -> return ()
61
56
62−assertCompiles :: FilePath -> IO ()
57+assertCompiles :: FilePath -> FilePath -> FilePath -> IO ()
63−assertCompiles inputFile = do
58+assertCompiles preludeJs preludeExterns inputFile = do
64− putStrLn $ "assert " ++ inputFile ++ " compiles successfully"
59+ putStrLn $ "Assert " ++ inputFile ++ " compiles successfully"
65− prelude <- preludeFilename
66− assert (P.defaultOptions { P.optionsMain = Just "Main", P.optionsModules = ["Main"] }) [prelude, inputFile] $ either (return . Just) $ \js -> do
60+ let options = P.defaultOptions { P.optionsMain = Just "Main", P.optionsModules = ["Main"], P.optionsCodeGenModules = ["Main"] }
61+ assert preludeExterns options inputFile $ either (return . Just) $ \(js, _, _) -> do
67 process <- findNodeProcess
62 process <- findNodeProcess
68− result <- traverse (\node -> readProcessWithExitCode node [] js) process
63+ result <- traverse (\node -> readProcessWithExitCode node [] (preludeJs ++ js)) process
69 case result of
64 case result of
70 Just (ExitSuccess, out, _) -> putStrLn out >> return Nothing
65 Just (ExitSuccess, out, _) -> putStrLn out >> return Nothing
71 Just (ExitFailure _, _, err) -> return $ Just err
66 Just (ExitFailure _, _, err) -> return $ Just err
72 Nothing -> return $ Just "Couldn't find node.js executable"
67 Nothing -> return $ Just "Couldn't find node.js executable"
73
68
74−findNodeProcess :: IO (Maybe String)
69+assertDoesNotCompile :: FilePath -> FilePath -> IO ()
75−findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
76− where names = ["nodejs", "node"]
77−
78−assertDoesNotCompile :: FilePath -> IO ()
79−assertDoesNotCompile inputFile = do
70+assertDoesNotCompile preludeExterns inputFile = do
80− putStrLn $ "assert " ++ inputFile ++ " does not compile"
71+ putStrLn $ "Assert " ++ inputFile ++ " does not compile"
81− assert P.defaultOptions [inputFile] $ \e ->
72+ assert preludeExterns P.defaultOptions inputFile $ \e ->
82 case e of
73 case e of
83 Left _ -> return Nothing
74 Left _ -> return Nothing
84 Right _ -> return $ Just "Should not have compiled"
75 Right _ -> return $ Just "Should not have compiled"
85
76
77+findNodeProcess :: IO (Maybe String)
78+findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
79+ where names = ["nodejs", "node"]
80+
86main :: IO ()
81main :: IO ()
87main = do
82main = do
83+ prelude <- preludeFilename
84+ putStrLn "Compiling Prelude"
85+ preludeResult <- compile P.defaultOptions [prelude]
86+ case preludeResult of
87+ Left err -> putStrLn err >> exitFailure
88+ Right (preludeJs, exts, _) -> do
89+ tmp <- getTemporaryDirectory
90+ let preludeExterns = tmp ++ pathSeparator : "prelude.externs"
91+ writeFile preludeExterns exts
92+ putStrLn $ "Wrote " ++ preludeExterns
88− cd <- getCurrentDirectory
93+ cd <- getCurrentDirectory
89− putStrLn cd
90− let examples = cd ++ pathSeparator : "examples"
94+ let examples = cd ++ pathSeparator : "examples"
91− let passing = examples ++ pathSeparator : "passing"
95+ let passing = examples ++ pathSeparator : "passing"
92− passingTestCases <- getDirectoryContents passing
96+ passingTestCases <- getDirectoryContents passing
93− forM_ passingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $
97+ forM_ passingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $
94− assertCompiles (passing ++ pathSeparator : inputFile)
98+ assertCompiles preludeJs preludeExterns (passing ++ pathSeparator : inputFile)
95− let failing = examples ++ pathSeparator : "failing"
99+ let failing = examples ++ pathSeparator : "failing"
96− failingTestCases <- getDirectoryContents failing
100+ failingTestCases <- getDirectoryContents failing
97− forM_ failingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $
101+ forM_ failingTestCases $ \inputFile -> when (".purs" `isSuffixOf` inputFile) $
98− assertDoesNotCompile (failing ++ pathSeparator : inputFile)
102+ assertDoesNotCompile preludeExterns (failing ++ pathSeparator : inputFile)
99− exitSuccess
103+ exitSuccess