[Ur] Wiki: Polymorphic_Variants_Usage_Example

Marc Weber marco-oweber at gmx.de
Fri Dec 17 22:34:43 EST 2010


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
 *)

If you replace the first Medium by _ it compiles.
do those constructors Hot, Medium, Cold, Large, Small share the same
namepsace? If not can I identify the first medium somehow, eg
temp.Medium?

If so declaration should be prohibited. If its not - why 

fun tempvalue temp =
    case temp of
        Hot => 10
      | Medium => 5 (* replace Medium by _ and it compiles *)
      | Cold => 1

fun sizevalue size =
    case size of
        Large => 8
      | Medium => 4
      | Small => 2




More information about the Ur mailing list