Polymorphic recursion
In computer science, polymorphic recursion (also referred to as Milner–Mycroft typability or the Milner–Mycroft calculus) refers to a recursive parametrically polymorphic function where the type parameter changes with each recursive invocation made, instead of staying constant. Type inference for polymorphic recursion is equivalent to semi-unification and therefore undecidable and requires the use of a semi-algorithm or programmer-supplied type annotations.
In computer science, polymorphic recursion (also referred to as Milner–Mycroft typability or the Milner–Mycroft calculus) refers to a recursive parametrically polymorphic function where the type parameter changes with each recursive invocation made, instead of staying constant. Type inference for polymorphic recursion is equivalent to semi-unification and therefore undecidable and requires the use of a semi-algorithm or programmer-supplied type annotations. data Nested a = a : A length function defined over this datatype will be polymorphically recursive, as the type of the argument changes from Nested a to Nested [a] in the recursive call: length :: Nested a -> Int length Epsilon = 0 length (_ : Note that Haskell normally infers the type signature for a function as simple-looking as this, but here it cannot be omitted without triggering a type error. Richard Bird and Lambert Meertens (1998). "Nested Datatypes". C. Vasconcellos, L. Figueiredo, C. Camarao (2003). "Practical Type Inference for Polymorphic Recursion: an Implementation in Haskell ". Journal of Universal Computer Science. L. Figueiredo, C. Camarao. "Type Inference for Polymorphic Recursive Definitions: a Specification in Haskell".
References
No reference rows published for this article.
Cite this article
MLA
"Polymorphic recursion." encyclopegia.org, 2026, https://encyclopegia.org/wiki/polymorphic-recursion. Accessed 24 November 2026.
Chicago
"Polymorphic recursion." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/polymorphic-recursion.
APA
encyclopegia.org. (2026). Polymorphic recursion. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/polymorphic-recursion
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON