paldepind / union-type

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

Tutorial on using union-types #33

Open jethrolarson opened 8 years ago

jethrolarson commented 8 years ago

I think there's a lack of info on how to actually apply union types to real problems in js.

I'd like to see something like http://fsharpforfunandprofit.com/series/designing-with-types.html offered somewhere. I understand if you want that outside the scope of this repo, but I thought I'd open an issue incase you want to make it a wiki or something.

I'd be interested in contributing here.

ericgj commented 8 years ago

I agree, great idea. Quite a few of the examples in functional-frontend-architecture use this library. Granted, they are pretty narrowly focused on modelling actions in the Elm architecture sense, and they don't demonstrate the new features of union-type. But that may be a place to collect some examples.

I have a few half-baked projects which use union-type outside of the Elm architecture, I can't say they are more than getting my feet wet, but they may be useful to look at.

paldepind commented 8 years ago

I agree with this as well. Just having such a library is one thing. But figuring out how best to use it is probably not easy unless one has experience in a language with algebraic data types. A tutorial would be a great idea.

kwijibo commented 8 years ago

+1 The FSharp blog was also what got me interested in this style of programming, and while I've managed to find this library very useful, my understanding of (functional) type-based design is inferred too much from current capabilities of union-type (rather than general principles). So I'm sometimes not sure what the most idiomatic way to use it is, or if a feature I'd like to see would be an appropriate addition.