module Numlift where

constmap::b->(a->b)
constmap x = always x
  where
  always x n = x

liftbinary::(b->b->b)->(a->b)->(a->b)->a->b
liftbinary oper f g x = oper (f x) (g x)

liftunary::(b->b)->(a->b)->a->b
liftunary oper f x = oper (f x)

instance (Num b) => Eq (a->b) where
    _ == _ = False

instance (Num b) => Ord (a->b) where
    _ < _ = False

instance (Num b) => Show (a->b) where
    show f = "Cannot display functions"


instance (Num b) => Num (a->b) where
    (+) = liftbinary (+)
    (-) = liftbinary (-)
    (*) = liftbinary (*)
    abs = liftunary abs
    signum = liftunary signum
    negate = liftunary negate
    fromInteger n = constmap (fromInteger n)


