Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-05 Thread Till Mossakowski
Sebastian Sylvan wrote: On 8/4/05, Till Mossakowski [EMAIL PROTECTED] wrote: Remi Turk wrote: MonadState needs multi-parameter type classes, State and StateT don't. And ST needs rank-2 types (or at least one rank-2 constant) and, to be implemented _efficiently_, also needs something like

Re[2]: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-05 Thread Bulat Ziganshin
Hello Till, Friday, August 05, 2005, 10:04:53 AM, you wrote: TMMonadState IOArray IOArray ST TMwithwith with TMFiniteMap unsafePerformIO MutArr TM safe yesyes no

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-05 Thread Till Mossakowski
Bulat Ziganshin wrote: Hello Till, Friday, August 05, 2005, 10:04:53 AM, you wrote: TMMonadState IOArray IOArray ST TMwithwith with TMFiniteMap unsafePerformIO MutArr TM safe yes

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-05 Thread Remi Turk
On Fri, Aug 05, 2005 at 08:04:53AM +0200, Till Mossakowski wrote: Sebastian Sylvan wrote: Hmmm... Wasn't that what he said? I disagree with the equation primitives = unsafe that is implicit in sentence to be implemented _efficiently_, also needs something like unsafePerformIO (or even

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-05 Thread Remi Turk
On Fri, Aug 05, 2005 at 01:13:06PM +0400, Bulat Ziganshin wrote: Hello Till, Friday, August 05, 2005, 10:04:53 AM, you wrote: TMMonadState IOArray IOArray ST TMwithwith with TMFiniteMap

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-05 Thread Wolfgang Jeltsch
Am Freitag, 5. August 2005 08:04 schrieb Till Mossakowski: [...] I disagree with the equation primitives = unsafe that is implicit in sentence to be implemented _efficiently_, also needs something like unsafePerformIO (or even lower-level unsafe mutable state primitives). The point

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-05 Thread Till Mossakowski
Remi Turk wrote: Ah, I think I understand what we're disagreeing about exactly now. We're understanding primitive to mean different things :) You're seeing runST, newSTRef, writeSTRef etc as primitives, is that correct? I see them as the public interface to something which is implemented in

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Axel Simon
On Wed, 2005-08-03 at 12:07 -0500, Srinivas Nedunuri wrote: I was wondering what advice folks had. In particular, what are the disadvantages to doing everything in the IO monad - ie why even bother with the ST monad? The most obvious disadvantage is that the IO monad has no

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Wolfgang Jeltsch
Am Mittwoch, 3. August 2005 19:07 schrieb Srinivas Nedunuri: [...] I have a bunch of ST code, and then somewhere in there I had the misfortune of needing to insert a file copy and bam I'm now stuck with the dang IO monad which goes and infects the entire program. You can use something like

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Wolfgang Jeltsch
Am Donnerstag, 4. August 2005 10:21 schrieb Axel Simon: [...] Nowadays, you can use one of the MonadState monad State transformer monads like State and StateT can be implemented without using special language features. So there was always the opportunity to implement something like State or

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Axel Simon
On Thu, 2005-08-04 at 10:58 +0200, Wolfgang Jeltsch wrote: Am Donnerstag, 4. August 2005 10:21 schrieb Axel Simon: [...] Nowadays, you can use one of the MonadState monad State transformer monads like State and StateT can be implemented without using special language features. So

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Pedro Vasconcelos
On Thu, 04 Aug 2005 10:09:06 +0100 Axel Simon [EMAIL PROTECTED] wrote: Ok, granted. In particular I take your point about array accesses. However, I am not quite convinced that using ST has any advantages over using IO directly. Of course, one could claim that programmers wants to protect

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Wolfgang Jeltsch
Am Donnerstag, 4. August 2005 11:09 schrieben Sie: On Thu, 2005-08-04 at 10:58 +0200, Wolfgang Jeltsch wrote: Am Donnerstag, 4. August 2005 10:21 schrieb Axel Simon: [...] Nowadays, you can use one of the MonadState monad State transformer monads like State and StateT can be

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Remi Turk
On Thu, Aug 04, 2005 at 10:09:06AM +0100, Axel Simon wrote: On Thu, 2005-08-04 at 10:58 +0200, Wolfgang Jeltsch wrote: Am Donnerstag, 4. August 2005 10:21 schrieb Axel Simon: [...] Nowadays, you can use one of the MonadState monad State transformer monads like State and StateT can

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Till Mossakowski
Remi Turk wrote: MonadState needs multi-parameter type classes, State and StateT don't. And ST needs rank-2 types (or at least one rank-2 constant) and, to be implemented _efficiently_, also needs something like unsafePerformIO (or even lower-level unsafe mutable state primitives). I think

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Sebastian Sylvan
On 8/4/05, Till Mossakowski [EMAIL PROTECTED] wrote: Remi Turk wrote: MonadState needs multi-parameter type classes, State and StateT don't. And ST needs rank-2 types (or at least one rank-2 constant) and, to be implemented _efficiently_, also needs something like unsafePerformIO (or even

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-04 Thread Remi Turk
On Thu, Aug 04, 2005 at 10:40:01PM +0200, Till Mossakowski wrote: Remi Turk wrote: MonadState needs multi-parameter type classes, State and StateT don't. And ST needs rank-2 types (or at least one rank-2 constant) and, to be implemented _efficiently_, also needs something like unsafePerformIO

[Haskell] Re: ST/STRef vs. IO/IORef

2005-08-03 Thread Srinivas Nedunuri
Cale Gibbard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Well, what to do with your computation depends on what that computation is actually doing. Is the IO really critical to your algorithm, or can it be done separately? Remember that pure computation is lazy and so you can save

[Haskell] Re: ST/STRef vs. IO/IORef

2005-08-03 Thread Srinivas Nedunuri
Glynn Clements [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Srinivas Nedunuri wrote: Hello, I have some code that manipulates STRefs within the ST monad. All good and fine, until I come across some computation that uses lets say IO and everything skids to a halt. At this

Re: [Haskell] Re: ST/STRef vs. IO/IORef

2005-08-03 Thread Iavor Diatchki
Hello, On 8/3/05, Srinivas Nedunuri [EMAIL PROTECTED] wrote: The most obvious disadvantage is that the IO monad has no equivalent of runST. OK, I'm missing something here. What is the big deal about runST? Can I not get the IO equivalent by simply running the program at the top level