Last active
June 22, 2018 14:44
-
-
Save kylecorbelli/fa49587e5ffc5a7404cf478a6b988681 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
import { curry } from 'ramda' | |
function maybeMap<A, B> (f: (val: A) => B, m: Maybe<A>): Maybe<B> { | |
switch (m.type) { | |
case MaybeType.Nothing: | |
return Nothing() | |
case MaybeType.Just: | |
return Just(f(m.value)) | |
} | |
} | |
export const Maybe = { | |
map: curry(maybeMap), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment