Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Glasgow Haskell Compiler
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Type system extensions=== An expressive static type system is one of the major defining features of Haskell. Accordingly, much of the work in extending the language has been directed towards [[data type]]s and [[type class]]es. The Glasgow Haskell Compiler supports an extended type system based on the theoretical System F<sub>C</sub>.<ref name="Sulzmann2007"/> Major extensions to the type system include: * [[Parametric polymorphism#Higher-ranked polymorphism|Arbitrary-rank]] and [[Parametric polymorphism#Impredicative polymorphism|impredicative]] [[Polymorphism (computer science)|polymorphism]]. Essentially, a polymorphic function or datatype constructor may require that one of its arguments is also polymorphic. * [[Generalized algebraic data type]]s. Each constructor of a polymorphic datatype can encode information into the resulting type. A function which pattern-matches on this type can use the per-constructor type information to perform more specific operations on data. * [[Existential type]]s. These can be used to "bundle" some data together with operations on that data, in such a way that the operations can be used without exposing the specific type of the underlying data. Such a value is very similar to an [[object (computer science)|object]] as found in [[object-oriented programming]] languages. * Data types that do not actually contain any values. These can be useful to represent data in type-level [[metaprogramming]]. * [[Type families]]: user-defined functions from types to types. Whereas parametric polymorphism provides the same structure for every type instantiation, type families provide ''ad hoc'' polymorphism with implementations that can differ between instantiations. Use cases include content-aware optimizing containers and type-level metaprogramming. * Implicit function parameters that have dynamic [[scope (programming)|scope]]. These are represented in types in much the same way as type class constraints. * [[Linear types]] (GHC 9.0) Extensions relating to [[type class]]es include: * A type class may be parametrized on more than one type. Thus a type class can describe not only a set of types, but an ''n''-ary [[finitary relation|relation]] on types. * [[Functional dependencies]], which constrain parts of that relation to be a mathematical [[function (mathematics)|function]] on types. That is, the constraint specifies that some type class parameter is completely determined once some other set of parameters is fixed. This guides the process of [[type inference]] in situations where otherwise there would be ambiguity. * Significantly relaxed rules regarding the allowable shape of type class instances. When these are enabled in full, the type class system becomes a [[Turing-complete]] language for [[logic programming]] at compile time. * Type families, as described above, may also be associated with a type class. * The automatic generation of certain type class instances is extended in several ways. New type classes for [[generic programming]] and common recursion patterns are supported. Also, when a new type is declared as [[isomorphic]] to an existing type, any type class instance declared for the underlying type may be lifted to the new type "for free".
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)