mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-10-26 11:18:47 +03:00
Changes to the Monoids section of the Basics chapter
This commit is contained in:
parent
363eb58099
commit
8073d55aaf
@ -508,8 +508,8 @@ Monoids
|
|||||||
-------
|
-------
|
||||||
|
|
||||||
Monoids provide an interface for structures which have an associative operation
|
Monoids provide an interface for structures which have an associative operation
|
||||||
(``mappend``) and a neutral element (``mempty``) which is the zero for the join
|
(``mappend``, there is also the synonym ``<>``) and a neutral
|
||||||
operation.
|
(also: unit or zero) element (``mempty``) for that operation.
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
class Monoid a where
|
class Monoid a where
|
||||||
@ -518,7 +518,8 @@ class Monoid a where
|
|||||||
mconcat :: [a] -> a
|
mconcat :: [a] -> a
|
||||||
```
|
```
|
||||||
|
|
||||||
The canonical example is the list type with the zero being the empty list.
|
The canonical example is the list type with concatenation as the operation
|
||||||
|
and the empty list as zero.
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
Loading…
Reference in New Issue
Block a user