Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (47 sloc) 1.91 KB
title description layout icon weight
Monoids
Monoids API
notopic
code-file
3

Each Monoid provides a means to represent a binary operation and is usually locked down to a specific type. These are great when you need to combine a list of values down to one value. In this library, any ADT that provides both an empty and a concat function can be used as a Monoid. There are a few of the crocks that are also monoidial, so be on the look out for those as well.

All Monoids work with the following helper functions mconcat, mreduce, mconcatMap and mreduceMap.

All Monoids provide empty functions on their Constructors as well as the following Instance Functions: valueOf, empty and concat.

Monoid Type Operation Empty (Identity)
All Boolean Logical AND true
Any Boolean Logical OR false
Assign Object Object.assign {lb}{rb}
Endo Function compose identity
First Maybe First Just Nothing
Last Maybe Last Just Nothing
Max Number Math.max -Infinity
Min Number Math.min Infinity
Prod Number Multiplication 1
Sum Number Addition 0
You can’t perform that action at this time.