-- 021202 -- H98-compliant version -- Provides specialized instance declarations for Num, Fractional, and -- Floating for Maybe types. (H98 compliance forces a replication of these -- declarations for each liftable type.) module LiftMaybeNum(module Liftable, module LiftMaybe) where import Liftable import LiftMaybe -- Make Maybe a instance of suitable numeric types instance (Num a, Eq a, Show a) => Num (Maybe a) where (+) = lift2 (+) (*) = lift2 (*) negate = lift1 negate abs = lift1 abs signum = lift1 signum fromInteger = lift0 . fromInteger instance (Fractional a, Num a, Eq a, Show a) => Fractional (Maybe a) where (/) = lift2 (/) recip = lift1 recip fromRational = lift0 . fromRational instance (Floating a, Num a, Eq a, Show a) => Floating (Maybe a) where pi = lift0 pi exp = lift1 exp log = lift1 log sqrt = lift1 sqrt (**) = lift2 (**) logBase = lift2 logBase sin = lift1 sin cos = lift1 cos tan = lift1 tan asin = lift1 asin acos = lift1 acos atan = lift1 atan sinh = lift1 sinh cosh = lift1 cosh tanh = lift1 tanh asinh = lift1 asinh acosh = lift1 acosh atanh = lift1 atanh