module Delude
(
Boolish(..)
, module Prelude
, module Control.Monad
, module Data.Foldable
, liftf1, liftf2
, Enumerable(..)
) where
import Control.Monad
import Data.Foldable
import Prelude hiding ((||), (&&), (^), iff, implies, not, elem)
class Boolish b where
(||), (&&), (^), iff, implies :: b -> b -> b
not :: b -> b
true, false :: b
instance Boolish Bool where
False || False = False
_ || _ = True
True && True = True
_ && _ = False
False ^ True = True
True ^ False = True
_ ^ _ = False
True `iff` True = True
False `iff` False = True
_ `iff` _ = False
True `implies` False = False
_ `implies` _ = True
not True = False
not False = True
true = True
false = False
liftf1 :: (b -> b) -> (a -> b) -> (a -> b)
liftf1 op f = \x -> op (f x)
liftf2 :: (b -> b -> b) -> (a -> b) -> (a -> b) -> (a -> b)
liftf2 op f g = \x -> f x `op` g x
instance (Boolish b) => Boolish (x -> b) where
(||) = liftf2 (||)
(&&) = liftf2 (&&)
(^) = liftf2 (^)
iff = liftf2 iff
implies = liftf2 implies
not = liftf1 not
true = const true
false = const false
instance (Num n) => Num (a -> n) where
(+) = liftf2 (+)
() = liftf2 ()
(*) = liftf2 (*)
negate = liftf1 negate
abs = liftf1 abs
signum = liftf1 signum
fromInteger n = const (fromInteger n)
instance (Fractional f) => Fractional (a -> f) where
(/) = liftf2 (/)
recip = liftf1 recip
fromRational n = const (fromRational n)
instance (Floating f) => Floating (a -> f) where
pi = \x -> pi
exp = liftf1 exp
log = liftf1 log
sqrt = liftf1 sqrt
(**) = liftf2 (**)
logBase = liftf2 logBase
sin = liftf1 sin
cos = liftf1 cos
tan = liftf1 tan
asin = liftf1 asin
acos = liftf1 acos
atan = liftf1 atan
sinh = liftf1 sinh
cosh = liftf1 cosh
tanh = liftf1 tanh
asinh = liftf1 asinh
acosh = liftf1 acosh
atanh = liftf1 atanh
class Arr arr where
(.<) :: arr b c -> arr a b -> arr a c
(>.) :: arr a b -> arr b c -> arr a c
f >. g = g .< f
f .< g = g >. f
instance Arr (->) where (.<) = (.)
class Enumerable e where enumeration :: [e]