momonorphisation and imperative/weak type variables
Stephen Weeks
sweeks@intertrust.com
Thu, 24 Aug 2000 09:35:19 -0700 (PDT)
Here is the example I promised yesterday. It type checks under imperative or
weak type variables, but not the value restriction. With our usual
monomorphisation strategy, we would duplicate the definitions of f and g,
causing r to be incremented twice, instead of once.
val r = ref 13
val f: unit -> 'a -> 'a = fn () => (r := !r + 1; fn x => x)
val g: 'a -> 'a = f()
val _ = g "foo"
val _ = g true