reasonml-q-a
reasonml-q-a copied to clipboard
What's the difference between ordinary variants and polymophic variants?
Question
What's the difference between ordinary variants and polymorphic variants? What's the best use-case for ordinary variants and what is for poly variants? What are the pros and the cons of both?
Answer
This question hasn't been answered yet.
Further reading
Resources I found so far:
- https://reasonml.github.io/docs/en/variant Only thing I found there is:
Variant Types Are Found By Field Name
Please refer to this record section. Variants are the same: a function can't accept an arbitrary constructor shared by two different variants. Again, such a feature exists, it's called a polymorphic variant. We'll talk about this in the future =)
- https://2ality.com/2017/12/variants-reasonml.html
- https://2ality.com/2018/01/polymorphic-variants-reasonml.html
- https://sketch.sh/s/5J9PMoANc62p5GcMS5oPle/