Re: [Haskell-cafe] forall ST monad

2009-02-25 Thread Kim-Ee Yeoh
Heinrich Apfelmus wrote: Now, (forall a. T[a]) - S is clearly true while exists a. (T[a] - S) should be nonsense: having one example of a marble that is either red or blue does in no way imply that all of them are, at least constructively. (It is true classically, but I

Re: [Haskell-cafe] forall ST monad

2009-02-25 Thread Jonathan Cast
On Wed, 2009-02-25 at 10:18 -0800, Kim-Ee Yeoh wrote: Heinrich Apfelmus wrote: Now, (forall a. T[a]) - S is clearly true while exists a. (T[a] - S) should be nonsense: having one example of a marble that is either red or blue does in no way imply that all of

Re: [Haskell-cafe] forall ST monad

2009-02-23 Thread Ryan Ingram
On Fri, Feb 20, 2009 at 11:33 AM, Kim-Ee Yeoh a.biurvo...@asuhan.com wrote: Here's a counterexample, regardless of whether you're using constructive or classical logic, that (forall a. T[a]) - T' does not imply exists a. (T[a] - T'). Let a not exist, but T' true. Done. That isn't quite a

Re: [Haskell-cafe] forall ST monad

2009-02-20 Thread Kim-Ee Yeoh
Wolfgang Jeltsch-2 wrote: Am Montag, 16. Februar 2009 19:22 schrieb Wolfgang Jeltsch: First, I thought so too but I changed my mind. To my knowledge a type (forall a. T[a]) - T' is equivalent to the type exists a. (T[a] - T'). It’s the same as in predicate logic – Curry-Howard in action.

Re: [Haskell-cafe] forall ST monad

2009-02-19 Thread Kim-Ee Yeoh
Jonathan Cast-2 wrote: Summary: Existential types are not enough for ST. You need the rank 2 type, to guarantee that *each* application of runST may (potentially) work with a different class of references. (A different state thread). Interesting. What's going on in the example that

Re: [Haskell-cafe] forall ST monad

2009-02-19 Thread Dan Doel
On Thursday 19 February 2009 7:22:48 am Kim-Ee Yeoh wrote: Jonathan Cast-2 wrote: Summary: Existential types are not enough for ST. You need the rank 2 type, to guarantee that *each* application of runST may (potentially) work with a different class of references. (A different state

Re: [Haskell-cafe] forall ST monad

2009-02-19 Thread Kim-Ee Yeoh
There's a lot to chew on (thank you!), but I'll just take something I can handle for now. Dan Doel wrote: An existential: exists a:T. P(a) is a pair of some a with type T and a proof that a satisfies P (which has type P(a)). In Haskell, T is some kind, and P(a) is some type

Re: [Haskell-cafe] forall ST monad

2009-02-19 Thread Derek Elkins
On Thu, 2009-02-19 at 05:53 -0800, Kim-Ee Yeoh wrote: There's a lot to chew on (thank you!), but I'll just take something I can handle for now. Dan Doel wrote: An existential: exists a:T. P(a) is a pair of some a with type T and a proof that a satisfies P (which has

Re: [Haskell-cafe] forall ST monad

2009-02-19 Thread Kim-Ee Yeoh
Jonathan Cast-2 wrote: Taking the `let open' syntax from `First-class Modules for Haskell' [1], we can say let open runST' = runST in let ref = runST' $ newSTRef 0 !() = runST' $ writeSTRef ref 1 !() = runST' $ writeSTRef ref 2 in runST' $ readSTRef ref This

Re: [Haskell-cafe] forall ST monad

2009-02-16 Thread Wolfgang Jeltsch
Am Sonntag, 15. Februar 2009 17:50 schrieb Peter Verswyvelen: I'm having trouble understanding the explanation of the meaning of the signature of runST Were you just reading the documentation of Grapefruit’s era parameters or why are you studying ST? ;-) Best wishes, Wolfgang

Re: [Haskell-cafe] forall ST monad

2009-02-16 Thread Peter Verswyvelen
Aha! Wolfgang is a man who knows his own code :) Yes, I've seen this a couple of times but when I saw it again in Grapefruit, I wanted to know how this usage of existentials worked, since I'm sooo curious to find out how you managed to use the type system for solving some of the typical FRP

Re: [Haskell-cafe] forall ST monad

2009-02-16 Thread Wolfgang Jeltsch
Am Montag, 16. Februar 2009 14:21 schrieben Sie: Aha! Wolfgang is a man who knows his own code :) Yes, I've seen this a couple of times but when I saw it again in Grapefruit, I wanted to know how this usage of existentials worked, since I'm sooo curious to find out how you managed to use the

Re: [Haskell-cafe] forall ST monad

2009-02-16 Thread Kim-Ee Yeoh
Peter Verswyvelen-2 wrote: I'm having trouble understanding the explanation of the meaning of the signature of runST at http://en.wikibooks.org/wiki/Haskell/Existentially_quantified_types I could try to read the article a couple of times again, but are there any other good readings

Re: [Haskell-cafe] forall ST monad

2009-02-16 Thread Wolfgang Jeltsch
Am Montag, 16. Februar 2009 19:04 schrieb Kim-Ee Yeoh: Despite its rank-2 type, runST really doesn't have anything to do with existential quantification. First, I thought so too but I changed my mind. To my knowledge a type (forall a. T[a]) - T' is equivalent to the type exists a. (T[a] - T').

Re: [Haskell-cafe] forall ST monad

2009-02-16 Thread Wolfgang Jeltsch
Am Montag, 16. Februar 2009 19:22 schrieb Wolfgang Jeltsch: Am Montag, 16. Februar 2009 19:04 schrieb Kim-Ee Yeoh: Despite its rank-2 type, runST really doesn't have anything to do with existential quantification. First, I thought so too but I changed my mind. To my knowledge a type

Re: [Haskell-cafe] forall ST monad

2009-02-16 Thread Kim-Ee Yeoh
Correct. And under the hood, GHC does implement runST in its existential dual form using a hidden State# type. I wonder however, if we're wandering too far away from the OP's query about grokking runST and how the ST monad works. I'd imagine that means he'd like to see how rank-2 polymorphism

Re: [Haskell-cafe] forall ST monad

2009-02-16 Thread Jonathan Cast
On Mon, 2009-02-16 at 19:36 +0100, Wolfgang Jeltsch wrote: Am Montag, 16. Februar 2009 19:22 schrieb Wolfgang Jeltsch: Am Montag, 16. Februar 2009 19:04 schrieb Kim-Ee Yeoh: Despite its rank-2 type, runST really doesn't have anything to do with existential quantification. First, I

[Haskell-cafe] forall ST monad

2009-02-15 Thread Peter Verswyvelen
I'm having trouble understanding the explanation of the meaning of the signature of runST at http://en.wikibooks.org/wiki/Haskell/Existentially_quantified_types I could try to read the article a couple of times again, but are there any other good readings about these existentially quantified

Re: [Haskell-cafe] forall ST monad

2009-02-15 Thread Brandon S. Allbery KF8NH
On 2009 Feb 15, at 11:50, Peter Verswyvelen wrote: I could try to read the article a couple of times again, but are there any other good readings about these existentially quantified types and how the ST monad works? You could think about it as playing a dirty trick on the typechecker.

Re: [Haskell-cafe] forall ST monad

2009-02-15 Thread Kim-Ee Yeoh
Peter Verswyvelen-2 wrote: I could try to read the article a couple of times again, but are there any other good readings about these existentially quantified types and how the ST monad works? The primary source is if I'm not mistaken, the following State in Haskell paper:

Re: [Haskell-cafe] forall ST monad

2009-02-15 Thread Ryan Ingram
On Sun, Feb 15, 2009 at 11:50 AM, Kim-Ee Yeoh a.biurvo...@asuhan.com wrote: Having said that, I'm not sure about the statement on page 9 that readVar v simply does not have type forall s. ST s Bool. The variable v could be of type forall s. MutVar s Bool, in which case all of runST (readVar v)

Re: [Haskell-cafe] forall ST monad

2009-02-15 Thread Henning Thielemann
Peter Verswyvelen schrieb: I'm having trouble understanding the explanation of the meaning of the signature of runST at http://en.wikibooks.org/wiki/Haskell/Existentially_quantified_types Is this one better http://haskell.org/haskellwiki/Monad/ST ?

Re: [Haskell-cafe] forall ST monad

2009-02-15 Thread Luke Palmer
2009/2/15 Brandon S. Allbery KF8NH allb...@ece.cmu.edu On 2009 Feb 15, at 11:50, Peter Verswyvelen wrote: I could try to read the article a couple of times again, but are there any other good readings about these existentially quantified types and how the ST monad works? You could think