generics-lift-0.1.0.0: GHC Generics for deriving numeric typeclasses, Monoid, and other similar classes.

Copyright(c) Justin Le 2018
LicenseBSD-3
Maintainerjustin@jle.im
Stabilityunstable
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Numeric.Generics

Contents

Description

Derived methods for numeric typeclasses.

Can be used for any types (deriving Generic) made with a single constructor, where every field is an instance of Num (or Fractional or Floating, depending on the function).

Also includes a newtype wrapper that imbues any such data type with an instant Num (and Fractional and Floating) instance.

See README for details on usage instructions and motivations.

Synopsis

Newtype wrapper

newtype GNum a Source #

If a is a data type with a single constructor whose fields are all instances of Num, then GNum a has a Num instance.

If a is a data type with a single constructor whose fields are all instances of Fractional, then GNum a has a Fractional instance.

If a is a data type with a single constructor whose fields are all instances of Floating, then GNum a has a Floating instance.

Constructors

GNum 

Fields

Instances

Functor GNum Source # 

Methods

fmap :: (a -> b) -> GNum a -> GNum b #

(<$) :: a -> GNum b -> GNum a #

Foldable GNum Source # 

Methods

fold :: Monoid m => GNum m -> m #

foldMap :: Monoid m => (a -> m) -> GNum a -> m #

foldr :: (a -> b -> b) -> b -> GNum a -> b #

foldr' :: (a -> b -> b) -> b -> GNum a -> b #

foldl :: (b -> a -> b) -> b -> GNum a -> b #

foldl' :: (b -> a -> b) -> b -> GNum a -> b #

foldr1 :: (a -> a -> a) -> GNum a -> a #

foldl1 :: (a -> a -> a) -> GNum a -> a #

toList :: GNum a -> [a] #

null :: GNum a -> Bool #

length :: GNum a -> Int #

elem :: Eq a => a -> GNum a -> Bool #

maximum :: Ord a => GNum a -> a #

minimum :: Ord a => GNum a -> a #

sum :: Num a => GNum a -> a #

product :: Num a => GNum a -> a #

Traversable GNum Source # 

Methods

traverse :: Applicative f => (a -> f b) -> GNum a -> f (GNum b) #

sequenceA :: Applicative f => GNum (f a) -> f (GNum a) #

mapM :: Monad m => (a -> m b) -> GNum a -> m (GNum b) #

sequence :: Monad m => GNum (m a) -> m (GNum a) #

Eq a => Eq (GNum a) Source # 

Methods

(==) :: GNum a -> GNum a -> Bool #

(/=) :: GNum a -> GNum a -> Bool #

(GLift Num (Rep (GNum a)), GLift Fractional (Rep (GNum a)), GLift Floating (Rep (GNum a))) => Floating (GNum a) Source # 

Methods

pi :: GNum a #

exp :: GNum a -> GNum a #

log :: GNum a -> GNum a #

sqrt :: GNum a -> GNum a #

(**) :: GNum a -> GNum a -> GNum a #

logBase :: GNum a -> GNum a -> GNum a #

sin :: GNum a -> GNum a #

cos :: GNum a -> GNum a #

tan :: GNum a -> GNum a #

asin :: GNum a -> GNum a #

acos :: GNum a -> GNum a #

atan :: GNum a -> GNum a #

sinh :: GNum a -> GNum a #

cosh :: GNum a -> GNum a #

tanh :: GNum a -> GNum a #

asinh :: GNum a -> GNum a #

acosh :: GNum a -> GNum a #

atanh :: GNum a -> GNum a #

log1p :: GNum a -> GNum a #

expm1 :: GNum a -> GNum a #

log1pexp :: GNum a -> GNum a #

log1mexp :: GNum a -> GNum a #

(GLift Num (Rep (GNum a)), GLift Fractional (Rep (GNum a))) => Fractional (GNum a) Source # 

Methods

(/) :: GNum a -> GNum a -> GNum a #

recip :: GNum a -> GNum a #

fromRational :: Rational -> GNum a #

Data a => Data (GNum a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GNum a -> c (GNum a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GNum a) #

toConstr :: GNum a -> Constr #

dataTypeOf :: GNum a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (GNum a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GNum a)) #

gmapT :: (forall b. Data b => b -> b) -> GNum a -> GNum a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GNum a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GNum a -> r #

gmapQ :: (forall d. Data d => d -> u) -> GNum a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> GNum a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> GNum a -> m (GNum a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GNum a -> m (GNum a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GNum a -> m (GNum a) #

GLift Num (Rep (GNum a)) => Num (GNum a) Source # 

Methods

(+) :: GNum a -> GNum a -> GNum a #

(-) :: GNum a -> GNum a -> GNum a #

(*) :: GNum a -> GNum a -> GNum a #

negate :: GNum a -> GNum a #

abs :: GNum a -> GNum a #

signum :: GNum a -> GNum a #

fromInteger :: Integer -> GNum a #

Ord a => Ord (GNum a) Source # 

Methods

compare :: GNum a -> GNum a -> Ordering #

(<) :: GNum a -> GNum a -> Bool #

(<=) :: GNum a -> GNum a -> Bool #

(>) :: GNum a -> GNum a -> Bool #

(>=) :: GNum a -> GNum a -> Bool #

max :: GNum a -> GNum a -> GNum a #

min :: GNum a -> GNum a -> GNum a #

Read a => Read (GNum a) Source # 
Show a => Show (GNum a) Source # 

Methods

showsPrec :: Int -> GNum a -> ShowS #

show :: GNum a -> String #

showList :: [GNum a] -> ShowS #

Generic (GNum a) Source # 

Associated Types

type Rep (GNum a) :: * -> * #

Methods

from :: GNum a -> Rep (GNum a) x #

to :: Rep (GNum a) x -> GNum a #

type Rep (GNum a) Source # 
type Rep (GNum a) = D1 * (MetaData "GNum" "Numeric.Generics" "generics-lift-0.1.0.0-59raSs2kTdGFz343sZ52qP" True) (C1 * (MetaCons "GNum" PrefixI True) (S1 * (MetaSel (Just Symbol "getGNum") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * a)))

Generics-derived methods

Num

genericPlus :: forall a. (Generic a, GLift Num (Rep a)) => a -> a -> a Source #

genericMinus :: forall a. (Generic a, GLift Num (Rep a)) => a -> a -> a Source #

genericTimes :: forall a. (Generic a, GLift Num (Rep a)) => a -> a -> a Source #

genericNegate :: forall a. (Generic a, GLift Num (Rep a)) => a -> a Source #

genericAbs :: forall a. (Generic a, GLift Num (Rep a)) => a -> a Source #

genericSignum :: forall a. (Generic a, GLift Num (Rep a)) => a -> a Source #

genericFromInteger :: forall a. (Generic a, GLift Num (Rep a)) => Integer -> a Source #

Fractional

genericDivide :: forall a. (Generic a, GLift Fractional (Rep a)) => a -> a -> a Source #

genericRecip :: forall a. (Generic a, GLift Fractional (Rep a)) => a -> a Source #

Floating

genericPi :: forall a. (Generic a, GLift Floating (Rep a)) => a Source #

genericExp :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericLog :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericSqrt :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericPower :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a -> a Source #

genericLogBase :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a -> a Source #

genericSin :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericCos :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericTan :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericAsin :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericAcos :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericAtan :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericSinh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericCosh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericTanh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericAsinh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericAcosh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #

genericAtanh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a Source #