Module

Data.Semigroup

Package
purescript-prelude
Repository
purescript/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 row subrow | rowlist -> subrow where

Members

Instances