Skip to content

Instantly share code, notes, and snippets.

@xaviervia
Last active February 4, 2017 00:44
Show Gist options
  • Save xaviervia/74ed142bf08afdba22e690270798baaa to your computer and use it in GitHub Desktop.
Save xaviervia/74ed142bf08afdba22e690270798baaa to your computer and use it in GitHub Desktop.
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)
@xaviervia
Copy link
Author

Will add freeze

@leostera
Copy link

leostera commented Feb 3, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment