Module

Data.Semigroup

#Semigroup

class Semigroup a  where

The Semigroup type class identifies an associative operation on a type.

Instances are required to satisfy the following law:

  • Associativity: (x <> y) <> z = x <> (y <> z)

One example of a Semigroup is String, with (<>) defined as string concatenation. Another example is List a, with (<>) defined as list concatenation.

Newtypes for Semigroup

There are two other ways to implement an instance for this type class regardless of which type is used. These instances can be used by wrapping the values in one of the two newtypes below:

  1. First - Use the first argument every time: append first _ = first.
  2. Last - Use the last argument every time: append _ last = last.

Members

Instances

#(<>)

Operator alias for Data.Semigroup.append (right-associative / precedence 5)

#SemigroupRecord

class SemigroupRecord :: RowList Type -> Row Type -> Row Type -> Constraintclass SemigroupRecord rowlist row subrow | rowlist -> subrow where

A class for records where all fields have Semigroup instances, used to implement the Semigroup instance for records.

Members

Instances

Modules