|
|
|
|
|
by ratmice
3189 days ago
|
|
>> Please do tell how you would make two or more instances of an abstract type in Java, in such a way that... >By having two implementations of a common interface, like `ArrayList` and `LinkedList` both implementing `List`. This is not i believe what he is talking about, here is a silly example in SML, it has 3 types which all share a type t...
a list of t pairs, a vector of t's, and a function from pair of t's to t. functor Foo (type t;
val pairs : (t * t) list
val f : t * t -> t)
= struct
val things : t vector = Vector.fromList (List.map f pairs);
end One thing to note is that t is never exported/returned.
and thus, the thing returned exports t vector but not t. we could export t in a few different ways: type t = t; Export it, let its binding be known
type t; Its a type, but what it is bound to is not known. |
|