[Haskell-cafe] Collection of objects?

Robert Dockins robdockins at fastmail.fm
Fri Nov 17 13:26:27 EST 2006

On Nov 17, 2006, at 12:36 PM, Valentin Gjorgjioski wrote:

> Is some kind of collection of object with different types in  
> Haskell exist? Except the tuples, which have fixed length.
> I find this
>    * Tuples heterogeneous, lists homogeneous.
>    * Tuples have a fixed length, or at least their length is  
> encoded in
>      their type. That is, two tuples with different lengths will have
>      different types.
>    * Tuples always finite.
> But I need something which is heterogeneous and non-fixed length.  
> I'm used do Java, and this switch to functional languages is very  
> strange to me. So, to be clear, I need something like  
> LinkedList<Object> in java.

The thing you're looking for doesn't really exist. (OK, yes, I'm  
lying a bit.  You can use existential types, but you probably don't  
actually need them, and they can get complicated quickly; they're  
better left until later).

Can you give us more details about what you're trying to do?  
Readjusting your thinking patterns can be difficult, but the people  
on this list are usually happy to help.

> Can you please help me or suggest me, what can I use in this case?
> Valentin

Rob Dockins

Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
           -- TMBG

More information about the Haskell-Cafe mailing list