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

Well apparently that's already the case just because they are Symbols ๐Ÿ‘

screen shot 2017-02-04 at 00 19 31

https://www.keithcirkel.co.uk/metaprogramming-in-es6-symbols/

@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