Last active
February 4, 2017 00:44
-
-
Save xaviervia/74ed142bf08afdba22e690270798baaa to your computer and use it in GitHub Desktop.
This file contains hidden or 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 createType = name => { | |
const of = x => Object.freeze({ | |
'@@type': name, | |
fold: f => f(x), | |
map: f => of(f(x)), | |
inspect: () => `${name}(${x})` | |
}) | |
return {of} | |
} | |
const Left = createType('Left') | |
const x = {a: 1} | |
Left.of(x).map(({a}) => a + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍