2 ms·
p = newPerson(); w = walk(p); t = talk(p, w); s = shout(p, t); becomes, seq(shout, seq(talk, seq(walk, seq(newPerson()))) "infix", newPe
by mjburgess 5y ago
p = newPerson();
w = walk(p);
t = talk(p, w);
s = shout(p, t);
becomes,
seq(shout, seq(talk, seq(walk, seq(newPerson())))
"infix",
newPerson() seq
walk seq
talk seq
shout
The operations `newPerson` and `seq` form a monad.
If you can omit `w =`, `t=`, and `s=` you have an applicative, rather than a monad. Ie., the operations being sequenced are independent.