function-instances-algebra

Instances of the Algebra.* classes for functions

github.com/kreuzschlitzschraubenzieher/function-instances-algebra

Latest on Hackage:0.1

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD-3-Clause licensed by Tobias Brandt
Maintained by [email protected]

This package provides instances for functions (k -> a) of the classes Absolute, Algebraic, Differential, Field, Lattice, Monoid, Ring and Transcendental from the numeric-prelude package. An instance for Additive already comes with the original package.

If a has an instance for one of the classes, then (k -> a) has too. The instances do what you would expect. Values become constant functions:

zero = const zero

Unary functions are composed:

sin f = sin . f

Binary functions fan out the input and combine both results:

f + g = \x -> f x + g x

You can either import them separately or import Data.Function.Instances.Algebra to get them all at once.