Skip to content

Instantly share code, notes, and snippets.

@zaetrik
Created May 12, 2020 07:54
Show Gist options
  • Save zaetrik/425345970034ecc1053fdce169a14c41 to your computer and use it in GitHub Desktop.
Save zaetrik/425345970034ecc1053fdce169a14c41 to your computer and use it in GitHub Desktop.
Monads: Example
import * as O from "fp-ts/lib/Option";
const addTwo = (x: number) => some(x + 2);
// Now we can work with nested contexts, thanks to chain/flatMap in our Monad instance
O.chain(addTwo)(O.some(5)); // => Option<number>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment