<div dir="ltr">From what I understand (not much), It seems that type-classes are more-or-less equivalent to OO interfaces (I think OP mentioned this), and that containers with existential types are less more-or-less equivalent to OO containers whose elements implement an interface, the biggest exception being that you can&#39;t use anything that isn&#39;t a part of the class on the contained values.<br>
<br>As I understand, something like this could be relevant:<br><br>&gt; class AquaticLifeform a where<br>&gt;   nutrition :: Int<br>&gt;   reproduce :: Maybe (a, a)<br><br><div class="gmail_quote">On Thu, Aug 26, 2010 at 10:08 AM, Stephen Tetley <span dir="ltr">&lt;<a href="mailto:stephen.tetley@gmail.com">stephen.tetley@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Drew<br>
<br>
Bear in mind though that existentials are not equivalent to subtyping in OO.<br>
<br>
For instance, with example 2.1 from [1] all you can do with an Obj is<br>
show it, so for the list xs all you can do is show the elements:<br>
<br>
data Obj = forall a. (Show a) =&gt; Obj a<br>
<br>
xs :: [Obj]<br>
xs = [Obj 1, Obj &quot;foo&quot;, Obj &#39;c&#39;]<br>
<br>
Because Obj is an existential you can&#39;t do an case analysis on it - so<br>
you can&#39;t write a function like this:<br>
<br>
add_one_if_int (Obj (n::Int)) = Obj (n+1)<br>
add_one_if_int (Obj other)    = Obj other<br>
<br>
There really is nothing you can do with Obj other than show it.<br>
<br>
<br>
If you are trying to transliterate OO designs, you might quickly find<br>
existentials are too inert to be useful.<br>
<br>
Best wishes<br>
<br>
Stephen<br>
<br>
[1] <a href="http://www.haskell.org/haskellwiki/Existential_type" target="_blank">http://www.haskell.org/haskellwiki/Existential_type</a><br>
<div class="im"><br>
<br>
On 26 August 2010 07:45, Drew Haven &lt;<a href="mailto:drew.haven@gmail.com">drew.haven@gmail.com</a>&gt; wrote:<br>
&gt; I think I found the answers to all my questions at<br>
&gt; <a href="http://www.haskell.org/haskellwiki/Existential_type" target="_blank">http://www.haskell.org/haskellwiki/Existential_type</a><br>
</div><div><div></div><div class="h5">_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><div>          Alex R</div></div><br>
</div>