Script:

Type-class polymorphism

Headline

Type-class polymorphism in Haskell

Description

We have looked at parametric polymorphism as a means to describe functionality in a universal way for many types or, in fact, all types of a certain kind. This is appropriate whenever such polymorphic functionality does not need to make any assumptions about the actual types that fill in the type parameters eventually. There is another kind of polymorphism, where the same kind of functionality (in terms of function signatures) needs to be defined for many types, but these definitions may vary per type. For instance, the conversion of values to text is required functionality for many types, but its definition depends on the input type. Type class support such polymorphism to which we may refer thus as type-class polymorphism or bounded polymorphism (or "overloading"). Other use cases for type-class polymorphism are equality, total ordering, number types, algebraic structures such as monoids, and traversal of data (containers).

Concepts

The following concepts are just briefly mentioned in this lecture and a more detailed treatment is deferred to Script:Functors and friends.

Languages

Features

These features are eligible to the use of monoids for implementation.

Contributions


Ralf Lämmel edited this article at Fri, 07 Jul 2023 15:58:50 +0200
Compare revisions Compare revisions

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.