MethodsFunctionsGenerics

Generics

Generic functions provide a form of polymorphism allowing many implementation methods with varying parameter types, called specializers. Methods on a given generic function are chosen according to applicability and are then ordered by specificity. A method is applicable if each argument is an instance of each corresponding specializer. A method A is more specific than method B if all of A's specializers are subtypes of B's. During method dispatch three cases can occur:

 <gen> (<fun>) C
 fun-mets (x|<gen> => <lst>) P
returns x's methods.
 gen-add-met (x|<gen> y|<met> => <gen>) G
adds method y to generic x.
 ord-app-mets (x|<gen> args|... => (tup ord|<lst> amb|<lst>)) G
returns both the list of sorted applicable methods and any ambiguous methods when generic x is called with arguments args.
 DG (DG ,name ,sig) S
defines a binding with name ,name bound to a generic with signature ,sig.

MethodsFunctionsGenerics