roam/20220312165629-monoid.org
2022-03-16 19:56:10 -04:00

22 lines
615 B
Org Mode

:PROPERTIES:
:ID: 434ee61c-4461-424f-8dba-5c86ddb06c3c
:END:
#+title: Monoid
A [[id:b22a1c70-02a7-49ce-b5e7-407f1064cd0c][Semigroup]] with an identity value.
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
* Examples
** 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=