# Data.Monoid

- Package
- purescript-monoidDEPRECATED
- Repository
- purescript/purescript-monoid

### #Monoid Source

`class (Semigroup m) <= Monoid m where`

A `Monoid`

is a `Semigroup`

with a value `mempty`

, which is both a
left and right unit for the associative operation `<>`

:

```
forall x. mempty <> x = x <> mempty = x
```

`Monoid`

s are commonly used as the result of fold operations, where
`<>`

is used to combine individual results, and `mempty`

gives the result
of folding an empty collection of elements.

#### Members

`mempty :: m`

#### Instances

### #power Source

`power :: forall m. Monoid m => m -> Int -> m`

Append a value to itself a certain number of times. For the
`Multiplicative`

type, and for a non-negative power, this is the same as
normal number exponentiation.

If the second argument is negative this function will return `mempty`

(*unlike* normal number exponentiation). The `Monoid`

constraint alone
is not enough to write a `power`

function with the property that ```
power x
n
```

cancels with `power x (-n)`

, i.e. `power x n <> power x (-n) = mempty`

.
For that, we would additionally need the ability to invert elements, i.e.
a Group.

## Re-exports from **Prelude
**

### #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.

#### Members

`append :: a -> a -> a`

#### Instances

`Semigroup String`

`Semigroup Unit`

`Semigroup Void`

`(Semigroup s') => Semigroup (s -> s')`

`Semigroup (Array a)`

### #(<>)

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