4 ms·
In algebra, monads are used to reify the notion of an "explicit expression". So you have the integers, Z, and the monad m gives m(Z), the set of expressions (le
by edflsafoiewq 5y ago
In algebra, monads are used to reify the notion of an "explicit expression". So you have the integers, Z, and the monad m gives m(Z), the set of expressions (let's say sums) over Z. And then you have m(m(Z)) which is nested expressions and so on. An algebra for a monad evaluates an expression m(Z)->Z, and all the monad laws basically enforce the kind of equational reasoning ordinary notation takes for granted (eg sub-expressions can be replaced by their value, 1+(1+1)=1+2).
So those would be related in this way
join
(1)+(1+1) : m(m(Z)) -----> 1+1+1 : m(Z)
| |
fmap(eval) | | eval
v v
1+2 : m(Z) -----------> 3 : Z
eval