Re: monomorphism etc.
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: finger [EMAIL PROTECTED]| -- leaked Microsoft memo.
Re: monomorphism etc.
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 of type variables, which is impossible. 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
Re: monomorphism etc.
[...] 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 performance loss due to the extra lifting for each nested pair. But tuples should be used very sparingly anyway, in my opinion. Define new types instead! -- Lennart
nested pairs (was Re: monomorphism etc.)
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 tuples you can use nested pairs At the cost of losing a little type-safety. Well, since no one else mentions it: It's fun to (try to) define some functions over these ``heterogeneous lists''. In which languages can you define, e.g., a length function?-) Claus 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?-)
Re: nested pairs (was Re: monomorphism etc.)
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 program uses only plain old Haskell? [from a Hugs1.4June1998 session transcript] Main l (True :. 'c' :. "length" :. ()) 3 Main l () 0 Main l (() :. ()) 1 What else have I missed?-) Claus
monomorphism etc.
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 of objects of any number of types It would avoid the nastiness of a special definition for each tuple type and and lead to more flexibility. I suspect it is impossible, but don't know why. -- __ / David Feuer \ | [EMAIL PROTECTED] | | [EMAIL PROTECTED]| \ [EMAIL PROTECTED] / -