git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #2131 from purescript/name-resolving
cd4c708Phil Freeman
core-tests/tests/generic-deriving/Main.purs+5−5
@@ -2,18 +2,18 @@ module GenericDeriving where
2
2
3import Prelude
3import Prelude
4
4
5−import Control.Monad.Eff (Eff())
5+import Control.Monad.Eff (Eff)
6−import Control.Monad.Eff.Console (CONSOLE())
6+import Control.Monad.Eff.Console (CONSOLE, log)
7import Data.Generic
7import Data.Generic
8
8
9data Void
9data Void
10
10
11derive instance genericVoid :: Generic Void
11derive instance genericVoid :: Generic Void
12
12
13−data A a
13+data A a
14 = A Number String
14 = A Number String
15 | B Int
15 | B Int
16− | C (Array (A a))
16+ | C (Array (A a))
17 | D { "asgård" :: a }
17 | D { "asgård" :: a }
18 | E Void
18 | E Void
19
19
@@ -24,4 +24,4 @@ newtype X b = X b
24derive instance genericX :: Generic (X String)
24derive instance genericX :: Generic (X String)
25
25
26main :: forall eff. Eff (console :: CONSOLE | eff) Unit
26main :: forall eff. Eff (console :: CONSOLE | eff) Unit
27−main = Control.Monad.Eff.Console.log (gShow (D { "asgård": C [ A 1.0 "test", B 42, D { "asgård": true } ] }))
27+main = log (gShow (D { "asgård": C [ A 1.0 "test", B 42, D { "asgård": true } ] }))
examples/failing/ExportExplicit1.purs+2−1
@@ -2,10 +2,11 @@
2module Main where
2module Main where
3
3
4import M1
4import M1
5+import Control.Monad.Eff.Console (log)
5
6
6testX = X
7testX = X
7
8
8-- should fail as Y constructor is not exported from M1
9-- should fail as Y constructor is not exported from M1
9testY = Y
10testY = Y
10
11
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/failing/ExportExplicit3.purs+4−3
@@ -1,9 +1,10 @@
1-- @shouldFailWith UnknownName
1-- @shouldFailWith UnknownName
2module Main where
2module Main where
3
3
4−import M1
4+import M1 as M
5+import Control.Monad.Eff.Console (log)
5
6
6-- should fail as Z is not exported from M1
7-- should fail as Z is not exported from M1
7−testZ = M1.Z
8+testZ = M.Z
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/failing/RowConstructors1.purs+2−2
@@ -1,9 +1,9 @@
1-- @shouldFailWith KindsDoNotUnify
1-- @shouldFailWith KindsDoNotUnify
2module Main where
2module Main where
3
3
4−import Prelude
4+import Control.Monad.Eff.Console (log)
5
5
6data Foo = Bar
6data Foo = Bar
7type Baz = { | Foo }
7type Baz = { | Foo }
8
8
9−main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/failing/RowConstructors2.purs+2−2
@@ -1,9 +1,9 @@
1-- @shouldFailWith KindsDoNotUnify
1-- @shouldFailWith KindsDoNotUnify
2module Main where
2module Main where
3
3
4−import Prelude
4+import Control.Monad.Eff.Console (log)
5
5
6type Foo r = (x :: Number | r)
6type Foo r = (x :: Number | r)
7type Bar = { | Foo }
7type Bar = { | Foo }
8
8
9−main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/failing/RowConstructors3.purs+2−2
@@ -1,9 +1,9 @@
1-- @shouldFailWith KindsDoNotUnify
1-- @shouldFailWith KindsDoNotUnify
2module Main where
2module Main where
3
3
4−import Prelude
4+import Control.Monad.Eff.Console (log)
5
5
6type Foo = { x :: Number }
6type Foo = { x :: Number }
7type Bar = { | Foo }
7type Bar = { | Foo }
8
8
9−main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/failing/TypedBinders.purs+3−3
@@ -1,10 +1,10 @@
1−-- @shouldFailWith ErrorParsingModule
1+-- @shouldFailWith ErrorParsingModule
2module Main where
2module Main where
3
3
4−import Prelude
4+import Control.Monad.Eff.Console (log)
5
5
6test = (\f :: Int -> Int -> f 10) id
6test = (\f :: Int -> Int -> f 10) id
7
7
8main = do
8main = do
9 let t1 = test
9 let t1 = test
10− Control.Monad.Eff.Console.log "Done"
10+ log "Done"
examples/failing/TypedBinders2.purs+3−3
@@ -2,8 +2,8 @@
2module Main where
2module Main where
3
3
4import Prelude
4import Prelude
5+import Control.Monad.Eff.Console (log)
5
6
6main = do
7main = do
7− s :: String <- Control.Monad.Eff.Console.log "Foo"
8+ s :: String <- log "Foo"
8− Control.Monad.Eff.Console.log "Done"
9+ log "Done"
9−
examples/failing/TypedBinders3.purs+2−1
@@ -2,6 +2,7 @@
2module Main where
2module Main where
3
3
4import Prelude
4import Prelude
5+import Control.Monad.Eff.Console (log)
5
6
6test = case 1 of
7test = case 1 of
7 (0 :: String) -> true
8 (0 :: String) -> true
@@ -9,4 +10,4 @@ test = case 1 of
9
10
10main = do
11main = do
11 let t = test
12 let t = test
12− Control.Monad.Eff.Console.log "Done"
13+ log "Done"
examples/failing/UnderscoreModuleName.purs+2−2
@@ -1,6 +1,6 @@
1-- @shouldFailWith ErrorParsingModule
1-- @shouldFailWith ErrorParsingModule
2module Bad_Module where
2module Bad_Module where
3
3
4−import Prelude
4+import Control.Monad.Eff.Console (log)
5
5
6−main = Control.Monad.Eff.Console.log "Done"
6+main = log "Done"
examples/passing/1185.purs+3−1
@@ -1,5 +1,7 @@
1module Main where
1module Main where
2
2
3+import Control.Monad.Eff.Console (log)
4+
3data Person = Person String Boolean
5data Person = Person String Boolean
4
6
5getName :: Person -> String
7getName :: Person -> String
@@ -10,4 +12,4 @@ getName p = case p of
10name :: String
12name :: String
11name = getName (Person "John Smith" true)
13name = getName (Person "John Smith" true)
12
14
13−main = Control.Monad.Eff.Console.log "Done"
15+main = log "Done"
examples/passing/1570.purs+3−1
@@ -1,6 +1,8 @@
1module Main where
1module Main where
2
2
3+import Control.Monad.Eff.Console (log)
4+
3test :: forall a. a -> a
5test :: forall a. a -> a
4test = \(x :: a) -> x
6test = \(x :: a) -> x
5
7
6−main = Control.Monad.Eff.Console.log "Done"
8+main = log "Done"
examples/passing/1697.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5_2 :: forall a. a -> a
6_2 :: forall a. a -> a
6_2 a = a
7_2 a = a
@@ -21,4 +22,4 @@ wtf = do
21 let tmp = _2 1
22 let tmp = _2 1
22 pure unit
23 pure unit
23
24
24−main = Control.Monad.Eff.Console.log "Done"
25+main = log "Done"
examples/passing/1881.purs+5−3
@@ -1,9 +1,11 @@
1module Main where
1module Main where
2
2
3+import Control.Monad.Eff.Console (log)
4+
3−foo =
5+foo =
4 1
6 1
5
7
6−bar
8+bar
7 = 2
9 = 2
8
10
9baz
11baz
@@ -14,4 +16,4 @@ qux
14 =
16 =
15 3
17 3
16
18
17−main = Control.Monad.Eff.Console.log "Done"
19+main = log "Done"
examples/passing/1991.purs+3−2
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5singleton :: forall a. a -> Array a
6singleton :: forall a. a -> Array a
6singleton x = [x]
7singleton x = [x]
@@ -17,5 +18,5 @@ regression =
17 let as = [1,2,3,4,5]
18 let as = [1,2,3,4,5]
18 as' = foldMap (\x -> if 1 < x && x < 4 then singleton x else empty) as
19 as' = foldMap (\x -> if 1 < x && x < 4 then singleton x else empty) as
19 in as'
20 in as'
20−
21+
21−main = Control.Monad.Eff.Console.log "Done"
22+main = log "Done"
examples/passing/652.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5class Foo a b
6class Foo a b
6
7
@@ -14,4 +15,4 @@ instance bar :: Bar (a -> b) b
14
15
15instance baz :: (Eq a) => Baz (a -> b) a b
16instance baz :: (Eq a) => Baz (a -> b) a b
16
17
17−main = Control.Monad.Eff.Console.log "Done"
18+main = log "Done"
examples/passing/810.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Maybe a = Nothing | Just a
6data Maybe a = Nothing | Just a
6
7
@@ -10,4 +11,4 @@ test m = o.x
10 o = case m of Nothing -> { x : Nothing }
11 o = case m of Nothing -> { x : Nothing }
11 Just a -> { x : Just a }
12 Just a -> { x : Just a }
12
13
13−main = Control.Monad.Eff.Console.log "Done"
14+main = log "Done"
examples/passing/Applicative.purs+2−2
@@ -1,6 +1,6 @@
1module Main where
1module Main where
2
2
3−import Prelude ()
3+import Control.Monad.Eff.Console (log)
4
4
5class Applicative f where
5class Applicative f where
6 pure :: forall a. a -> f a
6 pure :: forall a. a -> f a
@@ -13,4 +13,4 @@ instance applicativeMaybe :: Applicative Maybe where
13 apply (Just f) (Just a) = Just (f a)
13 apply (Just f) (Just a) = Just (f a)
14 apply _ _ = Nothing
14 apply _ _ = Nothing
15
15
16−main = Control.Monad.Eff.Console.log "Done"
16+main = log "Done"
examples/passing/ArrayType.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5class Pointed p where
6class Pointed p where
6 point :: forall a. a -> p a
7 point :: forall a. a -> p a
@@ -8,4 +9,4 @@ class Pointed p where
8instance pointedArray :: Pointed Array where
9instance pointedArray :: Pointed Array where
9 point a = [a]
10 point a = [a]
10
11
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/passing/Auto.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Auto s i o = Auto { state :: s, step :: s -> i -> o }
6data Auto s i o = Auto { state :: s, step :: s -> i -> o }
6
7
@@ -12,4 +13,4 @@ exists = \state step f -> f (Auto { state: state, step: step })
12run :: forall i o. SomeAuto i o -> i -> o
13run :: forall i o. SomeAuto i o -> i -> o
13run = \s i -> s (\a -> case a of Auto a -> a.step a.state i)
14run = \s i -> s (\a -> case a of Auto a -> a.step a.state i)
14
15
15−main = Control.Monad.Eff.Console.log "Done"
16+main = log "Done"
examples/passing/BindersInFunctions.purs+2−1
@@ -4,6 +4,7 @@ import Prelude
4import Partial.Unsafe (unsafePartial)
4import Partial.Unsafe (unsafePartial)
5import Test.Assert (assert')
5import Test.Assert (assert')
6import Control.Monad.Eff (Eff)
6import Control.Monad.Eff (Eff)
7+import Control.Monad.Eff.Console (log)
7
8
8snd :: forall a. Partial => Array a -> a
9snd :: forall a. Partial => Array a -> a
9snd = \[_, y] -> y
10snd = \[_, y] -> y
@@ -12,4 +13,4 @@ main :: Eff _ _
12main = do
13main = do
13 let ts = unsafePartial (snd [1.0, 2.0])
14 let ts = unsafePartial (snd [1.0, 2.0])
14 assert' "Incorrect result from 'snd'." (ts == 2.0)
15 assert' "Incorrect result from 'snd'." (ts == 2.0)
15− Control.Monad.Eff.Console.log "Done"
16+ log "Done"
examples/passing/BindingGroups.purs+2−1
@@ -1,10 +1,11 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5foo = bar
6foo = bar
6 where bar r = r + 1.0
7 where bar r = r + 1.0
7
8
8r = foo 2.0
9r = foo 2.0
9
10
10−main = Control.Monad.Eff.Console.log "Done"
11+main = log "Done"
examples/passing/BlockString.purs+2−1
@@ -1,8 +1,9 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5foo :: String
6foo :: String
6foo = """foo"""
7foo = """foo"""
7
8
8−main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/passing/CaseStatement.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data A = A | B | C
6data A = A | B | C
6
7
@@ -18,4 +19,4 @@ h f N a = a
18h f a N = a
19h f a N = a
19h f (J a) (J b) = J (f a b)
20h f (J a) (J b) = J (f a b)
20
21
21−main = Control.Monad.Eff.Console.log $ f "Done" "Failed" A
22+main = log $ f "Done" "Failed" A
examples/passing/CheckFunction.purs+2−1
@@ -1,7 +1,8 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5test = ((\x -> x+1.0) >>> (\x -> x*2.0)) 4.0
6test = ((\x -> x+1.0) >>> (\x -> x*2.0)) 4.0
6
7
7−main = Control.Monad.Eff.Console.log "Done"
8+main = log "Done"
examples/passing/CheckSynonymBug.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5length :: forall a. Array a -> Int
6length :: forall a. Array a -> Int
6length _ = 0
7length _ = 0
@@ -9,4 +10,4 @@ type Foo a = Array a
9
10
10foo _ = length ([] :: Foo Number)
11foo _ = length ([] :: Foo Number)
11
12
12−main = Control.Monad.Eff.Console.log "Done"
13+main = log "Done"
examples/passing/CheckTypeClass.purs+2−2
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Bar a = Bar
6data Bar a = Bar
6data Baz
7data Baz
@@ -14,5 +15,4 @@ foo_ x = foo ((mkBar :: forall a. (Foo a) => a -> Bar a) x)
14mkBar :: forall a. a -> Bar a
15mkBar :: forall a. a -> Bar a
15mkBar _ = Bar
16mkBar _ = Bar
16
17
17−main = Control.Monad.Eff.Console.log "Done"
18+main = log "Done"
18−
examples/passing/Church.purs+2−2
@@ -1,6 +1,6 @@
1module Main where
1module Main where
2
2
3−import Prelude ()
3+import Control.Monad.Eff.Console (log)
4
4
5type List a = forall r. r -> (a -> r -> r) -> r
5type List a = forall r. r -> (a -> r -> r) -> r
6
6
@@ -15,4 +15,4 @@ append = \l1 l2 r f -> l2 (l1 r f) f
15
15
16test = append (cons 1 empty) (cons 2 empty)
16test = append (cons 1 empty) (cons 2 empty)
17
17
18−main = Control.Monad.Eff.Console.log "Done"
18+main = log "Done"
examples/passing/ClassRefSyntax.purs+5−4
@@ -1,8 +1,9 @@
1module Main where
1module Main where
2
2
3− import Lib (class X, go)
3+import Lib (class X, go)
4+import Control.Monad.Eff.Console (log)
4
5
5− go' :: forall a. (X a) => a -> a
6+go' :: forall a. (X a) => a -> a
6− go' = go
7+go' = go
7
8
8− main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/passing/Conditional.purs+2−2
@@ -1,9 +1,9 @@
1module Main where
1module Main where
2
2
3−import Prelude ()
3+import Control.Monad.Eff.Console (log)
4
4
5fns = \f -> if f true then f else \x -> x
5fns = \f -> if f true then f else \x -> x
6
6
7not = \x -> if x then false else true
7not = \x -> if x then false else true
8
8
9−main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/passing/DataAndType.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data A = A B
6data A = A B
6
7
7type B = A
8type B = A
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/DeepArrayBinder.purs+2−1
@@ -2,6 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
5+import Control.Monad.Eff.Console (log)
5import Test.Assert
6import Test.Assert
6
7
7data List a = Cons a (List a) | Nil
8data List a = Cons a (List a) | Nil
@@ -13,4 +14,4 @@ match2 _ = 0.0
13main = do
14main = do
14 let result = match2 (Cons 1.0 (Cons 2.0 (Cons 3.0 (Cons 4.0 (Cons 5.0 (Cons 6.0 (Cons 7.0 (Cons 8.0 (Cons 9.0 Nil)))))))))
15 let result = match2 (Cons 1.0 (Cons 2.0 (Cons 3.0 (Cons 4.0 (Cons 5.0 (Cons 6.0 (Cons 7.0 (Cons 8.0 (Cons 9.0 Nil)))))))))
15 assert' "Incorrect result!" (result == 100.0)
16 assert' "Incorrect result!" (result == 100.0)
16− Control.Monad.Eff.Console.log "Done"
17+ log "Done"
examples/passing/Do.purs+3−2
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Maybe a = Nothing | Just a
6data Maybe a = Nothing | Just a
6
7
@@ -19,7 +20,7 @@ instance bindMaybe :: Bind Maybe where
19 bind Nothing _ = Nothing
20 bind Nothing _ = Nothing
20 bind (Just a) f = f a
21 bind (Just a) f = f a
21
22
22−instance monadMaybe :: Prelude.Monad Maybe
23+instance monadMaybe :: Monad Maybe
23
24
24test1 = \_ -> do
25test1 = \_ -> do
25 Just "abc"
26 Just "abc"
@@ -64,4 +65,4 @@ test10 _ = do
64 g x = f x / 2.0
65 g x = f x / 2.0
65 Just (f 10.0)
66 Just (f 10.0)
66
67
67−main = Control.Monad.Eff.Console.log "Done"
68+main = log "Done"
examples/passing/Dollar.purs+2−2
@@ -1,6 +1,6 @@
1module Main where
1module Main where
2
2
3−import Prelude ()
3+import Control.Monad.Eff.Console (log)
4
4
5applyFn :: forall a b. (a -> b) -> a -> b
5applyFn :: forall a b. (a -> b) -> a -> b
6applyFn f x = f x
6applyFn f x = f x
@@ -13,4 +13,4 @@ test1 x = id $ id $ id $ id $ x
13
13
14test2 x = id id $ id x
14test2 x = id id $ id x
15
15
16−main = Control.Monad.Eff.Console.log "Done"
16+main = log "Done"
examples/passing/EmptyDataDecls.purs+2−1
@@ -2,6 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Test.Assert
4import Test.Assert
5+import Control.Monad.Eff.Console (log)
5
6
6data Z
7data Z
7data S n
8data S n
@@ -15,5 +16,5 @@ cons' :: forall a n. a -> ArrayBox n a -> ArrayBox (S n) a
15cons' x (ArrayBox xs) = ArrayBox $ append [x] xs
16cons' x (ArrayBox xs) = ArrayBox $ append [x] xs
16
17
17main = case cons' 1 $ cons' 2 $ cons' 3 nil of
18main = case cons' 1 $ cons' 2 $ cons' 3 nil of
18− ArrayBox [1, 2, 3] -> Control.Monad.Eff.Console.log "Done"
19+ ArrayBox [1, 2, 3] -> log "Done"
19 _ -> assert' "Failed" false
20 _ -> assert' "Failed" false
examples/passing/EmptyRow.purs+2−1
@@ -1,10 +1,11 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Foo r = Foo { | r }
6data Foo r = Foo { | r }
6
7
7test :: Foo ()
8test :: Foo ()
8test = Foo {}
9test = Foo {}
9
10
10−main = Control.Monad.Eff.Console.log "Done"
11+main = log "Done"
examples/passing/ExplicitOperatorSections.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5subtractOne :: Int -> Int
6subtractOne :: Int -> Int
6subtractOne = (_ - 1)
7subtractOne = (_ - 1)
@@ -11,4 +12,4 @@ addOne = (1 + _)
11named :: Int -> Int
12named :: Int -> Int
12named = (_ `sub` 1)
13named = (_ `sub` 1)
13
14
14−main = Control.Monad.Eff.Console.log "Done"
15+main = log "Done"
examples/passing/ExportExplicit.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import M1
3import M1
4+import Control.Monad.Eff.Console (log)
4
5
5testX = X
6testX = X
6testZ = Z
7testZ = Z
7testFoo = foo
8testFoo = foo
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/ExportExplicit2.purs+2−1
@@ -1,7 +1,8 @@
1module Main where
1module Main where
2
2
3import M1
3import M1
4+import Control.Monad.Eff.Console (log)
4
5
5testBar = bar
6testBar = bar
6
7
7−main = Control.Monad.Eff.Console.log "Done"
8+main = log "Done"
examples/passing/FunctionScope.purs+2−1
@@ -2,6 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Test.Assert
4import Test.Assert
5+import Control.Monad.Eff.Console (log)
5
6
6mkValue :: Number -> Number
7mkValue :: Number -> Number
7mkValue id = id
8mkValue id = id
@@ -9,4 +10,4 @@ mkValue id = id
9main = do
10main = do
10 let value = mkValue 1.0
11 let value = mkValue 1.0
11 assert $ value == 1.0
12 assert $ value == 1.0
12− Control.Monad.Eff.Console.log "Done"
13+ log "Done"
examples/passing/Functions2.purs+2−1
@@ -2,6 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Test.Assert
4import Test.Assert
5+import Control.Monad.Eff.Console (log)
5
6
6test :: forall a b. a -> b -> a
7test :: forall a b. a -> b -> a
7test = \const _ -> const
8test = \const _ -> const
@@ -9,4 +10,4 @@ test = \const _ -> const
9main = do
10main = do
10 let value = test "Done" {}
11 let value = test "Done" {}
11 assert' "Not done" $ value == "Done"
12 assert' "Not done" $ value == "Done"
12− Control.Monad.Eff.Console.log "Done"
13+ log "Done"
examples/passing/Guards.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5collatz = \x -> case x of
6collatz = \x -> case x of
6 y | y `mod` 2.0 == 0.0 -> y / 2.0
7 y | y `mod` 2.0 == 0.0 -> y / 2.0
@@ -26,4 +27,4 @@ testIndentation x y | x > 0.0
26 | otherwise
27 | otherwise
27 = y - x
28 = y - x
28
29
29−main = Control.Monad.Eff.Console.log $ min "Done" "ZZZZ"
30+main = log $ min "Done" "ZZZZ"
examples/passing/IfThenElseMaybe.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Maybe a = Nothing | Just a
6data Maybe a = Nothing | Just a
6
7
@@ -8,4 +9,4 @@ test1 = if true then Just 10 else Nothing
8
9
9test2 = if true then Nothing else Just 10
10test2 = if true then Nothing else Just 10
10
11
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/passing/ImplicitEmptyImport.purs+4−3
@@ -1,8 +1,9 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5main = do
6main = do
6− Control.Monad.Eff.Console.log "Hello"
7+ log "Hello"
7− Control.Monad.Eff.Console.log "Goodbye"
8+ log "Goodbye"
8− Control.Monad.Eff.Console.log "Done"
9+ log "Done"
examples/passing/Import.purs+2−1
@@ -1,5 +1,6 @@
1module Main where
1module Main where
2
2
3import M2
3import M2
4+import Control.Monad.Eff.Console (log)
4
5
5−main = Control.Monad.Eff.Console.log "Done"
6+main = log "Done"
examples/passing/ImportExplicit.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import M1 (X(..))
3import M1 (X(..))
4+import Control.Monad.Eff.Console (log)
4
5
5testX :: X
6testX :: X
6testX = X
7testX = X
7testY = Y
8testY = Y
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/InstanceBeforeClass.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5instance fooNumber :: Foo Number where
6instance fooNumber :: Foo Number where
6 foo = 0.0
7 foo = 0.0
@@ -8,4 +9,4 @@ instance fooNumber :: Foo Number where
8class Foo a where
9class Foo a where
9 foo :: a
10 foo :: a
10
11
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/passing/IntAndChar.purs+2−1
@@ -2,6 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
5+import Control.Monad.Eff.Console (log)
5import Test.Assert
6import Test.Assert
6
7
7f 1 = 1
8f 1 = 1
@@ -15,4 +16,4 @@ main = do
15 assert $ f 0 == 0
16 assert $ f 0 == 0
16 assert $ g 'a' == 'a'
17 assert $ g 'a' == 'a'
17 assert $ g 'b' == 'b'
18 assert $ g 'b' == 'b'
18− Control.Monad.Eff.Console.log "Done"
19+ log "Done"
examples/passing/JSReserved.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5yield = 0
6yield = 0
6member = 1
7member = 1
@@ -9,4 +10,4 @@ public = \return -> return
9
10
10this catch = catch
11this catch = catch
11
12
12−main = Control.Monad.Eff.Console.log "Done"
13+main = log "Done"
examples/passing/KindedType.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5type Star2Star f = f :: * -> *
6type Star2Star f = f :: * -> *
6
7
@@ -30,4 +31,4 @@ class Clazz (a :: *) where
30instance clazzString :: Clazz String where
31instance clazzString :: Clazz String where
31 def = "test"
32 def = "test"
32
33
33−main = Control.Monad.Eff.Console.log "Done"
34+main = log "Done"
examples/passing/LargeSumType.purs+4−2
@@ -1,5 +1,7 @@
1module Main where
1module Main where
2−
2+
3+import Control.Monad.Eff.Console (log)
4+
3data Large = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
5data Large = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
4
6
5explode A A = "A"
7explode A A = "A"
@@ -30,4 +32,4 @@ explode Y Y = "Y"
30explode Z Z = "Z"
32explode Z Z = "Z"
31explode _ _ = ""
33explode _ _ = ""
32
34
33−main = Control.Monad.Eff.Console.log "Done"
35+main = log "Done"
examples/passing/LetInInstance.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5class Foo a where
6class Foo a where
6 foo :: a -> String
7 foo :: a -> String
@@ -11,4 +12,4 @@ instance fooString :: Foo String where
11 go :: String -> String
12 go :: String -> String
12 go s = s
13 go s = s
13
14
14−main = Control.Monad.Eff.Console.log "Done"
15+main = log "Done"
examples/passing/LiberalTypeSynonyms.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5type Reader = (->) String
6type Reader = (->) String
6
7
@@ -18,4 +19,4 @@ f :: (forall r. F r) -> String
18f g = case g { x: "Hello" } of
19f g = case g { x: "Hello" } of
19 { x = x } -> x
20 { x = x } -> x
20
21
21−main = Control.Monad.Eff.Console.log "Done"
22+main = log "Done"
examples/passing/MPTCs.purs+3−2
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5class NullaryTypeClass where
6class NullaryTypeClass where
6 greeting :: String
7 greeting :: String
@@ -14,7 +15,7 @@ class Coerce a b where
14instance coerceRefl :: Coerce a a where
15instance coerceRefl :: Coerce a a where
15 coerce a = a
16 coerce a = a
16
17
17−instance coerceShow :: (Prelude.Show a) => Coerce a String where
18+instance coerceShow :: Show a => Coerce a String where
18 coerce = show
19 coerce = show
19
20
20−main = Control.Monad.Eff.Console.log "Done"
21+main = log "Done"
examples/passing/Match.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Foo a = Foo
6data Foo a = Foo
6
7
7foo = \f -> case f of Foo -> "foo"
8foo = \f -> case f of Foo -> "foo"
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/Module.purs+2−1
@@ -2,5 +2,6 @@ module Main where
2
2
3import M1
3import M1
4import M2
4import M2
5+import Control.Monad.Eff.Console (log)
5
6
6−main = Control.Monad.Eff.Console.log "Done"
7+main = log "Done"
examples/passing/Module/M1.purs+1−1
@@ -4,7 +4,7 @@ import Prelude
4
4
5data Foo = Foo String
5data Foo = Foo String
6
6
7−foo :: M1.Foo -> String
7+foo :: Foo -> String
8foo = \f -> case f of Foo s -> s <> "foo"
8foo = \f -> case f of Foo s -> s <> "foo"
9
9
10bar :: Foo -> String
10bar :: Foo -> String
examples/passing/Module/M2.purs+1
@@ -1,6 +1,7 @@
1module M2 where
1module M2 where
2
2
3import Prelude
3import Prelude
4+import M1 as M1
4
5
5baz :: M1.Foo -> String
6baz :: M1.Foo -> String
6baz = M1.foo
7baz = M1.foo
examples/passing/ModuleDeps.purs+2−1
@@ -1,5 +1,6 @@
1module Main where
1module Main where
2
2
3import M1
3import M1
4+import Control.Monad.Eff.Console (log)
4
5
5−main = Control.Monad.Eff.Console.log "Done"
6+main = log "Done"
examples/passing/ModuleDeps/M1.purs+1−1
@@ -1,5 +1,5 @@
1module M1 where
1module M1 where
2
2
3−import M2
3+import M2 as M2
4
4
5foo = M2.bar
5foo = M2.bar
examples/passing/ModuleDeps/M2.purs+1−1
@@ -1,5 +1,5 @@
1module M2 where
1module M2 where
2
2
3−import M3
3+import M3 as M3
4
4
5bar = M3.baz
5bar = M3.baz
examples/passing/Monad.purs+2−2
@@ -1,6 +1,6 @@
1module Main where
1module Main where
2
2
3−import Prelude ()
3+import Control.Monad.Eff.Console (log)
4
4
5type Monad m = { return :: forall a. a -> m a
5type Monad m = { return :: forall a. a -> m a
6 , bind :: forall a b. m a -> (a -> m b) -> m b }
6 , bind :: forall a b. m a -> (a -> m b) -> m b }
@@ -29,4 +29,4 @@ test1 = test id
29
29
30test2 = test maybe
30test2 = test maybe
31
31
32−main = Control.Monad.Eff.Console.log "Done"
32+main = log "Done"
examples/passing/MutRec.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5f 0.0 = 0.0
6f 0.0 = 0.0
6f x = g x + 0.0
7f x = g x + 0.0
@@ -16,4 +17,4 @@ evenToNumber (Even n) = oddToNumber n + 0.0
16
17
17oddToNumber (Odd n) = evenToNumber n + 0.0
18oddToNumber (Odd n) = evenToNumber n + 0.0
18
19
19−main = Control.Monad.Eff.Console.log "Done"
20+main = log "Done"
examples/passing/MutRec2.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data A = A B
6data A = A B
6
7
@@ -16,4 +17,4 @@ g b = case b of B a -> f a
16showN :: A -> S
17showN :: A -> S
17showN a = f a
18showN a = f a
18
19
19−main = Control.Monad.Eff.Console.log "Done"
20+main = log "Done"
examples/passing/MutRec3.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data A = A B
6data A = A B
6
7
@@ -16,4 +17,4 @@ g b = case b of B a -> f a
16showN :: A -> S
17showN :: A -> S
17showN a = f a
18showN a = f a
18
19
19−main = Control.Monad.Eff.Console.log "Done"
20+main = log "Done"
examples/passing/NamedPatterns.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5foo = \x -> case x of
6foo = \x -> case x of
6 y@{ foo = "Foo" } -> y
7 y@{ foo = "Foo" } -> y
7 y -> y
8 y -> y
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/NegativeBinder.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5test :: Number -> Boolean
6test :: Number -> Boolean
6test -1.0 = false
7test -1.0 = false
7test _ = true
8test _ = true
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/NegativeIntInRange.purs+2−1
@@ -1,8 +1,9 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5n :: Int
6n :: Int
6n = -2147483648
7n = -2147483648
7
8
8−main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/passing/Nested.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Extend r a = Extend { prev :: r a, next :: a }
6data Extend r a = Extend { prev :: r a, next :: a }
6
7
7data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
8data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/NestedWhere.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5f x = g x
6f x = g x
6 where
7 where
@@ -9,4 +10,4 @@ f x = g x
9 go x = go1 (x - 1.0)
10 go x = go1 (x - 1.0)
10 go1 x = go x
11 go1 x = go x
11
12
12−main = Control.Monad.Eff.Console.log "Done"
13+main = log "Done"
examples/passing/NonConflictingExports.purs+5−4
@@ -1,9 +1,10 @@
1-- No failure here as the export `thing` only refers to Main.thing
1-- No failure here as the export `thing` only refers to Main.thing
2module Main (thing, main) where
2module Main (thing, main) where
3
3
4− import A
4+import A
5+import Control.Monad.Eff.Console (log)
5
6
6− thing :: Int
7+thing :: Int
7− thing = 2
8+thing = 2
8
9
9− main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/ObjectSynonym.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5type Inner = Number
6type Inner = Number
6
7
@@ -12,4 +13,4 @@ type Outer = { inner :: Inner }
12outer :: Outer
13outer :: Outer
13outer = { inner: inner }
14outer = { inner: inner }
14
15
15−main = Control.Monad.Eff.Console.log "Done"
16+main = log "Done"
examples/passing/ObjectUpdate2.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5type X r = { | r }
6type X r = { | r }
6
7
@@ -14,4 +15,4 @@ test = blah x
14 { baz = "blah"
15 { baz = "blah"
15 }
16 }
16
17
17−main = Control.Monad.Eff.Console.log "Done"
18+main = log "Done"
examples/passing/Objects.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude hiding (append)
3import Prelude hiding (append)
4+import Control.Monad.Eff.Console (log)
4
5
5test = \x -> x.foo + x.bar + 1.0
6test = \x -> x.foo + x.bar + 1.0
6
7
@@ -32,4 +33,4 @@ test6 = case { "***": 1.0 } of
32
33
33test7 {a: snoog , b : blah } = blah
34test7 {a: snoog , b : blah } = blah
34
35
35−main = Control.Monad.Eff.Console.log "Done"
36+main = log "Done"
examples/passing/OneConstructor.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data One a = One a
6data One a = One a
6
7
7one' (One a) = a
8one' (One a) = a
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/Operators.purs+4−8
@@ -1,6 +1,8 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Other (foo)
5+import Other as Other
4import Control.Monad.Eff
6import Control.Monad.Eff
5import Control.Monad.Eff.Console
7import Control.Monad.Eff.Console
6
8
@@ -9,9 +11,6 @@ op1 x _ = x
9
11
10infix 4 op1 as ?!
12infix 4 op1 as ?!
11
13
12−bar :: String -> String -> String
13−bar = \s1 s2 -> s1 <> s2
14−
15test1 :: forall n. (Semiring n) => n -> n -> (n -> n -> n) -> n
14test1 :: forall n. (Semiring n) => n -> n -> (n -> n -> n) -> n
16test1 x y z = x * y + z x y
15test1 x y z = x * y + z x y
17
16
@@ -44,14 +43,11 @@ op4 = \f x -> f x
44
43
45infix 4 op4 as @@
44infix 4 op4 as @@
46
45
47−foo :: String -> String
48−foo = \s -> s
49−
50test8 = foo @@ "Hello World"
46test8 = foo @@ "Hello World"
51
47
52−test9 = Main.foo @@ "Hello World"
48+test9 = Other.foo @@ "Hello World"
53
49
54−test10 = "Hello" `Main.bar` "World"
50+test10 = "Hello" `Other.baz` "World"
55
51
56op5 :: forall a. Array a -> Array a -> Array a
52op5 :: forall a. Array a -> Array a -> Array a
57op5 = \as -> \bs -> as
53op5 = \as -> \bs -> as
examples/passing/Operators/Other.pursnew file+7
@@ -0,0 +1,7 @@
1+module Other where
2+
3+foo :: String -> String
4+foo s = s
5+
6+baz :: String -> String -> String
7+baz s _ = s
examples/passing/OptimizerBug.purs+2−1
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5x a = 1.0 + y a
6x a = 1.0 + y a
6
7
7y a = x a
8y a = x a
8
9
9−main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/Patterns.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5test = \x -> case x of
6test = \x -> case x of
6 { str = "Foo", bool = true } -> true
7 { str = "Foo", bool = true } -> true
@@ -19,4 +20,4 @@ isDesc :: Array Number -> Boolean
19isDesc [x, y] | x > y = true
20isDesc [x, y] | x > y = true
20isDesc _ = false
21isDesc _ = false
21
22
22−main = Control.Monad.Eff.Console.log "Done"
23+main = log "Done"
examples/passing/PendingConflictingImports.purs+2−1
@@ -3,5 +3,6 @@ module Main where
3-- No error as we never force `thing` to be resolved in `Main`
3-- No error as we never force `thing` to be resolved in `Main`
4import A
4import A
5import B
5import B
6+import Control.Monad.Eff.Console (log)
6
7
7−main = Control.Monad.Eff.Console.log "Done"
8+main = log "Done"
examples/passing/PendingConflictingImports2.purs+6−5
@@ -1,9 +1,10 @@
1module Main where
1module Main where
2
2
3− import A
3+import A
4+import Control.Monad.Eff.Console (log)
4
5
5− -- No error as we never force `thing` to be resolved in `Main`
6+-- No error as we never force `thing` to be resolved in `Main`
6− thing :: Int
7+thing :: Int
7− thing = 2
8+thing = 2
8
9
9− main = Control.Monad.Eff.Console.log "Done"
10+main = log "Done"
examples/passing/QualifiedNames.purs+3−1
@@ -1,9 +1,11 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Either as Either
5+import Control.Monad.Eff.Console (log)
4
6
5either :: forall a b c. (a -> c) -> (b -> c) -> Either.Either a b -> c
7either :: forall a b c. (a -> c) -> (b -> c) -> Either.Either a b -> c
6either f _ (Either.Left x) = f x
8either f _ (Either.Left x) = f x
7either _ g (Either.Right y) = g y
9either _ g (Either.Right y) = g y
8
10
9−main = Control.Monad.Eff.Console.log (either id id (Either.Left "Done"))
11+main = log (either id id (Either.Left "Done"))
examples/passing/Rank2Types.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5test1 :: (forall a. (a -> a)) -> Number
6test1 :: (forall a. (a -> a)) -> Number
6test1 = \f -> f 0.0
7test1 = \f -> f 0.0
@@ -8,4 +9,4 @@ test1 = \f -> f 0.0
8forever :: forall m a b. (forall a b. m a -> (a -> m b) -> m b) -> m a -> m b
9forever :: forall m a b. (forall a b. m a -> (a -> m b) -> m b) -> m a -> m b
9forever = \bind action -> bind action $ \_ -> forever bind action
10forever = \bind action -> bind action $ \_ -> forever bind action
10
11
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/passing/ReExportQualified.purs+2−1
@@ -2,5 +2,6 @@ module Main where
2
2
3import Prelude
3import Prelude
4import C
4import C
5+import Control.Monad.Eff.Console (log)
5
6
6−main = Control.Monad.Eff.Console.log (x <> y)
7+main = log (x <> y)
examples/passing/Recursion.purs+2−1
@@ -1,10 +1,11 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5fib = \n -> case n of
6fib = \n -> case n of
6 0.0 -> 1.0
7 0.0 -> 1.0
7 1.0 -> 1.0
8 1.0 -> 1.0
8 n -> fib (n - 1.0) + fib (n - 2.0)
9 n -> fib (n - 1.0) + fib (n - 2.0)
9
10
10−main = Control.Monad.Eff.Console.log "Done"
11+main = log "Done"
examples/passing/RedefinedFixity.purs+2−1
@@ -1,5 +1,6 @@
1module Main where
1module Main where
2
2
3import M3
3import M3
4+import Control.Monad.Eff.Console (log)
4
5
5−main = Control.Monad.Eff.Console.log "Done"
6+main = log "Done"
examples/passing/ReservedWords.purs+2−1
@@ -3,6 +3,7 @@ module Main where
3
3
4import Prelude
4import Prelude
5import Control.Monad.Eff
5import Control.Monad.Eff
6+import Control.Monad.Eff.Console (log)
6
7
7o :: { type :: String }
8o :: { type :: String }
8o = { type: "o" }
9o = { type: "o" }
@@ -15,4 +16,4 @@ f { type = "p" } = "Done"
15f _ = "Fail"
16f _ = "Fail"
16
17
17main :: Eff _ _
18main :: Eff _ _
18−main = Control.Monad.Eff.Console.log $ f { type: p.type, foo: "bar" }
19+main = log $ f { type: p.type, foo: "bar" }
examples/passing/ResolvableScopeConflict.purs+2−1
@@ -2,6 +2,7 @@ module Main where
2
2
3import A (thing)
3import A (thing)
4import B
4import B
5+import Control.Monad.Eff.Console (log)
5
6
6-- Not an error as although we have `thing` in scope from both A and B, it is
7-- Not an error as although we have `thing` in scope from both A and B, it is
7-- imported explicitly from A, giving it a resolvable solution.
8-- imported explicitly from A, giving it a resolvable solution.
@@ -9,4 +10,4 @@ what :: Boolean -> Int
9what true = thing
10what true = thing
10what false = zing
11what false = zing
11
12
12−main = Control.Monad.Eff.Console.log "Done"
13+main = log "Done"
examples/passing/ResolvableScopeConflict2.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import A
3import A
4+import Control.Monad.Eff.Console (log)
4
5
5thing :: Int
6thing :: Int
6thing = 1
7thing = 1
@@ -11,4 +12,4 @@ what :: Boolean -> Int
11what true = thing
12what true = thing
12what false = zing
13what false = zing
13
14
14−main = Control.Monad.Eff.Console.log "Done"
15+main = log "Done"
examples/passing/ResolvableScopeConflict3.purs+2−1
@@ -1,8 +1,9 @@
1module Main (thing, main, module A) where
1module Main (thing, main, module A) where
2
2
3import A
3import A
4+import Control.Monad.Eff.Console (log)
4
5
5thing :: Int
6thing :: Int
6thing = 2
7thing = 2
7
8
8−main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/passing/RowConstructors.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5type Foo = (x :: Number | (y :: Number | (z :: Number)))
6type Foo = (x :: Number | (y :: Number | (z :: Number)))
6type Bar = (x :: Number, y :: Number, z :: Number)
7type Bar = (x :: Number, y :: Number, z :: Number)
@@ -39,4 +40,4 @@ wildcard { w: w } = { x: w, y: w, z: w, w: w }
39wildcard' :: { | Quux _ } -> Number
40wildcard' :: { | Quux _ } -> Number
40wildcard' { q: q } = q
41wildcard' { q: q } = q
41
42
42−main = Control.Monad.Eff.Console.log "Done"
43+main = log "Done"
examples/passing/RowPolyInstanceContext.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5class T s m where
6class T s m where
6 state :: (s -> s) -> m Unit
7 state :: (s -> s) -> m Unit
@@ -19,4 +20,4 @@ test2 = state $ \o -> o { foo = o.foo <> "!" }
19main = do
20main = do
20 let t1 = test1
21 let t1 = test1
21 let t2 = test2
22 let t2 = test2
22− Control.Monad.Eff.Console.log "Done"
23+ log "Done"
examples/passing/ScopedTypeVariables.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5test1 :: forall a. (a -> a) -> a -> a
6test1 :: forall a. (a -> a) -> a -> a
6test1 f x = g (g x)
7test1 f x = g (g x)
@@ -33,4 +34,4 @@ test4 = h
33 j x = x
34 j x = x
34
35
35
36
36−main = Control.Monad.Eff.Console.log "Done"
37+main = log "Done"
examples/passing/Sequence.purs+2−1
@@ -2,6 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
5+import Control.Monad.Eff.Console (log)
5
6
6data List a = Cons a (List a) | Nil
7data List a = Cons a (List a) | Nil
7
8
@@ -12,4 +13,4 @@ instance sequenceList :: Sequence List where
12 sequence Nil = pure Nil
13 sequence Nil = pure Nil
13 sequence (Cons x xs) = Cons <$> x <*> sequence xs
14 sequence (Cons x xs) = Cons <$> x <*> sequence xs
14
15
15−main = sequence $ Cons (Control.Monad.Eff.Console.log "Done") Nil
16+main = sequence $ Cons (log "Done") Nil
examples/passing/SequenceDesugared.purs+5−4
@@ -2,6 +2,7 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Control.Monad.Eff
4import Control.Monad.Eff
5+import Control.Monad.Eff.Console (log)
5
6
6data List a = Cons a (List a) | Nil
7data List a = Cons a (List a) | Nil
7
8
@@ -31,7 +32,7 @@ sequenceList''' = Sequence ((\val -> case val of
31 Cons x xs -> Cons <$> x <*> sequence sequenceList''' xs) :: forall m a. (Monad m) => List (m a) -> m (List a))
32 Cons x xs -> Cons <$> x <*> sequence sequenceList''' xs) :: forall m a. (Monad m) => List (m a) -> m (List a))
32
33
33main = do
34main = do
34− sequence sequenceList $ Cons (Control.Monad.Eff.Console.log "Done") Nil
35+ sequence sequenceList $ Cons (log "Done") Nil
35− sequence sequenceList' $ Cons (Control.Monad.Eff.Console.log "Done") Nil
36+ sequence sequenceList' $ Cons (log "Done") Nil
36− sequence sequenceList'' $ Cons (Control.Monad.Eff.Console.log "Done") Nil
37+ sequence sequenceList'' $ Cons (log "Done") Nil
37− sequence sequenceList''' $ Cons (Control.Monad.Eff.Console.log "Done") Nil
38+ sequence sequenceList''' $ Cons (log "Done") Nil
examples/passing/ShadowedName.purs+2−1
@@ -2,9 +2,10 @@ module Main where
2
2
3import Prelude
3import Prelude
4import Control.Monad.Eff.Console
4import Control.Monad.Eff.Console
5+import Control.Monad.Eff.Console (log)
5
6
6done :: String
7done :: String
7done = let str = "Not yet done" in
8done = let str = "Not yet done" in
8 let str = "Done" in str
9 let str = "Done" in str
9
10
10−main = Control.Monad.Eff.Console.log done
11+main = log done
examples/passing/SignedNumericLiterals.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5p = 0.5
6p = 0.5
6q = 1.0
7q = 1.0
@@ -14,4 +15,4 @@ f x = -x
14
15
15test1 = 2.0 - 1.0
16test1 = 2.0 - 1.0
16
17
17−main = Control.Monad.Eff.Console.log "Done"
18+main = log "Done"
examples/passing/TCOCase.purs+2−1
@@ -1,10 +1,11 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Data = One | More Data
6data Data = One | More Data
6
7
7−main = Control.Monad.Eff.Console.log (from (to 10000.0 One))
8+main = log (from (to 10000.0 One))
8 where
9 where
9 to 0.0 a = a
10 to 0.0 a = a
10 to n a = to (n - 1.0) (More a)
11 to n a = to (n - 1.0) (More a)
examples/passing/Tick.purs+2−1
@@ -1,7 +1,8 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5test' x = x
6test' x = x
6
7
7−main = Control.Monad.Eff.Console.log "Done"
8+main = log "Done"
examples/passing/TopLevelCase.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5gcd :: Number -> Number -> Number
6gcd :: Number -> Number -> Number
6gcd 0.0 x = x
7gcd 0.0 x = x
@@ -15,4 +16,4 @@ data A = A
15
16
16parseTest A 0.0 = 0.0
17parseTest A 0.0 = 0.0
17
18
18−main = Control.Monad.Eff.Console.log "Done"
19+main = log "Done"
examples/passing/TransitiveImport/Middle.purs+3−1
@@ -1,3 +1,5 @@
1module Middle where
1module Middle where
2
2
3+import Test (test)
4+
3−middle = Test.test
5+middle = test
examples/passing/TypeClasses.purs+3−3
@@ -5,19 +5,19 @@ import Control.Monad.Eff.Console (log)
5
5
6test1 = \_ -> show "testing"
6test1 = \_ -> show "testing"
7
7
8−f :: forall a. (Prelude.Show a) => a -> String
8+f :: forall a. (Show a) => a -> String
9f x = show x
9f x = show x
10
10
11test2 = \_ -> f "testing"
11test2 = \_ -> f "testing"
12
12
13−test7 :: forall a. (Prelude.Show a) => a -> String
13+test7 :: forall a. (Show a) => a -> String
14test7 = show
14test7 = show
15
15
16test8 = \_ -> show $ "testing"
16test8 = \_ -> show $ "testing"
17
17
18data Data a = Data a
18data Data a = Data a
19
19
20−instance showData :: (Prelude.Show a) => Prelude.Show (Data a) where
20+instance showData :: (Show a) => Show (Data a) where
21 show (Data a) = "Data (" <> show a <> ")"
21 show (Data a) = "Data (" <> show a <> ")"
22
22
23test3 = \_ -> show (Data "testing")
23test3 = \_ -> show (Data "testing")
examples/passing/TypeClassesInOrder.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5class Foo a where
6class Foo a where
6 foo :: a -> String
7 foo :: a -> String
@@ -8,4 +9,4 @@ class Foo a where
8instance fooString :: Foo String where
9instance fooString :: Foo String where
9 foo s = s
10 foo s = s
10
11
11−main = Control.Monad.Eff.Console.log $ foo "Done"
12+main = log $ foo "Done"
examples/passing/TypeClassesWithOverlappingTypeVariables.purs+3−2
@@ -1,11 +1,12 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Either a b = Left a | Right b
6data Either a b = Left a | Right b
6
7
7−instance functorEither :: Prelude.Functor (Either a) where
8+instance functorEither :: Functor (Either a) where
8 map _ (Left x) = Left x
9 map _ (Left x) = Left x
9 map f (Right y) = Right (f y)
10 map f (Right y) = Right (f y)
10
11
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/passing/TypeDecl.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5k :: String -> Number -> String
6k :: String -> Number -> String
6k x y = x
7k x y = x
@@ -9,4 +10,4 @@ iterate :: forall a. Number -> (a -> a) -> a -> a
9iterate 0.0 f a = a
10iterate 0.0 f a = a
10iterate n f a = iterate (n - 1.0) f (f a)
11iterate n f a = iterate (n - 1.0) f (f a)
11
12
12−main = Control.Monad.Eff.Console.log "Done"
13+main = log "Done"
examples/passing/TypeOperators.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import A (type (~>), type (/\), (/\))
3import A (type (~>), type (/\), (/\))
4+import Control.Monad.Eff.Console (log)
4
5
5natty ∷ ∀ f. f ~> f
6natty ∷ ∀ f. f ~> f
6natty x = x
7natty x = x
@@ -16,4 +17,4 @@ testPrecedence2 nat fx = nat fx
16swap ∷ ∀ a b. a /\ b → b /\ a
17swap ∷ ∀ a b. a /\ b → b /\ a
17swap (a /\ b) = b /\ a
18swap (a /\ b) = b /\ a
18
19
19−main = Control.Monad.Eff.Console.log "Done"
20+main = log "Done"
examples/passing/TypeSynonymInData.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5type A a = Array a
6type A a = Array a
6
7
@@ -8,4 +9,4 @@ data Foo a = Foo (A a) | Bar
8
9
9foo (Foo []) = Bar
10foo (Foo []) = Bar
10
11
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/passing/TypeSynonyms.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5type Lens a b =
6type Lens a b =
6 { get :: a -> b
7 { get :: a -> b
@@ -24,4 +25,4 @@ fst =
24test1 :: forall a b c. Lens (Pair (Pair a b) c) a
25test1 :: forall a b c. Lens (Pair (Pair a b) c) a
25test1 = composeLenses fst fst
26test1 = composeLenses fst fst
26
27
27−main = Control.Monad.Eff.Console.log "Done"
28+main = log "Done"
examples/passing/TypeWildcards.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5testTopLevel :: _ -> _
6testTopLevel :: _ -> _
6testTopLevel n = n + 1.0
7testTopLevel n = n + 1.0
@@ -12,4 +13,4 @@ test f a = go (f a) a
12 go a1 a2 | a1 == a2 = a1
13 go a1 a2 | a1 == a2 = a1
13 go a1 _ = go (f a1) a1
14 go a1 _ = go (f a1) a1
14
15
15−main = Control.Monad.Eff.Console.log "Done"
16+main = log "Done"
examples/passing/TypeWildcardsRecordExtension.purs+2−1
@@ -1,8 +1,9 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5foo :: forall a. {b :: Number | a} -> {b :: Number | _}
6foo :: forall a. {b :: Number | a} -> {b :: Number | _}
6foo f = f
7foo f = f
7
8
8−main = Control.Monad.Eff.Console.log "Done"
9+main = log "Done"
examples/passing/TypeWithoutParens.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Lib (X, Y)
3import Lib (X, Y)
4+import Control.Monad.Eff.Console (log)
4
5
5idX :: X -> X
6idX :: X -> X
6idX x = x
7idX x = x
@@ -8,4 +9,4 @@ idX x = x
8idY :: Y -> Y
9idY :: Y -> Y
9idY y = y
10idY y = y
10
11
11−main = Control.Monad.Eff.Console.log "Done"
12+main = log "Done"
examples/passing/TypedBinders.purs+3−2
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Tuple a b = Tuple a b
6data Tuple a b = Tuple a b
6
7
@@ -31,7 +32,7 @@ instance monadStateState :: MonadState s (State s) where
31 get = State (\s -> Tuple s s)
32 get = State (\s -> Tuple s s)
32 put s = State (\_ -> Tuple s {})
33 put s = State (\_ -> Tuple s {})
33
34
34−modify :: forall m s. (Prelude.Monad m, MonadState s m) => (s -> s) -> m {}
35+modify :: forall m s. (Monad m, MonadState s m) => (s -> s) -> m {}
35modify f = do
36modify f = do
36 s <- get
37 s <- get
37 put (f s)
38 put (f s)
@@ -64,4 +65,4 @@ main = do
64 t2 = test2 id
65 t2 = test2 id
65 t3 = test3 1
66 t3 = test3 1
66 t4 = test4 (Tuple 1 0)
67 t4 = test4 (Tuple 1 0)
67− Control.Monad.Eff.Console.log "Done"
68+ log "Done"
examples/passing/TypedWhere.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data E a b = L a | R b
6data E a b = L a | R b
6
7
@@ -14,4 +15,4 @@ lefts = go N
14 go ls (C (L a) rest) = go (C a ls) rest
15 go ls (C (L a) rest) = go (C a ls) rest
15 go ls (C _ rest) = go ls rest
16 go ls (C _ rest) = go ls rest
16
17
17−main = Control.Monad.Eff.Console.log "Done"
18+main = log "Done"
examples/passing/UnderscoreIdent.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5data Data_type = Con_Structor | Con_2 String
6data Data_type = Con_Structor | Con_2 String
6
7
@@ -9,4 +10,4 @@ type Type_name = Data_type
9done (Con_2 s) = s
10done (Con_2 s) = s
10done _ = "Failed"
11done _ = "Failed"
11
12
12−main = Control.Monad.Eff.Console.log (done (Con_2 "Done"))
13+main = log (done (Con_2 "Done"))
examples/passing/UnicodeIdentifier.purs+3−1
@@ -1,5 +1,7 @@
1module Main where
1module Main where
2
2
3+import Control.Monad.Eff.Console (log)
4+
3f asgård = asgård
5f asgård = asgård
4
6
5−main = Control.Monad.Eff.Console.log (f "Done")
7+main = log (f "Done")
examples/passing/UnicodeOperators.purs+3−1
@@ -1,5 +1,7 @@
1module Main where
1module Main where
2
2
3+import Control.Monad.Eff.Console (log)
4+
3compose :: forall a b c. (b -> c) -> (a -> b) -> a -> c
5compose :: forall a b c. (b -> c) -> (a -> b) -> a -> c
4compose f g a = f (g a)
6compose f g a = f (g a)
5
7
@@ -17,4 +19,4 @@ emptySet _ = true
17
19
18test2 = 1 ∈ emptySet
20test2 = 1 ∈ emptySet
19
21
20−main = Control.Monad.Eff.Console.log "Done"
22+main = log "Done"
examples/passing/UnknownInTypeClassLookup.purs+2−1
@@ -1,6 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5class EQ a b
6class EQ a b
6
7
@@ -11,4 +12,4 @@ test _ _ = "Done"
11
12
12runTest a = test a a
13runTest a = test a a
13
14
14−main = Control.Monad.Eff.Console.log $ runTest 0.0
15+main = log $ runTest 0.0
examples/passing/UntupledConstraints.purs+1−1
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff.Console
4+import Control.Monad.Eff.Console (log)
5
5
6class Show a <= Nonsense a where
6class Show a <= Nonsense a where
7 method :: a -> a
7 method :: a -> a
examples/passing/WildcardType.purs+2−3
@@ -1,7 +1,7 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4−import Control.Monad.Eff.Console
4+import Control.Monad.Eff.Console (log)
5
5
6f1 :: (_ -> _) -> _
6f1 :: (_ -> _) -> _
7f1 g = g 1
7f1 g = g 1
@@ -9,5 +9,4 @@ f1 g = g 1
9f2 :: _ -> _
9f2 :: _ -> _
10f2 _ = "Done"
10f2 _ = "Done"
11
11
12−main = Control.Monad.Eff.Console.log $ f1 f2
12+main = log $ f1 f2
13−
examples/passing/iota.purs+3−1
@@ -1,9 +1,11 @@
1module Main where
1module Main where
2
2
3+import Control.Monad.Eff.Console (log)
4+
3s = \x -> \y -> \z -> x z (y z)
5s = \x -> \y -> \z -> x z (y z)
4
6
5k = \x -> \y -> x
7k = \x -> \y -> x
6
8
7iota = \x -> x s k
9iota = \x -> x s k
8
10
9−main = Control.Monad.Eff.Console.log "Done"
11+main = log "Done"
examples/passing/s.purs+2−1
@@ -1,7 +1,8 @@
1module Main where
1module Main where
2
2
3import Prelude
3import Prelude
4+import Control.Monad.Eff.Console (log)
4
5
5s = \x y z -> x z (y z)
6s = \x y z -> x z (y z)
6
7
7−main = Control.Monad.Eff.Console.log "Done"
8+main = log "Done"
purescript.cabal+1
@@ -38,6 +38,7 @@ extra-source-files: examples/passing/*.purs
38 , examples/passing/ModuleExportSelf/*.purs
38 , examples/passing/ModuleExportSelf/*.purs
39 , examples/passing/NonConflictingExports/*.purs
39 , examples/passing/NonConflictingExports/*.purs
40 , examples/passing/OperatorAliasElsewhere/*.purs
40 , examples/passing/OperatorAliasElsewhere/*.purs
41+ , examples/passing/Operators/*.purs
41 , examples/passing/PendingConflictingImports/*.purs
42 , examples/passing/PendingConflictingImports/*.purs
42 , examples/passing/PendingConflictingImports2/*.purs
43 , examples/passing/PendingConflictingImports2/*.purs
43 , examples/passing/QualifiedNames/*.purs
44 , examples/passing/QualifiedNames/*.purs
src/Language/PureScript/Linter/Imports.hs+5−2
@@ -60,7 +60,7 @@ lintImports (Module ss _ mn mdecls (Just mexports)) env usedImps = do
60
60
61 -- TODO: this needs some work to be easier to understand
61 -- TODO: this needs some work to be easier to understand
62
62
63− let scope = maybe nullImports (\(_, imps', _) -> imps') (M.lookup mn env)
63+ let scope = maybe primImports (\(_, imps', _) -> imps') (M.lookup mn env)
64 usedImps' = foldr (elaborateUsed scope) usedImps exportedModules
64 usedImps' = foldr (elaborateUsed scope) usedImps exportedModules
65 numOpenImports = getSum $ foldMap (Sum . countOpenImports) mdecls
65 numOpenImports = getSum $ foldMap (Sum . countOpenImports) mdecls
66 allowImplicit = numOpenImports == 1
66 allowImplicit = numOpenImports == 1
@@ -159,9 +159,11 @@ lintImports (Module ss _ mn mdecls (Just mexports)) env usedImps = do
159 elaborateUsed scope mne used =
159 elaborateUsed scope mne used =
160 foldr go used
160 foldr go used
161 $ extractByQual mne (importedTypeClasses scope) TyClassName
161 $ extractByQual mne (importedTypeClasses scope) TyClassName
162+ ++ extractByQual mne (importedTypeOps scope) TyOpName
162 ++ extractByQual mne (importedTypes scope) TyName
163 ++ extractByQual mne (importedTypes scope) TyName
163 ++ extractByQual mne (importedDataConstructors scope) DctorName
164 ++ extractByQual mne (importedDataConstructors scope) DctorName
164 ++ extractByQual mne (importedValues scope) IdentName
165 ++ extractByQual mne (importedValues scope) IdentName
166+ ++ extractByQual mne (importedValueOps scope) ValOpName
165 where
167 where
166 go :: (ModuleName, Qualified Name) -> UsedImports -> UsedImports
168 go :: (ModuleName, Qualified Name) -> UsedImports -> UsedImports
167 go (q, name) = M.alter (Just . maybe [name] (name :)) q
169 go (q, name) = M.alter (Just . maybe [name] (name :)) q
@@ -298,6 +300,7 @@ findUsedRefs env mni qn names =
298 let
300 let
299 classRefs = TypeClassRef <$> mapMaybe (getClassName <=< disqualifyFor qn) names
301 classRefs = TypeClassRef <$> mapMaybe (getClassName <=< disqualifyFor qn) names
300 valueRefs = ValueRef <$> mapMaybe (getIdentName <=< disqualifyFor qn) names
302 valueRefs = ValueRef <$> mapMaybe (getIdentName <=< disqualifyFor qn) names
303+ valueOpRefs = ValueOpRef <$> mapMaybe (getValOpName <=< disqualifyFor qn) names
301 typeOpRefs = TypeOpRef <$> mapMaybe (getTypeOpName <=< disqualifyFor qn) names
304 typeOpRefs = TypeOpRef <$> mapMaybe (getTypeOpName <=< disqualifyFor qn) names
302 types = mapMaybe (getTypeName <=< disqualifyFor qn) names
305 types = mapMaybe (getTypeName <=< disqualifyFor qn) names
303 dctors = mapMaybe (getDctorName <=< disqualifyFor qn) names
306 dctors = mapMaybe (getDctorName <=< disqualifyFor qn) names
@@ -306,7 +309,7 @@ findUsedRefs env mni qn names =
306 typesRefs
309 typesRefs
307 = map (flip TypeRef (Just [])) typesWithoutDctors
310 = map (flip TypeRef (Just [])) typesWithoutDctors
308 ++ map (\(ty, ds) -> TypeRef ty (Just ds)) (M.toList typesWithDctors)
311 ++ map (\(ty, ds) -> TypeRef ty (Just ds)) (M.toList typesWithDctors)
309− in classRefs ++ typeOpRefs ++ typesRefs ++ valueRefs
312+ in classRefs ++ typeOpRefs ++ typesRefs ++ valueRefs ++ valueOpRefs
310
313
311 where
314 where
312
315
src/Language/PureScript/Sugar/Names.hs+29−67
@@ -16,7 +16,7 @@ import Control.Monad.Error.Class (MonadError(..))
16import Control.Monad.State.Lazy
16import Control.Monad.State.Lazy
17import Control.Monad.Writer (MonadWriter(..), censor)
17import Control.Monad.Writer (MonadWriter(..), censor)
18
18
19−import Data.List (find, nub)
19+import Data.List (nub)
20import Data.Maybe (fromMaybe, mapMaybe)
20import Data.Maybe (fromMaybe, mapMaybe)
21import qualified Data.Map as M
21import qualified Data.Map as M
22import qualified Data.Set as S
22import qualified Data.Set as S
@@ -65,9 +65,9 @@ desugarImportsWithEnv externs modules = do
65 externsEnv env ExternsFile{..} = do
65 externsEnv env ExternsFile{..} = do
66 let members = Exports{..}
66 let members = Exports{..}
67 ss = internalModuleSourceSpan "<Externs>"
67 ss = internalModuleSourceSpan "<Externs>"
68− env' = M.insert efModuleName (ss, nullImports, members) env
68+ env' = M.insert efModuleName (ss, primImports, members) env
69 fromEFImport (ExternsImport mn mt qmn) = (mn, [(Nothing, Just mt, qmn)])
69 fromEFImport (ExternsImport mn mt qmn) = (mn, [(Nothing, Just mt, qmn)])
70− imps <- foldM (resolveModuleImport env') nullImports (map fromEFImport efImports)
70+ imps <- foldM (resolveModuleImport env') primImports (map fromEFImport efImports)
71 exps <- resolveExports env' ss efModuleName imps members efExports
71 exps <- resolveExports env' ss efModuleName imps members efExports
72 return $ M.insert efModuleName (ss, imps, exps) env
72 return $ M.insert efModuleName (ss, imps, exps) env
73 where
73 where
@@ -101,7 +101,7 @@ desugarImportsWithEnv externs modules = do
101 Just m' -> throwError . errorMessage $ RedefinedModule mn [envModuleSourceSpan m', ss]
101 Just m' -> throwError . errorMessage $ RedefinedModule mn [envModuleSourceSpan m', ss]
102 Nothing -> do
102 Nothing -> do
103 members <- findExportable m
103 members <- findExportable m
104− let env' = M.insert mn (ss, nullImports, members) env
104+ let env' = M.insert mn (ss, primImports, members) env
105 (m', imps) <- resolveImports env' m
105 (m', imps) <- resolveImports env' m
106 exps <- maybe (return members) (resolveExports env' ss mn imps members) refs
106 exps <- maybe (return members) (resolveExports env' ss mn imps members) refs
107 return (m' : ms, M.insert mn (ss, imps, exps) env)
107 return (m' : ms, M.insert mn (ss, imps, exps) env)
@@ -110,7 +110,7 @@ desugarImportsWithEnv externs modules = do
110 renameInModule' env m@(Module _ _ mn _ _) =
110 renameInModule' env m@(Module _ _ mn _ _) =
111 warnAndRethrow (addHint (ErrorInModule mn)) $ do
111 warnAndRethrow (addHint (ErrorInModule mn)) $ do
112 let (_, imps, exps) = fromMaybe (internalError "Module is missing in renameInModule'") $ M.lookup mn env
112 let (_, imps, exps) = fromMaybe (internalError "Module is missing in renameInModule'") $ M.lookup mn env
113− (m', used) <- flip runStateT M.empty $ renameInModule env imps (elaborateExports exps m)
113+ (m', used) <- flip runStateT M.empty $ renameInModule imps (elaborateExports exps m)
114 lintImports m' env used
114 lintImports m' env used
115 return m'
115 return m'
116
116
@@ -147,11 +147,10 @@ elaborateExports exps (Module ss coms mn decls refs) =
147renameInModule
147renameInModule
148 :: forall m
148 :: forall m
149 . (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadState UsedImports m)
149 . (MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadState UsedImports m)
150− => Env
151− -> Imports
150+ => Imports
152 -> Module
151 -> Module
153 -> m Module
152 -> m Module
154−renameInModule env imports (Module ss coms mn decls exps) =
153+renameInModule imports (Module ss coms mn decls exps) =
155 Module ss coms mn <$> parU decls go <*> pure exps
154 Module ss coms mn <$> parU decls go <*> pure exps
156 where
155 where
157
156
@@ -219,10 +218,9 @@ renameInModule env imports (Module ss coms mn decls exps) =
219 (,) s <$> (ConstructorBinder <$> updateDataConstructorName name pos <*> pure b)
218 (,) s <$> (ConstructorBinder <$> updateDataConstructorName name pos <*> pure b)
220 updateBinder s@(pos, _) (OpBinder op) =
219 updateBinder s@(pos, _) (OpBinder op) =
221 (,) s <$> (OpBinder <$> updateValueOpName op pos)
220 (,) s <$> (OpBinder <$> updateValueOpName op pos)
222− updateBinder s (TypedBinder t b) = do
221+ updateBinder s@(pos, _) (TypedBinder t b) = do
223− (s'@ (span', _), b') <- updateBinder s b
224− t' <- updateTypesEverywhere span' t
222+ t' <- updateTypesEverywhere pos t
225− return (s', TypedBinder t' b')
223+ return (s, TypedBinder t' b)
226 updateBinder s v =
224 updateBinder s v =
227 return (s, v)
225 return (s, v)
228
226
@@ -244,82 +242,51 @@ renameInModule env imports (Module ss coms mn decls exps) =
244 updateType :: Type -> m Type
242 updateType :: Type -> m Type
245 updateType (TypeOp name) = TypeOp <$> updateTypeOpName name pos
243 updateType (TypeOp name) = TypeOp <$> updateTypeOpName name pos
246 updateType (TypeConstructor name) = TypeConstructor <$> updateTypeName name pos
244 updateType (TypeConstructor name) = TypeConstructor <$> updateTypeName name pos
247− updateType (ConstrainedType cs t) = ConstrainedType <$> updateConstraints pos cs <*> pure t
245+ updateType (ConstrainedType cs t) = ConstrainedType <$> traverse updateInConstraint cs <*> pure t
248 updateType t = return t
246 updateType t = return t
247+ updateInConstraint :: Constraint -> m Constraint
248+ updateInConstraint (Constraint name ts info) =
249+ Constraint <$> updateClassName name pos <*> pure ts <*> pure info
249
250
250 updateConstraints :: Maybe SourceSpan -> [Constraint] -> m [Constraint]
251 updateConstraints :: Maybe SourceSpan -> [Constraint] -> m [Constraint]
251− updateConstraints pos = traverse (\(Constraint name ts info) ->
252+ updateConstraints pos = traverse $ \(Constraint name ts info) ->
253+ Constraint
252− Constraint <$> updateClassName name pos
254+ <$> updateClassName name pos
253− <*> traverse (updateTypesEverywhere pos) ts
255+ <*> traverse (updateTypesEverywhere pos) ts
254− <*> pure info)
256+ <*> pure info
255
257
256 updateTypeName
258 updateTypeName
257 :: Qualified (ProperName 'TypeName)
259 :: Qualified (ProperName 'TypeName)
258 -> Maybe SourceSpan
260 -> Maybe SourceSpan
259 -> m (Qualified (ProperName 'TypeName))
261 -> m (Qualified (ProperName 'TypeName))
260− updateTypeName =
261− update (importedTypes imports) (resolveType . exportedTypes) TyName
262+ updateTypeName = update (importedTypes imports) TyName
262
263
263 updateTypeOpName
264 updateTypeOpName
264 :: Qualified (OpName 'TypeOpName)
265 :: Qualified (OpName 'TypeOpName)
265 -> Maybe SourceSpan
266 -> Maybe SourceSpan
266 -> m (Qualified (OpName 'TypeOpName))
267 -> m (Qualified (OpName 'TypeOpName))
267− updateTypeOpName =
268− update (importedTypeOps imports) (resolve . exportedTypeOps) TyOpName
268+ updateTypeOpName = update (importedTypeOps imports) TyOpName
269
269
270 updateDataConstructorName
270 updateDataConstructorName
271 :: Qualified (ProperName 'ConstructorName)
271 :: Qualified (ProperName 'ConstructorName)
272 -> Maybe SourceSpan
272 -> Maybe SourceSpan
273 -> m (Qualified (ProperName 'ConstructorName))
273 -> m (Qualified (ProperName 'ConstructorName))
274− updateDataConstructorName =
275− update
276− (importedDataConstructors imports)
274+ updateDataConstructorName = update (importedDataConstructors imports) DctorName
277− (resolveDctor . exportedTypes)
278− DctorName
279
275
280 updateClassName
276 updateClassName
281 :: Qualified (ProperName 'ClassName)
277 :: Qualified (ProperName 'ClassName)
282 -> Maybe SourceSpan
278 -> Maybe SourceSpan
283 -> m (Qualified (ProperName 'ClassName))
279 -> m (Qualified (ProperName 'ClassName))
284− updateClassName =
285− update
286− (importedTypeClasses imports)
280+ updateClassName = update (importedTypeClasses imports) TyClassName
287− (resolve . exportedTypeClasses)
288− TyClassName
289
281
290 updateValueName :: Qualified Ident -> Maybe SourceSpan -> m (Qualified Ident)
282 updateValueName :: Qualified Ident -> Maybe SourceSpan -> m (Qualified Ident)
291− updateValueName =
292− update (importedValues imports) (resolve . exportedValues) IdentName
283+ updateValueName = update (importedValues imports) IdentName
293
284
294 updateValueOpName
285 updateValueOpName
295 :: Qualified (OpName 'ValueOpName)
286 :: Qualified (OpName 'ValueOpName)
296 -> Maybe SourceSpan
287 -> Maybe SourceSpan
297 -> m (Qualified (OpName 'ValueOpName))
288 -> m (Qualified (OpName 'ValueOpName))
298− updateValueOpName =
299− update (importedValueOps imports) (resolve . exportedValueOps) ValOpName
289+ updateValueOpName = update (importedValueOps imports) ValOpName
300−
301− -- Used when performing an update to qualify values and classes with their
302− -- module of original definition.
303− resolve :: Ord a => M.Map a ModuleName -> a -> Maybe (Qualified a)
304− resolve as name = mkQualified name <$> name `M.lookup` as
305−
306− -- Used when performing an update to qualify types with their module of
307− -- original definition.
308− resolveType
309− :: M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ModuleName)
310− -> ProperName 'TypeName
311− -> Maybe (Qualified (ProperName 'TypeName))
312− resolveType tys name =
313− mkQualified name . snd <$> M.lookup name tys
314−
315− -- Used when performing an update to qualify data constructors with their
316− -- module of original definition.
317− resolveDctor
318− :: M.Map (ProperName 'TypeName) ([ProperName 'ConstructorName], ModuleName)
319− -> ProperName 'ConstructorName
320− -> Maybe (Qualified (ProperName 'ConstructorName))
321− resolveDctor tys name =
322− mkQualified name . snd <$> find (elem name . fst) tys
323
290
324 -- Update names so unqualified references become qualified, and locally
291 -- Update names so unqualified references become qualified, and locally
325 -- qualified references are replaced with their canoncial qualified names
292 -- qualified references are replaced with their canoncial qualified names
@@ -327,12 +294,11 @@ renameInModule env imports (Module ss coms mn decls exps) =
327 update
294 update
328 :: (Ord a, Show a)
295 :: (Ord a, Show a)
329 => M.Map (Qualified a) [ImportRecord a]
296 => M.Map (Qualified a) [ImportRecord a]
330− -> (Exports -> a -> Maybe (Qualified a))
331 -> (a -> Name)
297 -> (a -> Name)
332 -> Qualified a
298 -> Qualified a
333 -> Maybe SourceSpan
299 -> Maybe SourceSpan
334 -> m (Qualified a)
300 -> m (Qualified a)
335− update imps getE toName qname@(Qualified mn' name) pos = positioned $
301+ update imps toName qname@(Qualified mn' name) pos = positioned $
336 case (M.lookup qname imps, mn') of
302 case (M.lookup qname imps, mn') of
337
303
338 -- We found the name in our imports, so we return the name for it,
304 -- We found the name in our imports, so we return the name for it,
@@ -354,13 +320,9 @@ renameInModule env imports (Module ss coms mn decls exps) =
354 -- by qualified importing). If that's not the case, then we just need to
320 -- by qualified importing). If that's not the case, then we just need to
355 -- check it refers to a symbol in another module.
321 -- check it refers to a symbol in another module.
356 (Nothing, Just mn'') ->
322 (Nothing, Just mn'') ->
357− case M.lookup mn'' env of
323+ if mn'' `S.member` importedQualModules imports || mn'' `S.member` importedModules imports
358− Nothing
324+ then throwUnknown
359− | mn'' `S.member` importedVirtualModules imports -> throwUnknown
360− | otherwise ->
361− throwError . errorMessage .
362− UnknownName . Qualified Nothing $ ModName mn''
325+ else throwError . errorMessage . UnknownName . Qualified Nothing $ ModName mn''
363− Just env' -> maybe throwUnknown return (getE (envModuleExports env') name)
364
326
365 -- If neither of the above cases are true then it's an undefined or
327 -- If neither of the above cases are true then it's an undefined or
366 -- unimported symbol.
328 -- unimported symbol.
src/Language/PureScript/Sugar/Names/Env.hs+24−8
@@ -2,7 +2,7 @@ module Language.PureScript.Sugar.Names.Env
2 ( ImportRecord(..)
2 ( ImportRecord(..)
3 , ImportProvenance(..)
3 , ImportProvenance(..)
4 , Imports(..)
4 , Imports(..)
5− , nullImports
5+ , primImports
6 , Exports(..)
6 , Exports(..)
7 , nullExports
7 , nullExports
8 , Env
8 , Env
@@ -58,6 +58,7 @@ data ImportProvenance
58 = FromImplicit
58 = FromImplicit
59 | FromExplicit
59 | FromExplicit
60 | Local
60 | Local
61+ | Prim
61 deriving (Eq, Ord, Show, Read)
62 deriving (Eq, Ord, Show, Read)
62
63
63type ImportMap a = M.Map (Qualified a) [ImportRecord a]
64type ImportMap a = M.Map (Qualified a) [ImportRecord a]
@@ -98,18 +99,33 @@ data Imports = Imports
98 --
99 --
99 , importedModules :: S.Set ModuleName
100 , importedModules :: S.Set ModuleName
100 -- |
101 -- |
101− -- The names of "virtual" modules that come into existence when "import as"
102+ -- The "as" names of modules that have been imported qualified.
102− -- is used.
103 --
103 --
104− , importedVirtualModules :: S.Set ModuleName
104+ , importedQualModules :: S.Set ModuleName
105 } deriving (Show, Read)
105 } deriving (Show, Read)
106
106
107−-- |
108−-- An empty 'Imports' value.
109−--
110nullImports :: Imports
107nullImports :: Imports
111nullImports = Imports M.empty M.empty M.empty M.empty M.empty M.empty S.empty S.empty
108nullImports = Imports M.empty M.empty M.empty M.empty M.empty M.empty S.empty S.empty
112
109
110+-- |
111+-- An 'Imports' value with imports for the `Prim` module.
112+--
113+primImports :: Imports
114+primImports =
115+ nullImports
116+ { importedTypes = M.fromList $ mkEntries `concatMap` M.keys primTypes
117+ , importedTypeClasses = M.fromList $ mkEntries `concatMap` M.keys primClasses
118+ }
119+ where
120+ mkEntries :: Qualified a -> [(Qualified a, [ImportRecord a])]
121+ mkEntries fullName@(Qualified _ name) =
122+ [ (fullName, [ImportRecord fullName primModuleName Prim])
123+ , (Qualified Nothing name, [ImportRecord fullName primModuleName Prim])
124+ ]
125+
126+primModuleName :: ModuleName
127+primModuleName = ModuleName [ProperName "Prim"]
128+
113-- |
129-- |
114-- The exported declarations from a module.
130-- The exported declarations from a module.
115--
131--
@@ -186,7 +202,7 @@ primExports =
186-- | Environment which only contains the Prim module.
202-- | Environment which only contains the Prim module.
187primEnv :: Env
203primEnv :: Env
188primEnv = M.singleton
204primEnv = M.singleton
189− (ModuleName [ProperName "Prim"])
205+ primModuleName
190 (internalModuleSourceSpan "<Prim>", nullImports, primExports)
206 (internalModuleSourceSpan "<Prim>", nullImports, primExports)
191
207
192-- |
208-- |
src/Language/PureScript/Sugar/Names/Imports.hs+5−4
@@ -53,7 +53,7 @@ resolveImports env (Module ss coms currentModule decls exps) =
53 imports' = M.map (map (\(ss', dt, mmn) -> (ss', Just dt, mmn))) imports
53 imports' = M.map (map (\(ss', dt, mmn) -> (ss', Just dt, mmn))) imports
54 scope = M.insert currentModule [(Nothing, Nothing, Nothing)] imports'
54 scope = M.insert currentModule [(Nothing, Nothing, Nothing)] imports'
55 (Module ss coms currentModule decls exps,) <$>
55 (Module ss coms currentModule decls exps,) <$>
56− foldM (resolveModuleImport env) nullImports (M.toList scope)
56+ foldM (resolveModuleImport env) primImports (M.toList scope)
57
57
58-- | Constructs a set of imports for a single module import.
58-- | Constructs a set of imports for a single module import.
59resolveModuleImport
59resolveModuleImport
@@ -74,9 +74,10 @@ resolveModuleImport env ie (mn, imps) = foldM go ie imps
74 (throwError . errorMessage . UnknownName . Qualified Nothing $ ModName mn)
74 (throwError . errorMessage . UnknownName . Qualified Nothing $ ModName mn)
75 (return . envModuleExports)
75 (return . envModuleExports)
76 (mn `M.lookup` env)
76 (mn `M.lookup` env)
77− let virtualModules = importedVirtualModules ie'
77+ let impModules = importedModules ie'
78+ qualModules = importedQualModules ie'
78− ie'' = ie' { importedModules = S.insert mn (importedModules ie')
79+ ie'' = ie' { importedModules = maybe (S.insert mn impModules) (const impModules) impQual
79− , importedVirtualModules = maybe virtualModules (`S.insert` virtualModules) impQual
80+ , importedQualModules = maybe qualModules (`S.insert` qualModules) impQual
80 }
81 }
81 positioned $ resolveImport mn modExports ie'' impQual typ
82 positioned $ resolveImport mn modExports ie'' impQual typ
82 where
83 where
tests/support/bower.json+1−1
@@ -7,6 +7,6 @@
7 "purescript-functions": "1.0.0-rc.1",
7 "purescript-functions": "1.0.0-rc.1",
8 "purescript-prelude": "1.0.0-rc.3",
8 "purescript-prelude": "1.0.0-rc.3",
9 "purescript-st": "1.0.0-rc.1",
9 "purescript-st": "1.0.0-rc.1",
10− "purescript-partial": "1.1.1"
10+ "purescript-partial": "1.1.2"
11 }
11 }
12}
12}