2022-03-12 23:33:26 +00:00
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 434ee61c-4461-424f-8dba-5c86ddb06c3c
|
|
|
|
:END:
|
|
|
|
#+title: Monoid
|
|
|
|
|
|
|
|
A [[id:b22a1c70-02a7-49ce-b5e7-407f1064cd0c][Semigroup]] with an identity value.
|
|
|
|
|
2022-03-16 23:56:10 +00:00
|
|
|
In [[id:9ac78677-2602-4a06-af0a-4ed82e98a9b6][Haskell]], the function representing the identity value for a given Monoid is
|
|
|
|
=mempty=.
|
|
|
|
|
|
|
|
#+caption: =mempty= in Haskell
|
|
|
|
#+begin_src haskell :exports code
|
|
|
|
mempty :: Monoid a => a
|
|
|
|
#+end_src
|
|
|
|
|
2022-03-12 23:33:26 +00:00
|
|
|
* Examples
|
2022-03-16 23:56:10 +00:00
|
|
|
** List
|
|
|
|
Combined with =append=, identity value is the empty list (=[]=)
|
|
|
|
** Number Addition
|
|
|
|
Combined with =+=, identity value is =0=
|
|
|
|
** Number Multiplication
|
|
|
|
Combined with =*=, identity value is =1=
|