paldepind / union-type

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

What about names types? #23

Closed ccorcos closed 8 years ago

ccorcos commented 8 years ago

It seems like names types might be easier to work with.

const Point = Type({Point: {x:Number, y:Number}})

Point.case({
  Point: ({x, y}) => {}
}, point)

When types get more and more complicated it, I'd image it gets pretty hard to keep track of the order of everything. Any reason you decided to stick with arrays? I understand haskell seems to do it that way...

paldepind commented 8 years ago

Yes. That is a great idea. Haskell supports it with records.

There was another discussion that among other things was about such a feature. As described here I actually implemented it. I never got it finished up though :(

ccorcos commented 8 years ago

Awesome! :+1:

paldepind commented 8 years ago

I don't think unfinished unmerged code is particularly awesome ;)

What do you think about the features in the branch? Anything you like or don't like? Anything you'd still be missing? Would you use it? If so I should finish it up, merge it in and do a release.

ccorcos commented 8 years ago

haha. I was just commending the work in progress.

It looks good to me -- I wouldnt worry about enumeration. I'm not using union-type yet, but I'm inspired to from looking at your functional frontend examples. This was the only part holding me back.