Skip to content

Instantly share code, notes, and snippets.

@joost-de-vries
Last active January 1, 2016 07:19
Show Gist options
  • Save joost-de-vries/8110503 to your computer and use it in GitHub Desktop.
Save joost-de-vries/8110503 to your computer and use it in GitHub Desktop.
notes from Gilad Brachas talk wrt functor, monad, semigroup, monoid.The observation that a monoid is foldRightable is interesting.
a semigroup is addable
a monoid is foldRightable or aggregatable
(ie addable, zero)
a functor is mappable
a monad is chainable or flatmappable
strong suit of monads:
pipelining using a for comprehension, handle different outcomes, null, deferred outcomes until the first future completes etc
Erik Meijer calls this: focus on the happy path
a ring is multipliable
in addition to addable and additive zero
Kleisli arrows are a way of composing functions that return options etc without having to do a for comprehension
the monad contract:
new C(x).flatMap(f) == f(x);
c.flatMap((x)=> new C(x)) == c;
c.flatMap((x)=> f(x).flatMap(g)) ==
c.flatMap(f).flatMap(g);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment