|
|
# Existential Quantifier
|
|
# Existential Quantifier
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this means supporting the 'exists' quantifier as creating existential types much the same way 'forall' can be used in ghc. An example would be
|
|
this means supporting the 'exists' quantifier as creating existential types much the same way 'forall' can be used in ghc. An example would be
|
|
|
|
|
|
|
|
|
|
|
|
```wiki
|
|
```wiki
|
|
|
type Any = exists a . Typeable a => a
|
|
type Any = exists a . Typeable a => a
|
|
|
|
|
|
|
|
sameType :: Any -> Any -> Bool
|
|
sameType :: Any -> Any -> Bool
|
|
|
sameType x y = typeOf x == typeOf y
|
|
sameType x y = typeOf x == typeOf y
|
|
|
|
|
``` |
|
|
```
|
|
\ No newline at end of file |
|
|
|
|
|
|
|
|
|
|
|
|
When existentials appear in the contravarient position such as above, they can be desugared into rank-n types with foralls. if existentials are allowed in the covarient position, then support for FirstClassExistentials? is needed.
|
|
|
|
|
|
|
|
|
|
## Support
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jhc currently supports the existential syntax anywhere a type is accepted, but will report an error if one is used in a covariant position with the exception of when it is a component of a data type. |
|
|