Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are types with type constraints called?

Tags:

haskell

ghc

For example, Num a => a.

I assumed they're just called "constrained types", but Googling didn't turn up many uses of that term so I'm curious to know if they go by some other name.

like image 448
Laurence Gonsalves Avatar asked Jul 13 '12 16:07

Laurence Gonsalves


People also ask

What is constraints and its types in SQL?

Constraints can be column level or table level. Column level constraints apply to a column, and table level constraints apply to the whole table. The following constraints are commonly used in SQL: NOT NULL - Ensures that a column cannot have a NULL value. UNIQUE - Ensures that all values in a column are different.

Where is generic type constraint?

The where clause in a generic definition specifies constraints on the types that are used as arguments for type parameters in a generic type, method, delegate, or local function. Constraints can specify interfaces, base classes, or require a generic type to be a reference, value, or unmanaged type.

What are the three main types of constraints?

The three primary constraints that project managers should be familiar with are time, scope, and cost. These are frequently known as the triple constraints or the project management triangle.

What are type constraints?

A type constraint on a generic type parameter indicates a requirement that a type must fulfill in order to be accepted as a type argument for that type parameter. (For example, it might have to be a given class type or a subtype of that class type, or it might have to implement a given interface.)


1 Answers

Types with this particular kind of constraints are called "qualified types", and the feature itself sometimes "qualified polymorphism". I believe the terminology was originally introduced by Mark Jones' ESOP '92 paper.

Qualified types should not be confused with the more mainstream notion of "bounded polymorphism", on which generics in languages like Java are based. Bounded polymorphism essentially is the (rather complicated) combination of parametric polymorphism with subtyping, whereas qualified types get along without subtyping.

like image 152
Andreas Rossberg Avatar answered Sep 23 '22 19:09

Andreas Rossberg