Skip to content

Commit d1d5cc2

Browse files
committed
Fix some examples
1 parent ea3e968 commit d1d5cc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+618
-541
lines changed

examples/failing/Arrays.purs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
test = \arr -> arr !! (0 !! 0)
1+
module Arrays where
2+
3+
test = \arr -> arr !! (0 !! 0)

examples/failing/Import.purs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
import UndefinedModule
1+
module Module where
2+
3+
import UndefinedModule

examples/failing/KindError.purs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
data KindError f a = One f | Two f a
1+
module KindError where
2+
3+
data KindError f a = One f | Two f a

examples/failing/LocalVars.purs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
bad = \x -> do
2-
x = x + 1
3-
return x
1+
module LocalVars where
2+
3+
bad = \x -> {
4+
x = x + 1;
5+
return x;
6+
}

examples/failing/PatternScope.purs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
-- Pattern scope doesn't leak
2-
foobar = \x -> do
3-
var y = case x of
4-
z | z % 2 == 0 -> 1
5-
_ -> 2
6-
return z
1+
module PatternScope where
2+
3+
-- Pattern scope doesn't leak
4+
foobar = \x -> {
5+
var y = case x of
6+
z | z % 2 == 0 -> 1
7+
_ -> 2;
8+
return z;
9+
}
710

examples/failing/Rank2Types.purs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
foreign import test :: (forall a. a -> a) -> Number
1+
module Rank2Types where
22

3-
test1 = test (\n -> n + 1)
3+
foreign import test :: (forall a. a -> a) -> Number
4+
5+
test1 = test (\n -> n + 1)

examples/failing/ReadShow.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
foreign import read :: forall a. String -> a
1+
module ReadShow where
22

3-
foreign import show :: forall a. a -> String
3+
foreign import read :: forall a. String -> a
44

5-
test = \x -> show (read x)
5+
foreign import show :: forall a. a -> String
6+
7+
test = \x -> show (read x)

examples/failing/SkolemEscape.purs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
foreign import foo :: (forall a. a -> a) -> Number
1+
module SkolemEscape where
22

3-
test = \x -> foo x
3+
foreign import foo :: (forall a. a -> a) -> Number
4+
5+
test = \x -> foo x

examples/failing/TypeError.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
test = do
2-
var x = 0
3-
return x ++ "A"
1+
module TypeError where
2+
3+
test = x ++ "A"

examples/passing/Arrays.purs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
test1 = \arr -> arr !! 0 + arr !! 1
1+
module Arrays where
22

3-
test2 = \arr -> case arr of
4-
[x, y] -> x + y
5-
[x] -> x
6-
[] -> 0
7-
(x : y : _) -> x + y
3+
test1 = \arr -> arr !! 0 + arr !! 1
84

9-
data Tree = One Number | Some [Tree]
5+
test2 = \arr -> case arr of
6+
[x, y] -> x + y
7+
[x] -> x
8+
[] -> 0
9+
(x : y : _) -> x + y
1010

11-
test3 = \(tree, sum) -> case tree of
12-
One n -> n
13-
Some (n1 : n2 : rest) -> test3(n1, sum) * 10 + test3(n2, sum) * 5 + sum(rest)
11+
data Tree = One Number | Some [Tree]
1412

15-
test4 = \arr -> case arr of
16-
[] -> 0
17-
[_] -> 0
18-
x : y : xs -> x * y + test4 xs
19-
13+
test3 = \(tree, sum) -> case tree of
14+
One n -> n
15+
Some (n1 : n2 : rest) -> test3(n1, sum) * 10 + test3(n2, sum) * 5 + sum(rest)
16+
17+
test4 = \arr -> case arr of
18+
[] -> 0
19+
[_] -> 0
20+
x : y : xs -> x * y + test4 xs
21+
2022

0 commit comments

Comments
 (0)