[Ur] variant example

Adam Chlipala adamc at impredicative.com
Sat Jun 9 10:05:54 EDT 2012


Gergely Buday wrote:
> I would be glad to see a working example of 'make', creating a variant
> value, and using 'match' on it.

Here's a simple one:

type t = variant [A = int, B = float]

val a = make [#A] 1
val b = make [#B] 2.3

fun f (x : t) : string = match x {A = show, B = show}

val a' = f a
val b' = f b



More information about the Ur mailing list