jonathanfishbein1/numeric-typeclasses/1.0.0

NOTE: the latest version is 4.0.0

Semigroup

Semigroup typeclass definition and its instances for basic types.

Definition

type alias Semigroup a =
a -> a -> a

Explicit typeclass which implements semigroup operations for type a.

Notice that the binary operation function is named "prepend" instead of "append", because it follows the convention of having the context value come as the last value.

Construction utilities

prepend : (a -> a -> a) -> Semigroup a

Construct from a prepend function.

concat : (List a -> a) -> Semigroup a

Construct from a concatenation function.

appendable : Semigroup appendable

Construct an instance for any type which satisfies Elm's appendable magic constraint.

Instance transformation utilities

map : (a -> b) -> (b -> a) -> Semigroup a -> Semigroup b

Map over the owner type of an instance to produce a new instance.

You need to provide both a covariant and a contravariant mapping (i.e., (a -> b) and (b -> a)).

Instances

string : Semigroup String

Instance for strings under the appending operation.

maybeFirst : Semigroup (Maybe a)

Instance for maybe, which chooses the first Just value.

list : Semigroup (List a)

Instance for list under concatenation.

cmd : Semigroup (Cmd msg)

Instance for commands under the batch operation.

sub : Semigroup (Sub msg)

Instance for subscriptions under the batch operation.

task : Semigroup a -> Semigroup (Task x a)

Instance for tasks, which sequentially executes them and groups the results.

composition : Semigroup (a -> a)

Instance for a -> a function

setDifference : Semigroup (Set comparable)

Instance for set under the difference operation.

and : Semigroup Bool

Instance for and

intProduct : Semigroup Int

Instance for integers under the multiplication operation.

intSum : Semigroup Int

Instance for integers under the sum operation.

modularArithmetic : Int -> Semigroup Int

Instance for modularArithmetic semigroup

numberProduct : Semigroup number

Construct an instance for any type which satisfies Elm's number magic constraint. Implements multiplication.

numberSum : Semigroup number

Construct an instance for any type which satisfies Elm's number magic constraint. Implements sum.

or : Semigroup Bool

Instance for or

setIntersection : Semigroup (Set comparable)

Instance for set under the intersection operation.

setUnion : Semigroup (Set comparable)

Instance for set under the union operation.

unit : Semigroup ()

Instance for trivial semigroup

xor : Semigroup Bool

Instance for xor