Produce a hash for a type that is unique for that type. The hash takes both actual type names and type structure into account.
The purpose of the hash of a type is to be able to store the type of a persisted value together with the value. By comparing the type hash of a persisted value and the expected value we can know if the persistened value is of the correct type.
The type code preserves the exact structure of the type and can be used to
check if one type is a subtype of another. If one type is a subtype of
another it means that, e.g., read . show
will correctly between the types.
(Caveat read . show
is only guaranteed to work with named fields.)
The type hash uses a cryptographic hash and can only be used to test equality.
Documentation
Type codes.
convertibleTo :: TypeCode -> TypeCode -> BoolSource
Is the first type (code) as subtype of the second, i.e., can the first type be converted to the second.
Type hash.