According to this link describing existential types:
A value of an existential type like ∃x. F(x) is a pair containing some type x and a value of the type F(x). Whereas a value of a polymorphic type like ∀x. F(x) is a function that takes some type x and produces a value of type F(x). In both cases, the type closes over some type constructor F.
But a function definition with type class constraints doesn't pair with the type class instance.
It's not forall f, exists Functor f, ...
(because it's obvious not every type f has instance of Functor f, hence exists Functor f ...
not true).
It's not exists f and Functor f, ...
(because it's applicable to all instances of satisfied f, not only the chosen one).
To me, it's forall f and instances of Functor f, ...
, more like to scala's implicit arguments rather than existential types.
And according to this link describing type classes:
[The class declaration for
Eq
] means, logically, there is a type a for which the typea -> a -> Bool
is inhabited, or, from a it can be proved thata -> a -> Bool
(the class promises two different proofs for this, having names==
and/=
). This proposition is of existential nature (not to be confused with existential type)
What's the difference between type classes and existential types, and why are they both considered "existential"?