Skip to content

Commit 498dadc

Browse files
committed
Merge pull request purescript#1083 from purescript/arrays
Remove array type notation and cons binders
2 parents 04cd31c + 14b2310 commit 498dadc

38 files changed

+142
-226
lines changed

examples/failing/Foldable.purs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ class Foldable f where
44
fold :: forall a b. (a -> b -> b) -> b -> f a -> b
55
size :: forall a. f a -> Number
66

7-
instance foldableArray :: Foldable [] where
8-
fold _ z [] = z
9-
fold f z (x:xs) = x `f` (fold f z xs)
10-
size = fold (const ((+) 1)) 0
7+
data L a = C a (L a) | N
118

12-
x = size [1,2,3]
9+
instance foldableL :: Foldable L where
10+
fold _ z N = z
11+
fold f z (C x xs) = x `f` (fold f z xs)
12+
size = fold (const ((+) 1.0)) 0.0
13+
14+
x = size (C 1 (C 2 (C 3 N)))
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module OverlappingBinders where
22

3+
data S a = S a (S a)
4+
35
f x = case x of
4-
(y:y@(z:zs)) -> y
6+
(S y (S y@(S z zs))) -> y

examples/failing/TypeSynonyms.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Main where
22

3-
type T1 = [T2]
3+
type T1 = Array T2
44

55
type T2 = T1

examples/passing/ArrayType.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Main where
33
class Pointed p where
44
point :: forall a. a -> p a
55

6-
instance pointedArray :: Pointed [] where
6+
instance pointedArray :: Pointed Array where
77
point a = [a]
88

99
main = Debug.Trace.trace "Done"

examples/passing/Arrays.purs

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/passing/BindersInFunctions.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Main where
22

33
import Prelude
44

5-
tail = \(_:xs) -> xs
5+
snd = \[_, y] -> y
66

77
foreign import error
88
"""
@@ -12,7 +12,7 @@ foreign import error
1212
""" :: forall a. String -> a
1313

1414
main =
15-
let ts = tail [1.0, 2.0, 3.0] in
16-
if ts == [2.0, 3.0]
15+
let ts = snd [1.0, 2.0] in
16+
if ts == 2.0
1717
then Debug.Trace.trace "Done"
18-
else error "Incorrect result from 'tails'."
18+
else error "Incorrect result from 'snd'."

examples/passing/CheckSynonymBug.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ module Main where
22

33
import Prelude
44

5-
type Foo a = [a]
5+
type Foo a = Array a
66

77
foreign import length
88
"""
99
function length(a) {
1010
return a.length;
1111
}
12-
""" :: forall a. [a] -> Number
12+
""" :: forall a. Array a -> Number
1313

1414
foo _ = length ([] :: Foo Number)
1515

examples/passing/DeepArrayBinder.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ module Main where
22

33
import Control.Monad.Eff
44

5-
match2 :: [Number] -> Number
6-
match2 (x : y : xs) = x * y + match2 xs
5+
data List a = Cons a (List a) | Nil
6+
7+
match2 :: List Number -> Number
8+
match2 (Cons x (Cons y xs)) = x * y + match2 xs
79
match2 _ = 0.0
810

911
foreign import explode
@@ -13,6 +15,6 @@ foreign import explode
1315
}
1416
""" :: forall eff a. Eff eff a
1517

16-
main = case match2 [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] of
18+
main = case match2 (Cons 1.0 (Cons 2.0 (Cons 3.0 (Cons 4.0 (Cons 5.0 (Cons 6.0 (Cons 7.0 (Cons 8.0 (Cons 9.0 Nil))))))))) of
1719
100.0 -> Debug.Trace.trace "Done"
1820
_ -> explode

examples/passing/Do.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ test1 = \_ -> do
2525
Just "abc"
2626

2727
test2 = \_ -> do
28-
(x : _) <- Just [1.0, 2.0, 3.0]
29-
(y : _) <- Just [4.0, 5.0, 6.0]
28+
x <- Just 1.0
29+
y <- Just 2.0
3030
Just (x + y)
3131

3232
test3 = \_ -> do

examples/passing/EmptyDataDecls.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Prelude
55
data Z
66
data S n
77

8-
data ArrayBox n a = ArrayBox [a]
8+
data ArrayBox n a = ArrayBox (Array a)
99

1010
nil :: forall a. ArrayBox Z a
1111
nil = ArrayBox []
@@ -17,7 +17,7 @@ foreign import concat
1717
return l1.concat(l2);
1818
};
1919
}
20-
""" :: forall a. [a] -> [a] -> [a]
20+
""" :: forall a. Array a -> Array a -> Array a
2121

2222
cons' :: forall a n. a -> ArrayBox n a -> ArrayBox (S n) a
2323
cons' x (ArrayBox xs) = ArrayBox $ concat [x] xs

0 commit comments

Comments
 (0)