On 12-Nov-1998, Lennart Augustsson [EMAIL PROTECTED] wrote:
[...] if you dislike tuples you can use nested pairs
At the cost of losing a little type-safety.
--
Fergus Henderson [EMAIL PROTECTED] | "Binaries may die
WWW: http://www.cs.mu.oz.au/~fjh | but source code lives forever"
PGP:
I think it would be
really nice if it were possible to create a container capable of
containing any number of objects of any number of types It would
That's not possible in Haskell. Since you want an any number
of different types in this new type it would need to have a variable
number
[...] if you dislike tuples you can use nested pairs
At the cost of losing a little type-safety.
That's really a very minimal loss. (And it's not really a loss of
type safety, just the possibilty of confusing a part of a "tuple" with
another "tuple"). I'd be more worried about the
But if you dislike tuples you can use nested pairs, like
infixr 0 :.
data T a b = a :. b
Now you can write
'a' :. True :. "Hello" :. ()
which has type
T Char (T Bool (T String ()))
But I guess that's not what you were after?
-- Lennart
Fergus replied:
[...] if you dislike
PS. I've got a length function for ``heterogeneous lists'', as
they appear in nested pairs, in Hugs. However, it uses the
type system extensions available in 1.3c or in 1.4 [98 BETA].
How much can you do in plain Haskell??? in Cayenne?-)
oops.
On second thought, this length
I tried and failed to understand the reasons given in the Report (1.4)
for the monomorphism restriction and other type things. Could someone
explain what these mean and why they are needed? I think it would be
really nice if it were possible to create a container capable of
containing any number