Re: [Haskell-cafe] Existential types (Was: Type vs TypeClass duality)

2007-10-25 Thread apfelmus
Ryan Ingram wrote: On 10/24/07, apfelmus [EMAIL PROTECTED] wrote: So, instead of storing a list [∃a. Show a = a], you may as well store a list of strings [String]. I've seen this before, and to some extent I agree with it, but it breaks down for bigger examples due to sharing. In most

Re: [Haskell-cafe] Existential types (Was: Type vs TypeClass duality)

2007-10-25 Thread Wouter Swierstra
In a sense, that's also the reason why stream fusion à la Duncan + Roman + Don uses an existential type data Stream a where Stream :: ∀s. s - (s - Step a s) - Stream a data Step a s = Done | Yield a s | Skip s I thought there was a deeper reason for

[Haskell-cafe] Existential types (Was: Type vs TypeClass duality)

2007-10-24 Thread apfelmus
TJ wrote: data Showable = forall a. Show a = Showable a stuff = [Showable 42, Showable hello, Showable 'w'] Which is exactly the kind of 2nd-rate treatment I dislike. I am saying that Haskell's type system forces me to write boilerplate. Nice :) I mean, the already powerful

Re: [Haskell-cafe] Existential types (Was: Type vs TypeClass duality)

2007-10-24 Thread Alfonso Acosta
Thanks for posting this, I finally understand existentials! This bit was specially helpful: So, how to compute a value b from an existential type ∃a.(a - a)? ... Could you give a specific example of computing existential types? I think this shows why digested tutorials, as opposed to

Re: [Haskell-cafe] Existential types (Was: Type vs TypeClass duality)

2007-10-24 Thread Dan Weston
Thanks for the concise explanation. I do have one minor question though. -+- A more useful example is ∃a. Show a = a i.e. ∃a.(a - String, a) So, given a value (f,x) :: ∃a.(a - String, a), we can do f x :: String but that's pretty much all we can do. The type is isomorphic to