I read through the wikipedia entry on this. I gathered that they're called existential types because of the existential operator (∃). I'm not sure what the point of it is, though. What's the difference between
T = ∃X { X a; int f(X); }
and
T = ∀x { X a; int f(X); }
...
A bit more specific than this question, can someone tell me what is the difference between Scala's existential types and Java's wildcard, prefereably with some illustrative example?
In everything I've seen so far, they seem to be pretty equivalent.
Edit: A few references. Martin Odersky mentions them; Google's top hit for my question
...
object Test extends Application {
// compiles:
Map[Int, Value](
0 -> KnownType(classOf[Object]),
1 -> UnknownValue())
// does not compile:
Map(
0 -> KnownType(classOf[Object]),
1 -> UnknownValue())
}
sealed trait Value {
def getType: Option[Class[_]]
}
case class UnknownValue() extends Value {
def getType = ...
So, just for fun, I've been playing with a CountedList type in Haskell, using Peano numbers
and smart constructors.
Type-safe head and tail just seem really cool to me.
And I think I've reached the limit of what I know how to do
{-# LANGUAGE EmptyDataDecls #-}
module CountedList (
Zero, Succ, CountedList,
toList, ofList,
empty,...
Currently watching Bart De Smet's explanation of IQueryable and he mentioned Existential Types (which I've been curious about for some time). After reading the answers to this question I'm just wondering if this is a way to construct it in C#:
public abstract class ExistentialType
{
private ExistentialType() { }
public abstrac...