| 9 | | * [http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#existential-quantification] GHC documentation |
| | 9 | * [http://www.cs.luc.edu/users/laufer/papers/toplas94.pdf Polymorphic Type Inference and Abstract Data Types] by K. Läufer and M. Odersky, in TOPLAS, Sep 1994. |
| | 10 | * [http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#existential-quantification GHC documentation] |
| | 11 | |
| | 12 | == Variations == |
| | 13 | |
| | 14 | * Hugs allows existential quantification for newtype declarations, as long as there are no class constraints. |
| | 15 | {{{ |
| | 16 | newtype T = forall a. C a |
| | 17 | }}} |
| | 18 | GHC and Nhc98 do not. |
| | 19 | |
| | 20 | * Hugs and Nhc98 allow matching on an existentially quantified constructor in a pattern binding declaration, except at the top level. |
| | 21 | {{{ |
| | 22 | data T = forall a. C (a -> Int) a |
| | 23 | foo t = let C f x = t in f x |
| | 24 | }}} |
| | 25 | GHC does not allow such matching. |
| | 26 | |
| | 27 | * None of the implementations can derive instances for existentially quantified types, but this could be relaxed, e.g |
| | 28 | {{{ |
| | 29 | data T = forall a. Show a => C [a] |
| | 30 | deriving Show |
| | 31 | }}} |
| | 32 | |
| | 33 | * GHC 6.5 allows fields with existentially quantified types, though selectors may only be used if their type does not include the quantified variable. |
| | 34 | {{{ |
| | 35 | data T = forall a. C { f1 :: a, f2 :: Int } |
| | 36 | }}} |