Unit type

from Wikipedia, the free encyclopedia

With unit type ( English unit type ) is referred to in the type theory and computer science those type which only a single value has.

The designations of the type range from 1 ( category theory ) to ()( Haskell ) to Unit(e.g. Scala ) and void( C and descendants ) , depending on the area of ​​application ; however, the correspondence is not complete here, since it voidcannot be used everywhere a type is required and because literals are missing).

Since there is only one value, it does not carry any information with it. If it is necessary to name the value, it often happens 0- tuple , ()or with an otherwise used as symbol .

literature

  • Benjamin C. Pierce: Types and Programming Languages. MIT Press, Cambridge MA et al. 2002, ISBN 0-262-16209-1 .