one-liner-instances-0.1.2.1: Generics-based implementations for common typeclasses

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 FieldsgetGNum :: a

Instances

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