Phantom type

From OCaml Wiki
Jump to: navigation, search

A phantom type is a type variable that appears on the left-hand side of a type declaration but not on the right-hand side. They are typically used to track properties of values and enforce invariants on those properties via user-defined APIs and the assistance of the type system. In the type declaration below, the type 'a is a phantom type because it does not appear on the right-hand size of the equality:

 type 'a query = string