Concept:
Type synonym
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 as well be transformed by resolving all type synonyms (described by Feature:Flat_company) to a less understandable variant:
total :: ([Char], [([Char], [Char], Float)]) -> Float
Concept:
Type synonym
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 as well be transformed by resolving all type synonyms (described by Feature:Flat_company) to a less understandable variant:
total :: ([Char], [([Char], [Char], Float)]) -> Float
Language:
Haskell
Headline
The functional programming language Haskell
Details
101wiki hosts plenty of Haskell-based contributions. This is evident from corresponding back-links. More selective sets of Haskell-based contributions are organized in themes: Theme:Haskell data, Theme:Haskell potpourri, and Theme:Haskell genericity. Haskell is also the language of choice for a course supported by 101wiki: Course:Lambdas_in_Koblenz.
Illustration
The following expression takes the first 42 elements of the infinite list of natural numbers:
> take 42 [0..]
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41]
In this example, we leverage Haskell's lazy evaluation.