one-liner-instances-0.1.3.0: Generics-based implementations for common typeclasses
Copyright(c) Justin Le 2021
LicenseBSD-3
Maintainerjustin@jle.im
Stabilityunstable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Numeric.OneLiner

Description

Derived methods for numeric typeclasses, using Generics.OneLiner and GHC.Generics.

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, which can one day be used with DerivingVia syntax to derive instances automatically.

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.

Will one day be able to be used with DerivingVia syntax, to derive instances automatically.

Constructors

GNum 

Fields

Instances

Instances details
Functor GNum Source # 
Instance details

Defined in Numeric.OneLiner

Methods

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

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

Foldable GNum Source # 
Instance details

Defined in Numeric.OneLiner

Methods

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

foldMap :: Monoid m => (a -> m) -> GNum a -> 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 # 
Instance details

Defined in Numeric.OneLiner

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 # 
Instance details

Defined in Numeric.OneLiner

Methods

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

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

(ADTRecord a, Constraints a Num, Constraints a Fractional, Constraints a Floating) => Floating (GNum a) Source # 
Instance details

Defined in Numeric.OneLiner

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 #

(ADTRecord a, Constraints a Num, Constraints a Fractional) => Fractional (GNum a) Source # 
Instance details

Defined in Numeric.OneLiner

Methods

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

recip :: GNum a -> GNum a #

fromRational :: Rational -> GNum a #

Data a => Data (GNum a) Source # 
Instance details

Defined in Numeric.OneLiner

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 :: forall r r'. (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) #

(ADTRecord a, Constraints a Num) => Num (GNum a) Source # 
Instance details

Defined in Numeric.OneLiner

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 # 
Instance details

Defined in Numeric.OneLiner

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 # 
Instance details

Defined in Numeric.OneLiner

Show a => Show (GNum a) Source # 
Instance details

Defined in Numeric.OneLiner

Methods

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

show :: GNum a -> String #

showList :: [GNum a] -> ShowS #

Generic (GNum a) Source # 
Instance details

Defined in Numeric.OneLiner

Associated Types

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

Methods

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

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

type Rep (GNum a) Source # 
Instance details

Defined in Numeric.OneLiner

type Rep (GNum a) = D1 ('MetaData "GNum" "Numeric.OneLiner" "one-liner-instances-0.1.3.0-KGYaKgOm9Pn8Wcz4AhCIIX" 'True) (C1 ('MetaCons "GNum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getGNum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Generics-derived methods

All of these implement the appropriate functions by carrying them over every field of the data type

gPlus :: forall a. (ADTRecord a, Constraints a Num) => a -> a -> a Source #

gMinus :: forall a. (ADTRecord a, Constraints a Num) => a -> a -> a Source #

gTimes :: forall a. (ADTRecord a, Constraints a Num) => a -> a -> a Source #

gNegate :: forall a. (ADTRecord a, Constraints a Num) => a -> a Source #

gAbs :: forall a. (ADTRecord a, Constraints a Num) => a -> a Source #

gSignum :: forall a. (ADTRecord a, Constraints a Num) => a -> a Source #

gFromInteger :: forall a. (ADTRecord a, Constraints a Num) => Integer -> a Source #

Fractional

gDivide :: forall a. (ADTRecord a, Constraints a Fractional) => a -> a -> a Source #

gRecip :: forall a. (ADTRecord a, Constraints a Fractional) => a -> a Source #

Floating

gPi :: forall a. (ADTRecord a, Constraints a Floating) => a Source #

gExp :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gLog :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gSqrt :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gPower :: forall a. (ADTRecord a, Constraints a Floating) => a -> a -> a Source #

gLogBase :: forall a. (ADTRecord a, Constraints a Floating) => a -> a -> a Source #

gSin :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gCos :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gTan :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gAsin :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gAcos :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gAtan :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gSinh :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gCosh :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gTanh :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gAsinh :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gAcosh :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #

gAtanh :: forall a. (ADTRecord a, Constraints a Floating) => a -> a Source #