@@ -15,7 +15,7 @@ module Prelude where
15 (<|) :: forall a b c. (b -> c) -> (a -> b) -> a -> c
15 (<|) :: forall a b c. (b -> c) -> (a -> b) -> a -> c
16 (<|) = flip (|>)
16 (<|) = flip (|>)
18− -- Maybe
18+module Maybe where
20 data Maybe a = Nothing | Just a
20 data Maybe a = Nothing | Just a
@@ -24,12 +24,12 @@ module Prelude where
24 maybe _ f (Just a) = f a
24 maybe _ f (Just a) = f a
26 fromMaybe :: forall a. a -> Maybe a -> a
26 fromMaybe :: forall a. a -> Maybe a -> a
27− fromMaybe a = maybe a id
27+ fromMaybe a = maybe a Prelude.id
29 bindMaybe :: forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
29 bindMaybe :: forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
30 bindMaybe m f = maybe Nothing f m
30 bindMaybe m f = maybe Nothing f m
32− -- Either
32+module Either where
34 data Either a b = Left a | Right b
34 data Either a b = Left a | Right b
@@ -40,7 +40,9 @@ module Prelude where
40 bindEither :: forall e a b. Either e a -> (a -> Either e b) -> Either e b
40 bindEither :: forall e a b. Either e a -> (a -> Either e b) -> Either e b
41 bindEither = either (\e _ -> Left e) (\a f -> f a)
41 bindEither = either (\e _ -> Left e) (\a f -> f a)
43− -- Arrays
43+module Arrays where
45 head :: forall a. [a] -> a
47 head :: forall a. [a] -> a
46 head (x : _) = x
48 head (x : _) = x
@@ -96,7 +98,7 @@ module Prelude where
96 foreign import splice :: forall a. Number -> Number -> [a] -> [a] -> [a]
98 foreign import splice :: forall a. Number -> Number -> [a] -> [a] -> [a]
98 cons :: forall a. a -> [a] -> [a]
100 cons :: forall a. a -> [a] -> [a]
99− cons = \a -> concat([a])
101+ cons a = concat [a]
101 concatMap :: forall a b. [a] -> (a -> [b]) -> [b]
103 concatMap :: forall a b. [a] -> (a -> [b]) -> [b]
102 concatMap as f = {
104 concatMap as f = {
@@ -146,7 +148,9 @@ module Prelude where
146 return true;
148 return true;
149− -- Pairs
151+module Tuple where
151 type Tuple a b = { fst :: a, snd :: b }
155 type Tuple a b = { fst :: a, snd :: b }
@@ -157,7 +161,7 @@ module Prelude where
157 uncurry f t = f t.fst t.snd
161 uncurry f t = f t.fst t.snd
159 tuple :: forall a b. a -> b -> Tuple a b
163 tuple :: forall a b. a -> b -> Tuple a b
160− tuple = curry id
164+ tuple = curry Prelude.id
162 zip :: forall a b. [a] -> [b] -> [Tuple a b]
166 zip :: forall a b. [a] -> [b] -> [Tuple a b]
163 zip = zipWith tuple
167 zip = zipWith tuple
@@ -167,7 +171,7 @@ module Prelude where
167 { fst = as, snd = bs } -> tuple (cons t.fst as) (cons t.snd bs)
171 { fst = as, snd = bs } -> tuple (cons t.fst as) (cons t.snd bs)
168 unzip [] = tuple [] []
172 unzip [] = tuple [] []
170− -- Strings
174+module String where
172 foreign import member "length" lengthS :: String -> Number
176 foreign import member "length" lengthS :: String -> Number
@@ -195,7 +199,7 @@ module Prelude where
196 foreign import trim :: String -> String
200 foreign import trim :: String -> String
198− -- Regex
202+module Regex where
200 foreign import data Regex :: *
204 foreign import data Regex :: *
@@ -209,7 +213,7 @@ module Prelude where
210 foreign import search :: Regex -> String -> Number
214 foreign import search :: Regex -> String -> Number
212− -- Globals
216+module Global where
214 foreign import nan :: Number
218 foreign import nan :: Number
@@ -239,7 +243,7 @@ module Prelude where
240 foreign import decodeURI :: String -> String
244 foreign import decodeURI :: String -> String
242− -- Math
246+module Math where
244 type Math =
248 type Math =
245 { abs :: Number -> Number
249 { abs :: Number -> Number