Created
May 12, 2020 07:20
-
-
Save zaetrik/43aed901b6bcd4f637dc68fbfe83356e to your computer and use it in GitHub Desktop.
Monads: Nested Contexts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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