manual: alternative polymorphic variants intro

master
octachron 2015-12-18 21:42:55 +01:00
parent b8502751d0
commit 4f131e3803
1 changed files with 6 additions and 4 deletions

View File

@ -317,10 +317,12 @@ is only used when a more detailed specification is needed.
Variants as presented in section~\ref{s:tut-recvariants} are a
powerful tool to build data structures and algorithms. However they
sometimes lack flexibility when used in modular programming. This is
due to the fact every constructor reserves a name to be used with a
unique type. One cannot use the same name in another type, or consider
a value of some type to belong to some other type with more
constructors.
due to the fact that every constructor is assigned to an unique type
when defined and used. Even if the same name appears in the definition
of multiple types, the constructor itself belongs to only one type.
Therefore, one cannot decide that a given constructor belongs to
multiple types, or consider a value of some type to belong to some
other type with more constructors.
With polymorphic variants, this original assumption is removed. That
is, a variant tag does not belong to any type in particular, the type