3 ms·
I like to think of monads as a supporting sidecar wrapper. It's almost like a plugin system; you can extend some base computation to have additional functional
by bcheung 8y ago
I like to think of monads as a supporting sidecar wrapper. It's almost like a plugin system; you can extend some base computation to have additional functionality for free.
This becomes really obvious how much boilerplate can be "lift"ed in something like the Flare library for PureScript (https://david-peter.de/articles/flare/ https://david-peter.de/articles/flare/).
Ex:
lift2 ( * ) (int "a" 6) (int "b" 7)
This generates 2 text fields, hooks up the change events, plumbs them into a third UI component that renders the product of the 2 fields.
Fundamentally we are just saying we want "a * b" but the monad / sidecar does all the extra work to make UI components and hook up the change events.