@@ -6,29 +6,33 @@ module Prelude where
6 foreign import data Array :: * -> *
6 foreign import data Array :: * -> *
7 foreign import data Function :: * -> * -> *
7 foreign import data Function :: * -> * -> *
9− id :: forall a. a -> a
12 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
9 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
13− flip = \f -> \b -> \a -> f a b
10+ flip f b a = f a b
15 konst :: forall a b. a -> b -> a
12 konst :: forall a b. a -> b -> a
16− konst = \a -> \b -> a
13+ konst a _ = a
18− (|>) :: forall a b c. (a -> b) -> (b -> c) -> a -> c
15+ infixr 5 >>>
19− (|>) = \f -> \g -> \a -> g (f a)
16+ infixr 5 <<<
21− infixr 5 |>
18+ class Category a where
19+ id :: forall t. a t t
20+ (<<<) :: forall b c d. a c d -> a b c -> a b d
21+ (>>>) :: forall b c d. a b c -> a c d -> a b d
23− (<|) :: forall a b c. (b -> c) -> (a -> b) -> a -> c
23+ instance Category (->) where
24− (<|) = flip (|>)
24+ id x = x
25+ (<<<) f g x = f (g x)
26+ (>>>) f g x = g (f x)
26− infixr 5 <|
28+ infixr 1000 $
28 ($) :: forall a b. (a -> b) -> a -> b
31 ($) :: forall a b. (a -> b) -> a -> b
29 ($) f x = f x
32 ($) f x = f x
31− infixr 1000 $
34+ (#) :: forall a b. a -> (a -> b) -> b
33 class Show a where
37 class Show a where
34 show :: a -> String
38 show :: a -> String
@@ -169,8 +173,10 @@ module Prelude where
169 (/=) = unsafeRefIneq
173 (/=) = unsafeRefIneq
171 instance (Eq a) => Eq [a] where
175 instance (Eq a) => Eq [a] where
172− (==) = unsafeRefEq
176+ (==) [] [] = true
173− (/=) = unsafeRefIneq
177+ (==) (x:xs) (y:ys) = x == y && xs == ys
179+ (/=) xs ys = not (xs == ys)
175 infixl 3 <
181 infixl 3 <
176 infixl 3 >
182 infixl 3 >
@@ -213,21 +219,17 @@ module Prelude where
213 (<=) = numLessEq
219 (<=) = numLessEq
214 (>=) = numGreaterEq
220 (>=) = numGreaterEq
220 infixl 10 &
222 infixl 10 &
221 infixl 10 |
223 infixl 10 |
222− infixl 10 ^
224+ infixl 10 ^
224 class Bits b where
226 class Bits b where
225− (<<) :: b -> Number -> b
226− (>>) :: b -> Number -> b
227− (>>>) :: b -> Number -> b
228 (&) :: b -> b -> b
227 (&) :: b -> b -> b
229 (|) :: b -> b -> b
228 (|) :: b -> b -> b
230 (^) :: b -> b -> b
229 (^) :: b -> b -> b
230+ shl :: b -> Number -> b
231+ shr :: b -> Number -> b
232+ zshr :: b -> Number -> b
231 complement :: b -> b
233 complement :: b -> b
233 foreign import numShl "function numShl(n1) {\
235 foreign import numShl "function numShl(n1) {\
@@ -242,7 +244,7 @@ module Prelude where
243 \}" :: Number -> Number -> Number
245 \}" :: Number -> Number -> Number
245− foreign import numZfShr "function numZfShr(n1) {\
247+ foreign import numZshr "function numZshr(n1) {\
246 \ return function(n2) {\
248 \ return function(n2) {\
247 \ return n1 >>> n2;\
249 \ return n1 >>> n2;\
@@ -271,12 +273,12 @@ module Prelude where
271 \}" :: Number -> Number
273 \}" :: Number -> Number
273 instance Bits Number where
275 instance Bits Number where
277 (&) = numAnd
276 (&) = numAnd
278 (|) = numOr
277 (|) = numOr
279 (^) = numXor
278 (^) = numXor
280 complement = numComplement
282 complement = numComplement
282 infixl 4 !!
284 infixl 4 !!
@@ -326,6 +328,8 @@ module Prelude where
327module Maybe where
329module Maybe where
329 data Maybe a = Nothing | Just a
333 data Maybe a = Nothing | Just a
331 maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
335 maybe :: forall a b. b -> (a -> b) -> Maybe a -> b
@@ -333,7 +337,7 @@ module Maybe where
333 maybe _ f (Just a) = f a
337 maybe _ f (Just a) = f a
335 fromMaybe :: forall a. a -> Maybe a -> a
339 fromMaybe :: forall a. a -> Maybe a -> a
336− fromMaybe a = maybe a Prelude.id
340+ fromMaybe a = maybe a (Prelude.id :: forall a. a -> a)
338 instance Prelude.Monad Maybe where
342 instance Prelude.Monad Maybe where
339 ret = Just
343 ret = Just
@@ -503,6 +507,7 @@ module Arrays where
504module Tuple where
508module Tuple where
506 import Arrays
511 import Arrays
508 type Tuple a b = { fst :: a, snd :: b }
513 type Tuple a b = { fst :: a, snd :: b }
@@ -514,7 +519,7 @@ module Tuple where
514 uncurry f t = f t.fst t.snd
519 uncurry f t = f t.fst t.snd
516 tuple :: forall a b. a -> b -> Tuple a b
521 tuple :: forall a b. a -> b -> Tuple a b
517− tuple = curry Prelude.id
522+ tuple = curry (\t -> t)
519 zip :: forall a b. [a] -> [b] -> [Tuple a b]
524 zip :: forall a b. [a] -> [b] -> [Tuple a b]
520 zip = zipWith tuple
525 zip = zipWith tuple