elmbridge / curriculum

Curriculum for Elmbridge
https://elmbridge.github.io/curriculum/
66 stars 14 forks source link

Explanation for union types (#91) #92

Closed siruguri closed 7 years ago

avh4 commented 7 years ago

Looks pretty good-- I added a few more suggestions in https://github.com/elmbridge/curriculum/pull/92/commits/3cbb172df50f2be7bf3266e790756777e1f50dc8

avh4 commented 7 years ago

(Also, take a look at https://github.com/elmbridge/curriculum/issues/83 and make sure we're talking about things consistently with what's there.)

siruguri commented 7 years ago

I agree with your edits. (Jeez, "being of a" - where did I come up with that?!?)

Re #83, I hope this explanation is a good setup for the more complex patterns that are called "tags" in that issue. I would have to research the use of "tags" in the general Elm/FP literature to have an opinion on that issue though.

avh4 commented 7 years ago

in

type Result x a
    = Ok a
    | Err x

Ok and Err are the "tags", and the actual possible values of type Result String Int would be an Int "tagged with" Ok, or a String "tagged with" Err (both of which are sometimes called "tagged values"). I'm not sure if that kind of language is overall more consistent or not, but in any case, looks like we don't need to introduce any of those terms in the section relevant to this PR.

siruguri commented 7 years ago

Thanks. Interesting usage - the closest I can map to in my prog lang experience is templated types in C++, though I can't remember all the ways in which those type contracts were enforced in the language itself.