Last active
June 29, 2023 21:48
-
-
Save benjstephenson/c77347f08721e85584c50a5c92ee7d08 to your computer and use it in GitHub Desktop.
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
const foo: number | undefined = 2 | |
const inc: (x: number) => number = x => x + 1 | |
const lift: <A, B>(f: (a: A) => B) => (a: A | undefined) => B | undefined = | |
f => a => a === undefined | |
? undefined | |
: f(a) | |
const map: <A, B>(a: A | undefined) => (f: (a: A) => B) => B | undefined = | |
a => | |
f => a === undefined | |
? undefined | |
: f(a) | |
const bar = map(foo)(inc) | |
const baz = lift(inc)(foo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment