[Ur] Wiki: Polymorphic_Variants_Usage_Example

Adam Chlipala adamc at impredicative.com
Sat Dec 18 08:27:39 EST 2010


Marc Weber wrote:
> http://impredicative.com/wiki/index.php/Polymorphic_Variants_Usage_Example
>
> (* The commented out functions below do not compile .. the Medium constructor is not polymorphic;
>   * it must "decide" on one of temp or size type
>   *)
>
> [...snip...]
>
>  From reading the definitions in basis.urs I find it hard to find out how
> to use them.
>    

The code you quoted doesn't use polymorphic variants, which probably 
explains why you found the definition of polymorphic variants unhelpful. ;)

Rather, the code you quoted uses normal ML variants, which are already 
quite well accepted in SML, OCaml, and F#.  Thus, I see no reason to 
change the behavior.  Just like with any other identifier in ML, it is 
possible to shadow datatype constructor names, such that they literally 
become unmentionable in future code.  You can use modules as a namespace 
mechanism to reuse constructor names, just as you can use this technique 
to reuse any identifier.



More information about the Ur mailing list