Skip to content

Instantly share code, notes, and snippets.

@zaetrik
Created May 12, 2020 07:20
Show Gist options
  • Save zaetrik/43aed901b6bcd4f637dc68fbfe83356e to your computer and use it in GitHub Desktop.
Save zaetrik/43aed901b6bcd4f637dc68fbfe83356e to your computer and use it in GitHub Desktop.
Monads: Nested Contexts
import * as O from "fp-ts/lib/Option";
addTwo :: number -> Option<number>
const addTwo = (x: number) => O.some(x + 2);
// If we map() with addTwo we get a nested context
O.map(addTwo, O.some(5)) // => Option<Option<number>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment