Go backward to Universal Quantification
Go up to Top
Go forward to Parametric Types
Polymorphic Functions
- First version of polymorphic twice:
- value twice1 = all[t] fun(f: forall a: a a)
fun(x: t) f[t](f[t](x))
- twice1[Int](id)(3) is legal.
- twice1[Int](succ) is illegal!
- Second version of polymorphic twice:
- value twice2 = all[t] fun(f: t t) fun(x: t)
f(f(x))
- twice2[Int](succ) is legal.
- twice2[Int](id[Int])(3) is legal.
- Both versions different in nature of f:
- In twice1, f is a polymorphic function of type
forall a: a a.
- In twice2, f is a monomorphic function of type
(for some instantiation of )
Wolfgang.Schreiner@risc.uni-linz.ac.at
Id: understand.tex,v 1.1 1996/06/12 09:38:21 schreine Exp schreine