paldepind / union-type

A small JavaScript library for defining and using union types.
MIT License
477 stars 28 forks source link

add predicates `is[Something]` for union type #56

Open jcouyang opened 7 years ago

jcouyang commented 7 years ago

just a handy predicate, so we can do

blah.filter(Maybe.isJust)

instead of

blah.filter(x=>x._name==='Just')

or

blah.filter(Maybe.case({Just: ()=>true, _: ()=>false}))