Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-11 Thread Roman Cheplyaka
* Günther Schmidt gue.schm...@web.de [2010-06-11 01:22:27+0200] there is nothing wrong with ifs as such except the won't actually exit a long piece of code, the computation will continue, just in a useless way. Can you clarify? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-11 Thread Christopher Done
On 11 June 2010 10:12, Roman Cheplyaka r...@ro-che.info wrote: * Günther Schmidt gue.schm...@web.de [2010-06-11 01:22:27+0200] there is nothing wrong with ifs as such except the won't actually exit a long piece of code, the computation will continue, just in a useless way. Can you clarify?

Re[2]: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-11 Thread Bulat Ziganshin
Hello Christopher, Friday, June 11, 2010, 4:06:05 PM, you wrote: do if x then return () else do bar; continueComputation i format it this way: if x then return () else do bar continueComputation -- Best regards, Bulat

Re: Re[2]: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-11 Thread Christopher Done
On 11 June 2010 14:27, Bulat Ziganshin bulat.zigans...@gmail.com wrote: i format it this way: if x then return () else do bar continueComputation That's a nice way of formatting! God bless optional formatting! I like this problem-specific indentation. Another is: if xthen foo else

Re[4]: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-11 Thread Bulat Ziganshin
Hello Christopher, Friday, June 11, 2010, 4:35:00 PM, you wrote: if xthen foo else if y then bar else if z then mu else zot case () of _ | x - foo | y - bar | otherwise - zor it's usually considered as haskell way of doing this -- Best regards, Bulat

Re: Re[4]: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-11 Thread Christopher Done
On 11 June 2010 14:40, Bulat Ziganshin bulat.zigans...@gmail.com wrote: if x        then foo else if y then bar else if z then mu else             zot case () of  _ | x - foo   | y - bar   | otherwise - zor it's usually considered as haskell way of doing this The example is merely to

[Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Günther Schmidt
Hi everyone, I'm about to write a rather lengthy piece of IO code. Depending on the results of some of the IO actions I'd like the computation to stop right there and then. Now I know in general how to write this but I'm wondering if this is one of those occasions where I should make use of

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Job Vranish
Yeah I don't see why not. The ContT monad should work great. Also, depending on what you're doing, the ErrorT monad might do what you want as well. - Job 2010/6/10 Günther Schmidt gue.schm...@web.de Hi everyone, I'm about to write a rather lengthy piece of IO code. Depending on the results

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread aditya siram
I have a general question about this kind of approach. Tutorials on continuations in Haskell always come with a warning about not using it unless you have to because it makes code unreadable and unmaintainable. Is this true in your opinion? -deech On 6/10/10, Job Vranish job.vran...@gmail.com

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Tim Wawrzynczak
Günther, This is definitely one way to do it. If you want to be able to quit the IO action in the middle of a lengthy computation, that is one way that I, personally, find very straightfoward. You can find an example of this in my Advgame package on Hackage, which uses this method to quit

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Lennart Augustsson
I would not use the continuation monad just for early exit. Sounds like the error monad to me. 2010/6/10 Günther Schmidt gue.schm...@web.de: Hi everyone, I'm about to write a rather lengthy piece of IO code. Depending on the results of some of the IO actions I'd like the computation to stop

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Christopher Done
2010/6/10 Günther Schmidt gue.schm...@web.de: Hi everyone, I'm about to write a rather lengthy piece of IO code. Depending on the results of some of the IO actions I'd like the computation to stop right there and then. What's wrong with a mere if/else condition? foo = do bar x - mu

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Tim Wawrzynczak
Actually, on second thought, Lennart is probably right. Continuations are probably overkill for this situation. Since not wanting to continue is probably an 'erroneous condition,' you may as well use Error. Cheers, - Tim 2010/6/10 Lennart Augustsson lenn...@augustsson.net I would not use the

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Günther Schmidt
Hi Christopher, there is nothing wrong with ifs as such except the won't actually exit a long piece of code, the computation will continue, just in a useless way. Primarily for every if I need two forks, so at every if the branches double. I have written the previous code with ifs and it's

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Yitzchak Gale
Lennart Augustsson wrote: I would not use the continuation monad just for early exit.  Sounds like the error monad to me. I.e., the Either/ErrorT monad. But the mtl/transformers packages have an orphan instance for Either that requires the exit type to be an instance of the Error class. If that

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Derek Elkins
Or... one could just use the exceptions that are already built into the IO monad... 2010/6/10 Yitzchak Gale g...@sefer.org: Lennart Augustsson wrote: I would not use the continuation monad just for early exit.  Sounds like the error monad to me. I.e., the Either/ErrorT monad. But the

Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?

2010-06-10 Thread Jason Dagit
On Thu, Jun 10, 2010 at 8:45 PM, Derek Elkins derek.a.elk...@gmail.comwrote: Or... one could just use the exceptions that are already built into the IO monad... It feels to me like this discussion has a lot of speculation in it. I would like to see concrete examples of the code and the