@@ -18,57 +18,50 @@ konst = \a -> \b -> a
18data Maybe a = Nothing | Just a
18data Maybe a = Nothing | Just a
20maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
20maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
21−maybe = \b -> \f -> \m -> case m of
22− Nothing -> b
21+maybe b _ Nothing = b
23− Just a -> f a
22+maybe _ f (Just a) = f a
25fromMaybe :: forall a. a -> Maybe a -> a
24fromMaybe :: forall a. a -> Maybe a -> a
26−fromMaybe = \a -> maybe a id
25+fromMaybe a = maybe a id
28bindMaybe :: forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
27bindMaybe :: forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
29−bindMaybe = \m -> \f -> maybe Nothing f m
28+bindMaybe m f = maybe Nothing f m
33data Either a b = Left a | Right b
32data Either a b = Left a | Right b
35either :: forall a b c. (a -> c) -> (b -> c) -> Either a b -> c
34either :: forall a b c. (a -> c) -> (b -> c) -> Either a b -> c
36−either = \f -> \g -> \e -> case e of
37− Left a -> f a
35+either f _ (Left a) = f a
38− Right b -> g b
36+either _ g (Right b) = g b
40bindEither :: forall e a b. Either e a -> (a -> Either e b) -> Either e b
38bindEither :: forall e a b. Either e a -> (a -> Either e b) -> Either e b
41−bindEither = either (\e -> \_ -> Left e) (\a -> \f -> f a)
39+bindEither = either (\e _ -> Left e) (\a f -> f a)
45head :: forall a. [a] -> a
43head :: forall a. [a] -> a
46−head = \xs -> case xs of
47− x : _ -> x
44+head (x : _) = x
49headSafe :: forall a. [a] -> Maybe a
46headSafe :: forall a. [a] -> Maybe a
50−headSafe = \xs -> case xs of
51− x : _ -> Just x
47+headSafe (x : _) = Just x
52− _ -> Nothing
48+headSafe _ = Nothing
54tail :: forall a. [a] -> [a]
50tail :: forall a. [a] -> [a]
55−tail = \xs -> case xs of
56− _ : xs -> xs
51+tail (_ : xs) = xs
58tailSafe :: forall a. [a] -> Maybe [a]
53tailSafe :: forall a. [a] -> Maybe [a]
59−tailSafe = \xs -> case xs of
60− _ : xs -> Just xs
54+tailSafe (_ : xs) = Just xs
61− _ -> Nothing
55+tailSafe _ = Nothing
63foreign import map :: forall a b. (a -> b) -> [a] -> [b]
57foreign import map :: forall a b. (a -> b) -> [a] -> [b]
65foldr :: forall a b. (a -> b -> a) -> a -> [b] -> a
59foldr :: forall a b. (a -> b -> a) -> a -> [b] -> a
66−foldr = \f -> \a -> \bs -> case bs of
67− b : bs -> f (foldr f a bs) b
60+foldr f a (b : bs) = f (foldr f a bs) b
68− [] -> a
61+foldr _ a [] = a
70foldl :: forall a b. (a -> b -> b) -> b -> [a] -> b
63foldl :: forall a b. (a -> b -> b) -> b -> [a] -> b
71−foldl = \f -> \b -> \as -> {
64+foldl f b as = {
72 var result = b;
65 var result = b;
73 foreach (a in as) {
66 foreach (a in as) {
74 result = f a result;
67 result = f a result;
@@ -104,7 +97,7 @@ cons :: forall a. a -> [a] -> [a]
104cons = \a -> concat([a])
97cons = \a -> concat([a])
106concatMap :: forall a b. [a] -> (a -> [b]) -> [b]
99concatMap :: forall a b. [a] -> (a -> [b]) -> [b]
107−concatMap = \as -> \f -> {
100+concatMap as f = {
108 var result = [];
101 var result = [];
109 foreach (a in as) {
102 foreach (a in as) {
110 result = result `concat` f a;
103 result = result `concat` f a;
@@ -115,12 +108,11 @@ concatMap = \as -> \f -> {
115foreign import filter :: forall a. [a] -> (a -> Boolean) -> [a]
108foreign import filter :: forall a. [a] -> (a -> Boolean) -> [a]
117empty :: forall a. [a] -> Boolean
110empty :: forall a. [a] -> Boolean
118−empty = \as -> case as of
119− [] -> true
111+empty [] = true
120− _ -> false
112+empty _ = false
122range :: Number -> Number -> [Number]
114range :: Number -> Number -> [Number]
123−range = \lo -> \hi -> {
115+range lo hi = {
124 var ns = [];
116 var ns = [];
125 for (n <- lo until hi) {
117 for (n <- lo until hi) {
126 ns = push ns n;
118 ns = push ns n;
@@ -129,12 +121,11 @@ range = \lo -> \hi -> {
131zipWith :: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
123zipWith :: forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
132−zipWith = \f -> \as -> \bs -> case { as: as, bs: bs } of
133− { as = a : as1, bs = b : bs1 } -> cons (f a b) (zipWith f as1 bs1)
124+zipWith f (a:as) (b:bs) = cons (f a b) (zipWith f as bs)
134− _ -> []
125+zipWith _ _ _ = []
136any :: forall a. (a -> Boolean) -> [a] -> Boolean
127any :: forall a. (a -> Boolean) -> [a] -> Boolean
137−any = \p -> \as -> {
128+any p as = {
138 for (i <- 0 until length as) {
129 for (i <- 0 until length as) {
139 if (p (as !! i)) {
130 if (p (as !! i)) {
140 return true;
131 return true;
@@ -144,7 +135,7 @@ any = \p -> \as -> {
146all :: forall a. (a -> Boolean) -> [a] -> Boolean
137all :: forall a. (a -> Boolean) -> [a] -> Boolean
147−all = \p -> \as -> {
138+all p as = {
148 for (i <- 0 until length as) {
139 for (i <- 0 until length as) {
149 if (!(p (as !! i))) {
140 if (!(p (as !! i))) {
150 return false;
141 return false;
@@ -158,10 +149,10 @@ all = \p -> \as -> {
158type Tuple a b = { fst :: a, snd :: b }
149type Tuple a b = { fst :: a, snd :: b }
160curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
151curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
161−curry = \f -> \a -> \b -> f { fst: a, snd: b }
152+curry f a b = f { fst: a, snd: b }
163uncurry :: forall a b c. (a -> b -> c) -> Tuple a b -> c
154uncurry :: forall a b c. (a -> b -> c) -> Tuple a b -> c
164−uncurry = \f -> \t -> f t.fst t.snd
155+uncurry f t = f t.fst t.snd
166tuple :: forall a b. a -> b -> Tuple a b
157tuple :: forall a b. a -> b -> Tuple a b
167tuple = curry id
158tuple = curry id
@@ -170,10 +161,9 @@ zip :: forall a b. [a] -> [b] -> [Tuple a b]
170zip = zipWith tuple
161zip = zipWith tuple
172unzip :: forall a b. [Tuple a b] -> Tuple [a] [b]
163unzip :: forall a b. [Tuple a b] -> Tuple [a] [b]
173−unzip = \ts -> case ts of
174− t : ts1 -> case unzip ts1 of
164+unzip (t:ts) = case unzip ts of
175 { fst = as, snd = bs } -> tuple (cons t.fst as) (cons t.snd bs)
165 { fst = as, snd = bs } -> tuple (cons t.fst as) (cons t.snd bs)
176− [] -> tuple [] []
166+unzip [] = tuple [] []
178-- Strings
168-- Strings