Found 1 hit - Term: generic type variable, Database: *, Strategy: prefix
- [1] : The Free On-line Dictionary of Computing (27 SEP 03)
generic type variable
also known as a "schematic type variable".
different occurrences of a generic type variable in a type
expression may be instantiated to different types. thus, in
the expression
let id x = x in
id true, id 1
id's type is for all a: a -> a. the universal quantifier
"for all a:" means that a is a generic type variable. for the
two uses of id, a is instantiated to bool and int. compare
this with
let id x = x in
let f g = g true, g 1 in
f id
this looks similar but f has no legal hindley-milner type.
if we say
f :: a -> b -> b, b
this would permit g's type to be any instance of a -> b
rather than requiring it to be at least as general as a ->
b. furthermore, it constrains both instances of g to have
the same result type whereas they do not. the type variables
a and b in the above are implicitly quantified at the top
level:
f :: for all a: for all b: a -> b -> b, b
so instantiating them removing the quantifiers can only be
done once, at the top level. to correctly describe the type
of f requires that they be locally quantified:
f :: for all a: a -> for all b: b -> c, d
which means that each time g is applied, a and b may be
instantiated differently. f's actual argument must have a
type at least as general as for all a: a -> for all b:
b, and may not be some less general instance of this type.
type variables c and d are still implicitly quantified at the
top level and, now that g's result type is a generic type
variable, any types chosen for c and d are guaranteed to be
instances of it.
this type for f does not express the fact that b only needs to
be at least as general as the types c and d. for example, if
c and d were both bool then any function of type for all a: a
-> bool would be a suitable argument to f but it would not
match the above type for f.
see also:
quantifier hindley-milner type
Results 1 - 2 of 2 found about generic type variable: Generic
>> G Words
Generic, definition of term: Generic
generic_pag1.html Blood Type
>> B Words
Blood Type, definition of term: Blood Type
blood+type_pag1.html
Last accessed:2008/10/08 06:56:52 [Total processing time: 0 seconds] |