[Haskell-cafe] What is the rank of a polymorphic type?

Stefan Holdermans stefan at cs.uu.nl
Sat Dec 5 08:56:06 EST 2009


Eugene,

> Consider the type: (forall a . a) -> String.

It's of rank 2.

> What is the definition of rank of a polymorphic type?

The minimal rank of a type is given by

   rank (forall a. t) = 1 `max` rank t
   rank (t -> u)      = (if rank t == 0 then 0 else rank t + 1) `max`  
rank u
   rank _             = 0

HTH,

   Stefan


More information about the Haskell-Cafe mailing list