Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Working on Eq...

  • Loading branch information...
commit f8df28b8cd4ffe26372c7feb04ab22bb472fabe3 1 parent 41c088e
@tomlokhorst authored
Showing with 67 additions and 61 deletions.
  1. +26 −23 src/AwesomePrelude.hs
  2. +18 −15 src/HaskellPrelude.hs
  3. +23 −23 src/Main.hs
View
49 src/AwesomePrelude.hs
@@ -3,6 +3,9 @@
module AwesomePrelude where
+undefined :: a
+undefined = undefined
+
class Bool f r | f -> r where
bool :: r -> r -> f -> r
false :: f
@@ -17,11 +20,8 @@ if' p t f = bool f t p
(||) :: (Bool b b) => b -> b -> b
(||) x y = if' x x y
-not :: (Bool b b) => b -> b
-not b = if' b false true
-
-otherwise :: (Bool b b) => b
-otherwise = true
+-- otherwise :: (Bool b b) => b
+-- otherwise = true
class Maybe f a r | f -> a, f -> r where
maybe :: r -> (a -> r) -> f a -> r
@@ -49,33 +49,36 @@ curry f x y = f (ctuple2 x y)
uncurry :: (Tuple2 f a b r) => (a -> b -> r) -> f a b -> r
uncurry f t = tuple2 f t
+not :: (Bool b b', Bool b' r) => b -> b'
+not b = if' b false true
+
class Eq a where
- (==), (/=) :: Bool b b => a -> a -> b
+ (==), (/=) :: Bool b r => a -> a -> b
x /= y = not (x == y)
x == y = not (x /= y)
-class (Eq f) => Ordering f r | f -> r where
- ordering :: r -> r -> r -> f -> r
- lt :: f
- eq :: f
- gt :: f
-
-isLt :: (Ordering o b, Bool b r) => o -> b
-isLt = ordering true false false
-
-isEq :: (Ordering o b, Bool b r) => o -> b
-isEq = ordering false true false
+-- class (Eq f) => Ordering f r | f -> r where
+-- ordering :: r -> r -> r -> f -> r
+-- lt :: f
+-- eq :: f
+-- gt :: f
-isGt :: (Ordering o b, Bool b r) => o -> b
-isGt = ordering false false true
+-- isLt :: (Ordering o b, Bool b r) => o -> b
+-- isLt = ordering true false false
+--
+-- isEq :: (Ordering o b, Bool b r) => o -> b
+-- isEq = ordering false true false
+-- isGt :: (Ordering o b, Bool b r) => o -> b
+-- isGt = ordering false false true
-class (Eq a) => Ord a where
- compare :: (Bool o o, Ordering o r) => a -> a -> o
- (<), (<=), (>), (>=) :: Ordering o r => a -> a -> o
- max, min :: a -> a -> a
+-- class (Eq a) => Ord a where
+-- compare :: (Bool o o, Ordering o r) => a -> a -> o
+-- (<), (<=), (>), (>=) :: Ordering o r => a -> a -> o
+--
+-- max, min :: a -> a -> a
-- compare x y = bool eq lt (x == x) --if_ (x == y)
-- eq lt
View
33 src/HaskellPrelude.hs
@@ -25,19 +25,22 @@ instance Tuple2 (,) a b r where
tuple2 f (x, y) = f x y
ctuple2 x y = (x, y)
-instance Eq P.Ordering where
- x == y = if x P.== y then true else false
-
-instance Ordering P.Ordering r where
- ordering x _ _ P.LT = x
- ordering _ y _ P.EQ = y
- ordering _ _ z P.GT = z
- lt = P.LT
- eq = P.EQ
- gt = P.GT
-
-instance List [] a r where
- list = \x f ys -> P.foldr f x ys
- nil = []
- cons = (:)
+instance Eq () where
+ () == () = true
+
+-- instance Eq P.Ordering where
+-- x == y = if x P.== y then true else false
+--
+-- instance Ordering P.Ordering r where
+-- ordering x _ _ P.LT = x
+-- ordering _ y _ P.EQ = y
+-- ordering _ _ z P.GT = z
+-- lt = P.LT
+-- eq = P.EQ
+-- gt = P.GT
+--
+-- instance List [] a r where
+-- list = \x f ys -> P.foldr f x ys
+-- nil = []
+-- cons = (:)
View
46 src/Main.hs
@@ -31,27 +31,27 @@ test = not false && false || true
-listy :: [Int]
-listy = 3 `cons` (4 `cons` nil)
-
-bool' :: a -> a -> P.Bool -> a
-bool' x y b = if b then x else y
-
-f :: (forall a. a -> a -> b -> a) -> a -> b -> a
-f g a b = g a a b
-
-ok = f bool'
--- epicfail = f bool
-
-hi = maybe false not
- (just true :: P.Maybe P.Bool)
- -- (just true :: JsC1 JsMaybe (Js JsBool))
-
-yo = either (P.* 5) (P.const 2)
- (right false :: P.Either P.Int P.Bool)
- -- (right false :: JsC2 JsEither (Js JsNumber) (Js JsBool))
-
-ah = tuple2 (\x y -> x && P.const false y)
- (ctuple2 true 3 :: (,) P.Bool P.Int)
- -- (ctuple2 true 3 :: JsC2 JsTuple2 (Js JsBool) (Js JsNumber))
+-- listy :: [Int]
+-- listy = 3 `cons` (4 `cons` nil)
+
+-- bool' :: a -> a -> P.Bool -> a
+-- bool' x y b = if b then x else y
+--
+-- f :: (forall a. a -> a -> b -> a) -> a -> b -> a
+-- f g a b = g a a b
+--
+-- ok = f bool'
+-- -- epicfail = f bool
+--
+-- hi = maybe false not
+-- (just true :: P.Maybe P.Bool)
+-- -- (just true :: JsC1 JsMaybe (Js JsBool))
+--
+-- yo = either (P.* 5) (P.const 2)
+-- (right false :: P.Either P.Int P.Bool)
+-- -- (right false :: JsC2 JsEither (Js JsNumber) (Js JsBool))
+--
+-- ah = tuple2 (\x y -> x && P.const false y)
+-- (ctuple2 true 3 :: (,) P.Bool P.Int)
+-- -- (ctuple2 true 3 :: JsC2 JsTuple2 (Js JsBool) (Js JsNumber))
Please sign in to comment.
Something went wrong with that request. Please try again.