@@ -14,7 +14,7 @@ module Prelude where
14 (<<<) :: forall b c d. a c d -> a b c -> a b d
14 (<<<) :: forall b c d. a c d -> a b c -> a b d
15 (>>>) :: forall b c d. a b c -> a c d -> a b d
15 (>>>) :: forall b c d. a b c -> a c d -> a b d
17− instance Category (->) where
17+ instance categoryArr :: Category (->) where
19 (<<<) f g x = f (g x)
19 (<<<) f g x = f (g x)
20 (>>>) f g x = g (f x)
20 (>>>) f g x = g (f x)
@@ -31,36 +31,36 @@ module Prelude where
31 class Show a where
31 class Show a where
32 show :: a -> String
32 show :: a -> String
34− instance Show String where
34+ instance showString :: Show String where
35 show s = s
35 show s = s
37− instance Show Boolean where
37+ instance showBoolean :: Show Boolean where
38 show true = "true"
38 show true = "true"
39 show false = "false"
39 show false = "false"
41− foreign import showNumber "function showNumber(n) {\
41+ foreign import showNumberImpl "function showNumberImpl(n) {\
42− \ return n.toString();\
42+ \ return n.toString();\
43− \}" :: Number -> String
43+ \}" :: Number -> String
45− instance Show Number where
45+ instance showNumber :: Show Number where
46− show = showNumber
46+ show = showNumberImpl
48 class Read a where
48 class Read a where
49 read :: String -> a
49 read :: String -> a
51− instance Read String where
51+ instance readString :: Read String where
52 read s = s
52 read s = s
54− instance Read Boolean where
54+ instance readBoolean :: Read Boolean where
55 read "true" = true
55 read "true" = true
56 read _ = false
56 read _ = false
58− foreign import readNumber "function readNumber(n) {\
58+ foreign import readNumberImpl "function readNumber(n) {\
59− \ return parseFloat(n);\
59+ \ return parseFloat(n);\
60− \}" :: String -> Number
60+ \}" :: String -> Number
62− instance Read Number where
62+ instance readNumber :: Read Number where
63− read = readNumber
63+ read = readNumberImpl
65 infixl 4 <$>
65 infixl 4 <$>
@@ -73,7 +73,7 @@ module Prelude where
73 pure :: forall a. a -> f a
73 pure :: forall a. a -> f a
74 (<*>) :: forall a b. f (a -> b) -> f a -> f b
74 (<*>) :: forall a b. f (a -> b) -> f a -> f b
76− instance (Applicative f) => Functor f where
76+ instance functorFromApplicative :: (Applicative f) => Functor f where
77 (<$>) f a = pure f <*> a
77 (<$>) f a = pure f <*> a
79 infixl 3 <|>
79 infixl 3 <|>
@@ -88,7 +88,7 @@ module Prelude where
88 return :: forall a. a -> m a
88 return :: forall a. a -> m a
89 (>>=) :: forall a b. m a -> (a -> m b) -> m b
89 (>>=) :: forall a b. m a -> (a -> m b) -> m b
91− instance (Monad m) => Applicative m where
91+ instance applicativeFromMonad :: (Monad m) => Applicative m where
92 pure = return
92 pure = return
93 (<*>) f a = do
93 (<*>) f a = do
@@ -144,7 +144,7 @@ module Prelude where
144 \ return -n;\
144 \ return -n;\
145 \}" :: Number -> Number
145 \}" :: Number -> Number
147− instance Num Number where
147+ instance numNumber :: Num Number where
148 (+) = numAdd
148 (+) = numAdd
149 (-) = numSub
149 (-) = numSub
150 (*) = numMul
150 (*) = numMul
@@ -159,18 +159,6 @@ module Prelude where
159 (==) :: a -> a -> Boolean
159 (==) :: a -> a -> Boolean
160 (/=) :: a -> a -> Boolean
160 (/=) :: a -> a -> Boolean
162− -- Referential equality
165− liftRef :: forall a b. (a -> a -> b) -> Ref a -> Ref a -> b
166− liftRef f (Ref x) (Ref y) = f x y
168− refEq :: forall a. Ref a -> Ref a -> Boolean
169− refEq = liftRef unsafeRefEq
171− refIneq :: forall a. Ref a -> Ref a -> Boolean
172− refIneq = liftRef unsafeRefIneq
174 foreign import unsafeRefEq "function unsafeRefEq(r1) {\
162 foreign import unsafeRefEq "function unsafeRefEq(r1) {\
175 \ return function(r2) {\
163 \ return function(r2) {\
176 \ return r1 === r2;\
164 \ return r1 === r2;\
@@ -183,23 +171,19 @@ module Prelude where
184 \}" :: forall a. a -> a -> Boolean
172 \}" :: forall a. a -> a -> Boolean
186− instance Eq (Ref a) where
190− instance Eq String where
174+ instance eqString :: Eq String where
191 (==) = unsafeRefEq
175 (==) = unsafeRefEq
192 (/=) = unsafeRefIneq
176 (/=) = unsafeRefIneq
194− instance Eq Number where
178+ instance eqNumber :: Eq Number where
195 (==) = unsafeRefEq
179 (==) = unsafeRefEq
196 (/=) = unsafeRefIneq
180 (/=) = unsafeRefIneq
198− instance Eq Boolean where
182+ instance eqBoolean :: Eq Boolean where
199 (==) = unsafeRefEq
183 (==) = unsafeRefEq
200 (/=) = unsafeRefIneq
184 (/=) = unsafeRefIneq
202− instance (Eq a) => Eq [a] where
186+ instance eqArray :: (Eq a) => Eq [a] where
203 (==) [] [] = true
187 (==) [] [] = true
204 (==) (x:xs) (y:ys) = x == y && xs == ys
188 (==) (x:xs) (y:ys) = x == y && xs == ys
205 (==) _ _ = false
189 (==) _ _ = false
@@ -240,7 +224,7 @@ module Prelude where
241 \}" :: Number -> Number -> Boolean
225 \}" :: Number -> Number -> Boolean
243− instance Ord Number where
227+ instance ordNumber :: Ord Number where
244 (<) = numLess
228 (<) = numLess
245 (>) = numGreater
229 (>) = numGreater
246 (<=) = numLessEq
230 (<=) = numLessEq
@@ -299,7 +283,7 @@ module Prelude where
299 \ return ~n;\
283 \ return ~n;\
300 \}" :: Number -> Number
284 \}" :: Number -> Number
302− instance Bits Number where
286+ instance bitsNumber :: Bits Number where
303 (&) = numAnd
287 (&) = numAnd
304 (|) = numOr
288 (|) = numOr
305 (^) = numXor
289 (^) = numXor
@@ -340,7 +324,7 @@ module Prelude where
340 \ return !b;\
324 \ return !b;\
341 \}" :: Boolean -> Boolean
325 \}" :: Boolean -> Boolean
343− instance BoolLike Boolean where
327+ instance boolLikeBoolean :: BoolLike Boolean where
344 (&&) = boolAnd
328 (&&) = boolAnd
345 (||) = boolOr
329 (||) = boolOr
346 not = boolNot
330 not = boolNot
@@ -364,11 +348,11 @@ module Data.Monoid where
364 mempty :: m
348 mempty :: m
365 (<>) :: m -> m -> m
349 (<>) :: m -> m -> m
367− instance Monoid String where
351+ instance monoidString :: Monoid String where
368 mempty = ""
352 mempty = ""
369 (<>) = (++)
353 (<>) = (++)
371− instance Monoid [a] where
355+ instance monoidArray :: Monoid [a] where
372 mempty = []
356 mempty = []
373 (<>) = Data.Array.concat
357 (<>) = Data.Array.concat
@@ -441,20 +425,20 @@ module Data.Maybe where
441 fromMaybe :: forall a. a -> Maybe a -> a
425 fromMaybe :: forall a. a -> Maybe a -> a
442 fromMaybe a = maybe a (id :: forall a. a -> a)
426 fromMaybe a = maybe a (id :: forall a. a -> a)
444− instance Monad Maybe where
428+ instance monadMaybe :: Monad Maybe where
445 return = Just
429 return = Just
446 (>>=) m f = maybe Nothing f m
430 (>>=) m f = maybe Nothing f m
448− instance Applicative Maybe where
432+ instance applicativeMaybe :: Applicative Maybe where
449 pure = Just
433 pure = Just
450 (<*>) (Just fn) x = fn <$> x
434 (<*>) (Just fn) x = fn <$> x
451 (<*>) Nothing _ = Nothing
435 (<*>) Nothing _ = Nothing
453− instance Functor Maybe where
437+ instance functorMaybe :: Functor Maybe where
454 (<$>) fn (Just x) = Just (fn x)
438 (<$>) fn (Just x) = Just (fn x)
455 (<$>) _ _ = Nothing
439 (<$>) _ _ = Nothing
457− instance (Show a) => Show (Maybe a) where
441+ instance showMaybe :: (Show a) => Show (Maybe a) where
458 show (Just x) = "Just " ++ (show x)
442 show (Just x) = "Just " ++ (show x)
459 show Nothing = "Nothing"
443 show Nothing = "Nothing"
@@ -468,20 +452,20 @@ module Data.Either where
468 either f _ (Left a) = f a
452 either f _ (Left a) = f a
469 either _ g (Right b) = g b
453 either _ g (Right b) = g b
471− instance Monad (Either e) where
455+ instance monadEither :: Monad (Either e) where
472 return = Right
456 return = Right
473 (>>=) = either (\e _ -> Left e) (\a f -> f a)
457 (>>=) = either (\e _ -> Left e) (\a f -> f a)
475− instance Applicative (Either e) where
459+ instance applicativeEither :: Applicative (Either e) where
476 pure = Right
460 pure = Right
477 (<*>) (Left e) _ = Left e
461 (<*>) (Left e) _ = Left e
478 (<*>) (Right f) r = f <$> r
462 (<*>) (Right f) r = f <$> r
480− instance Functor (Either a) where
464+ instance functorEither :: Functor (Either a) where
481 (<$>) _ (Left x) = Left x
465 (<$>) _ (Left x) = Left x
482 (<$>) f (Right y) = Right (f y)
466 (<$>) f (Right y) = Right (f y)
484− instance (Show a, Show b) => Show (Either a b) where
468+ instance showEither :: (Show a, Show b) => Show (Either a b) where
485 show (Left x) = "Left " ++ (show x)
469 show (Left x) = "Left " ++ (show x)
486 show (Right y) = "Right " ++ (show y)
470 show (Right y) = "Right " ++ (show y)
@@ -576,7 +560,7 @@ module Data.Array where
576 \ return l1;\
560 \ return l1;\
577 \}" :: forall a. [a] -> [a]
561 \}" :: forall a. [a] -> [a]
579− foreign import insertAt
563+ foreign import insertAt
580 "function insertAt(index) {\
564 "function insertAt(index) {\
581 \ return function(a) {\
565 \ return function(a) {\
582 \ return function(l) {\
566 \ return function(l) {\
@@ -587,7 +571,7 @@ module Data.Array where
588 \}":: forall a. Number -> a -> [a] -> [a]
572 \}":: forall a. Number -> a -> [a] -> [a]
590− foreign import deleteAt
574+ foreign import deleteAt
591 "function deleteAt(index) {\
575 "function deleteAt(index) {\
592 \ return function(n) {\
576 \ return function(n) {\
593 \ return function(l) {\
577 \ return function(l) {\
@@ -598,7 +582,7 @@ module Data.Array where
599 \}":: forall a. Number -> Number -> [a] -> [a]
583 \}":: forall a. Number -> Number -> [a] -> [a]
601− foreign import updateAt
585+ foreign import updateAt
602 "function updateAt(index) {\
586 "function updateAt(index) {\
603 \ return function(a) {\
587 \ return function(a) {\
604 \ return function(l) {\
588 \ return function(l) {\
@@ -625,7 +609,7 @@ module Data.Array where
625 filter _ [] = []
609 filter _ [] = []
626 filter p (x:xs) | p x = x : filter p xs
610 filter p (x:xs) | p x = x : filter p xs
627 filter p (_:xs) = filter p xs
611 filter p (_:xs) = filter p xs
629 find :: forall a. (a -> Boolean) -> [a] -> Maybe a
613 find :: forall a. (a -> Boolean) -> [a] -> Maybe a
630 find _ [] = Nothing
614 find _ [] = Nothing
631 find p (x:xs) | p x = Just x
615 find p (x:xs) | p x = Just x
@@ -661,20 +645,40 @@ module Data.Array where
661 take _ [] = []
645 take _ [] = []
662 take n (x:xs) = x : take (n - 1) xs
646 take n (x:xs) = x : take (n - 1) xs
664− instance (Show a) => Show [a] where
648+ instance showArray :: (Show a) => Show [a] where
665 show xs = "[" ++ joinWith (map show xs) "," ++ "]"
649 show xs = "[" ++ joinWith (map show xs) "," ++ "]"
667− instance Functor [] where
670− instance Monad [] where
651+ instance monadArray :: Monad [] where
671 return = singleton
652 return = singleton
672 (>>=) = concatMap
653 (>>=) = concatMap
655+ instance functorArray :: Functor [] where
674− instance Alternative [] where
658+ instance alternativeArray :: Alternative [] where
675 empty = []
659 empty = []
676 (<|>) = concat
660 (<|>) = concat
666+ -- Referential equality
669+ liftRef :: forall a b. (a -> a -> b) -> Ref a -> Ref a -> b
670+ liftRef f (Ref x) (Ref y) = f x y
672+ refEq :: forall a. Ref a -> Ref a -> Boolean
673+ refEq = liftRef unsafeRefEq
675+ refIneq :: forall a. Ref a -> Ref a -> Boolean
676+ refIneq = liftRef unsafeRefIneq
678+ instance eqRef :: Eq (Ref a) where
678module Data.Array.Unsafe where
682module Data.Array.Unsafe where
680 head :: forall a. [a] -> a
684 head :: forall a. [a] -> a
@@ -690,7 +694,7 @@ module Data.Tuple where
691 data Tuple a b = Tuple a b
695 data Tuple a b = Tuple a b
693− instance (Show a, Show b) => Show (Tuple a b) where
697+ instance showTuple :: (Show a, Show b) => Show (Tuple a b) where
694 show (Tuple a b) = "Tuple(" ++ show a ++ ", " ++ show b ++ ")"
698 show (Tuple a b) = "Tuple(" ++ show a ++ ", " ++ show b ++ ")"
696 curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
700 curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
@@ -968,7 +972,7 @@ module Control.Monad.Eff where
968 \ return f();\
972 \ return f();\
969 \}" :: forall a. Pure a -> a
973 \}" :: forall a. Pure a -> a
971− instance Monad (Eff e) where
975+ instance monadEff :: Monad (Eff e) where
972 return = retEff
976 return = retEff
973 (>>=) = bindEff
977 (>>=) = bindEff