@@ -12,7 +12,7 @@ module Prelude where
12 class Category a where
12 class Category a where
13 id :: forall t. a t t
13 id :: forall t. a t t
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
16 (>>>) :: forall a b c d. (Category a) => a b c -> a c d -> a b d
16 (>>>) :: forall a b c d. (Category a) => a b c -> a c d -> a b d
17 (>>>) f g = g <<< f
17 (>>>) f g = g <<< f
@@ -179,7 +179,7 @@ module Prelude where
179 show LT = "LT"
179 show LT = "LT"
180 show GT = "GT"
180 show GT = "GT"
181 show EQ = "EQ"
181 show EQ = "EQ"
183 class Ord a where
183 class Ord a where
184 compare :: a -> a -> Ordering
184 compare :: a -> a -> Ordering
@@ -191,19 +191,19 @@ module Prelude where
191 _ -> false
191 _ -> false
193 infixl 4 >
193 infixl 4 >
195 (>) :: forall a. (Ord a) => a -> a -> Boolean
195 (>) :: forall a. (Ord a) => a -> a -> Boolean
196 (>) a1 a2 = case a1 `compare` a2 of
196 (>) a1 a2 = case a1 `compare` a2 of
197 GT -> true
197 GT -> true
198 _ -> false
198 _ -> false
200 infixl 4 <=
200 infixl 4 <=
202 (<=) :: forall a. (Ord a) => a -> a -> Boolean
202 (<=) :: forall a. (Ord a) => a -> a -> Boolean
203 (<=) a1 a2 = case a1 `compare` a2 of
203 (<=) a1 a2 = case a1 `compare` a2 of
204 GT -> false
204 GT -> false
205 _ -> true
205 _ -> true
207 infixl 4 >=
207 infixl 4 >=
209 (>=) :: forall a. (Ord a) => a -> a -> Boolean
209 (>=) :: forall a. (Ord a) => a -> a -> Boolean
@@ -418,6 +418,12 @@ module Data.Maybe where
418 fromMaybe :: forall a. a -> Maybe a -> a
418 fromMaybe :: forall a. a -> Maybe a -> a
419 fromMaybe a = maybe a (id :: forall a. a -> a)
419 fromMaybe a = maybe a (id :: forall a. a -> a)
421+ isJust :: forall a. Maybe a -> Boolean
422+ isJust = maybe false (const true)
424+ isNothing :: forall a. Maybe a -> Boolean
425+ isNothing = maybe true (const false)
421 instance monadMaybe :: Monad Maybe where
427 instance monadMaybe :: Monad Maybe where
422 return = Just
428 return = Just
423 (>>=) m f = maybe Nothing f m
429 (>>=) m f = maybe Nothing f m
@@ -451,6 +457,12 @@ module Data.Either where
451 either f _ (Left a) = f a
457 either f _ (Left a) = f a
452 either _ g (Right b) = g b
458 either _ g (Right b) = g b
460+ isLeft :: forall a b. Either a b -> Boolean
461+ isLeft = either (const true) (const false)
463+ isRight :: forall a b. Either a b -> Boolean
464+ isRight = either (const false) (const true)
454 instance monadEither :: Monad (Either e) where
466 instance monadEither :: Monad (Either e) where
455 return = Right
467 return = Right
456 (>>=) = either (\e _ -> Left e) (\a f -> f a)
468 (>>=) = either (\e _ -> Left e) (\a f -> f a)