Personal tools

Phantom type

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (+cat)
Line 1: Line 1:
A '''phantom type''' is a [[type]] the values of which are never used, the type being used only to construct other types.
+
A '''phantom type''' is a [[type]] the values of which are never used, the type being used only to construct other types. They are used in [[type arithmetic]].
   
 
An extension to Haskell 98 supported by [[GHC]] allows you to define datatypes without any constructors (and therefore no values other than [[bottom]]):
 
An extension to Haskell 98 supported by [[GHC]] allows you to define datatypes without any constructors (and therefore no values other than [[bottom]]):
   
data MyType;
+
data MyType
   
 
This helps distinguish phantom types.
 
This helps distinguish phantom types.

Revision as of 20:37, 1 February 2006

A phantom type is a type the values of which are never used, the type being used only to construct other types. They are used in type arithmetic.

An extension to Haskell 98 supported by GHC allows you to define datatypes without any constructors (and therefore no values other than bottom):

data MyType

This helps distinguish phantom types.