Equivalence of Type expression
. Structural equivalence: Two type expressions are equivalent if
. either these are same basic types
. or these are formed by applying same constructor to equivalent types
. Name equivalence : types can be given names
. Two type expressions are equivalent if they have the same name
The checking rules enumerated above have the form "if two type expressions are equal then return a certain type else return type_error ". Thus, it is often required to make the decision whether two expressions are equivalent. In particular, the case where names are given to type expressions and the names are then used in subsequent type expressions produces ambiguities. There are two distinct notions of equivalence of type-expressions:
Structural equivalence : Two expressions are structurally equivalent if they are either the same basic type, or are formed by applying the same constructor to structurally equivalent types.
Name equivalence : In this case, each type name is viewed as a distinct type, and equivalence of two type-expressions is based on their having identical type names. When names are not allowed in type expressions, two type-expressions are structurally equivalent only if they are identical. If names are allowed, two type expressions are name-equivalent only if they are identical, but are structurally independent if they represent two structurally equivalent expressions when all names have been substituted out by the type expressions they define.
|