Skip to content

Instantly share code, notes, and snippets.

@WimJongeneel
Created December 15, 2019 10:59
Show Gist options
  • Save WimJongeneel/a5545bbd444d24074a51e8c9bbe50a4f to your computer and use it in GitHub Desktop.
Save WimJongeneel/a5545bbd444d24074a51e8c9bbe50a4f to your computer and use it in GitHub Desktop.
type Option<a> = { kind: 'none' } | { kind: 'some', value: a }
let val: Option<string> = { kind: 'some', value: 'hello' }
// Conditinal way of geting the value
if(val.kind == 'some') return val.value
// Pattern matching way of geting the value
match(val)
.with({ kind: 'some' }, o => o.value) // TypeError!
.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment