Module

Data.Semigroup

Package
prelude
Repository
purerl/purescript-prelude

#Semigroup Source

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

#(<>) Source

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

#SemigroupRecord Source

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