Comparing revisions for page Type synonym
Back to history list
== Headline ==
Abstraction over type expressions
== Illustration ==
The name [[type synonym]] is specifically used in [[Language:Haskell]]. (The same concept goes by the name "typedef" in, for example, [[Language:C]].) For instance, the following Haskell declaration introduces a type synonym for salaries to be represented as floats.
type Salary = Float
The choice of a type synonym implies that salaries and floats are compatible in a typing sense: any float is immediately acceptable whereever a salary is expected, and vice versa. The type synonym is merely a convenience without any proper effect on typing.
Thus, if you look at the signature of a function, such as total:
total :: Company -> Float
This signature could be transformed by resolving all typesynonyms into (a less understandable variant!):
total :: ([Char], [([Char], [Char], Float)]) -> Float
== Metadata ==
* [[sameAs::http://en.wikipedia.org/wiki/Typedef]]
* [[sameAs::http://www.haskell.org/haskellwiki/Type_synonym]]
* [[memberOf::Vocabulary:Functional programming]]
* [[relatesTo::Structural typing]]
* [[isA::Concept]]