Copyright | (c) Justin Le 2018 |
---|---|
License | BSD-3 |
Maintainer | justin@jle.im |
Stability | unstable |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
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.
- newtype GNum a = GNum {
- getGNum :: a
- genericPlus :: forall a. (Generic a, GLift Num (Rep a)) => a -> a -> a
- genericMinus :: forall a. (Generic a, GLift Num (Rep a)) => a -> a -> a
- genericTimes :: forall a. (Generic a, GLift Num (Rep a)) => a -> a -> a
- genericNegate :: forall a. (Generic a, GLift Num (Rep a)) => a -> a
- genericAbs :: forall a. (Generic a, GLift Num (Rep a)) => a -> a
- genericSignum :: forall a. (Generic a, GLift Num (Rep a)) => a -> a
- genericFromInteger :: forall a. (Generic a, GLift Num (Rep a)) => Integer -> a
- genericDivide :: forall a. (Generic a, GLift Fractional (Rep a)) => a -> a -> a
- genericRecip :: forall a. (Generic a, GLift Fractional (Rep a)) => a -> a
- genericFromRational :: forall a. (Generic a, GLift Fractional (Rep a)) => Rational -> a
- genericPi :: forall a. (Generic a, GLift Floating (Rep a)) => a
- genericExp :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericLog :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericSqrt :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericPower :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a -> a
- genericLogBase :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a -> a
- genericSin :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericCos :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericTan :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericAsin :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericAcos :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericAtan :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericSinh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericCosh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericTanh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericAsinh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericAcosh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
- genericAtanh :: forall a. (Generic a, GLift Floating (Rep a)) => a -> a
Newtype wrapper
If a
is a data type with a single constructor whose fields are all
instances of Num
, then
has a GNum
aNum
instance.
If a
is a data type with a single constructor whose fields are all
instances of Fractional
, then
has a GNum
aFractional
instance.
If a
is a data type with a single constructor whose fields are all
instances of Floating
, then
has a GNum
aFloating
instance.
Functor GNum Source # | |
Foldable GNum Source # | |
Traversable GNum Source # | |
Eq a => Eq (GNum a) Source # | |
(GLift Num (Rep (GNum a)), GLift Fractional (Rep (GNum a)), GLift Floating (Rep (GNum a))) => Floating (GNum a) Source # | |
(GLift Num (Rep (GNum a)), GLift Fractional (Rep (GNum a))) => Fractional (GNum a) Source # | |
Data a => Data (GNum a) Source # | |
GLift Num (Rep (GNum a)) => Num (GNum a) Source # | |
Ord a => Ord (GNum a) Source # | |
Read a => Read (GNum a) Source # | |
Show a => Show (GNum a) Source # | |
Generic (GNum a) Source # | |
type Rep (GNum a) Source # | |
Generics-derived methods
Num
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 #
genericFromRational :: forall a. (Generic a, GLift Fractional (Rep a)) => Rational -> a Source #