Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-13 Thread Donn Cave
On Mar 12, 2008, at 11:23 PM, Luke Palmer wrote: The issue is that exception handling semantics do induce an order of evaluation for determinacy: if both functions in a composition throw an exception at some point (say in the 3rd element of a list they're generating), you need to decide which

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Henning Thielemann
On Wed, 12 Mar 2008, Donn Cave wrote: On Mar 12, 2008, at 2:10 PM, Henning Thielemann wrote: On Wed, 12 Mar 2008, Donn Cave wrote: On Mar 12, 2008, at 12:32 PM, Brandon S. Allbery KF8NH wrote: On Mar 12, 2008, at 14:17 , Donn Cave wrote: Sure. It isn't a lot of code, so I subjected it t

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Luke Palmer
On Wed, Mar 12, 2008 at 4:45 PM, Donn Cave <[EMAIL PROTECTED]> wrote: > Well, the problem inherently requires a certain order of > evaluation. But if you will just handle pattern match failure > in the IO monad, then you can write a simple functional > expression of the problem instead, > >

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Donn Cave
On Mar 12, 2008, at 2:10 PM, Henning Thielemann wrote: On Wed, 12 Mar 2008, Donn Cave wrote: On Mar 12, 2008, at 12:32 PM, Brandon S. Allbery KF8NH wrote: On Mar 12, 2008, at 14:17 , Donn Cave wrote: Sure. It isn't a lot of code, so I subjected it to Either-ization as an experiment, and I

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Henning Thielemann
On Wed, 12 Mar 2008, Donn Cave wrote: On Mar 12, 2008, at 12:32 PM, Brandon S. Allbery KF8NH wrote: On Mar 12, 2008, at 14:17 , Donn Cave wrote: Sure. It isn't a lot of code, so I subjected it to Either-ization as an experiment, and I did indeed take the monad procedural route. Monad !=

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Donn Cave
On Mar 12, 2008, at 12:32 PM, Brandon S. Allbery KF8NH wrote: On Mar 12, 2008, at 14:17 , Donn Cave wrote: Sure. It isn't a lot of code, so I subjected it to Either-ization as an experiment, and I did indeed take the monad procedural route. Monad != procedural, unless you insist on do not

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Brandon S. Allbery KF8NH
On Mar 12, 2008, at 14:17 , Donn Cave wrote: Sure. It isn't a lot of code, so I subjected it to Either-ization as an experiment, and I did indeed take the monad procedural route. Monad != procedural, unless you insist on do notation. Think of it as composition (it may be easier to use (=<

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Donn Cave
On Mar 12, 2008, at 6:34 AM, Brandon S. Allbery KF8NH wrote: On Mar 11, 2008, at 14:27 , Donn Cave wrote: readLDAPMessage s = let [(_, msgID), (tag, body)] = berList s in LDAPMessage (berInt msgID) (readResponse tag body) I go on to account for all the LDAP stuff I need in about

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Brandon S. Allbery KF8NH
On Mar 11, 2008, at 14:27 , Donn Cave wrote: readLDAPMessage s = let [(_, msgID), (tag, body)] = berList s in LDAPMessage (berInt msgID) (readResponse tag body) I go on to account for all the LDAP stuff I need in about 60 lines of that kind of thing, 1/3 of it devoted to declaration

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Henning Thielemann
On Tue, 11 Mar 2008, Donn Cave wrote: On Mar 10, 2008, at 5:48 PM, Jonathan Cast wrote: On 10 Mar 2008, at 12:37 AM, Donn Cave wrote: ... An exception is, for me, any state that isn't properly accounted for in its immediate context. openFile could return 'Maybe Handle', but it doesn't,

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-12 Thread Donn Cave
On Mar 10, 2008, at 5:48 PM, Jonathan Cast wrote: On 10 Mar 2008, at 12:37 AM, Donn Cave wrote: ... An exception is, for me, any state that isn't properly accounted for in its immediate context. openFile could return 'Maybe Handle', but it doesn't, so the context demands a Handle or a

[Haskell-cafe] Exception handling when using STUArray

2008-03-11 Thread oleg
Sterling Clover wrote: > there's no standard way that I know of besides "inspection" to > determine if code might throw an exception, and this is particularly > the case with the dreaded lazy IO of prelude functions. The following old message showed even two ways of doing exactly that -- in Haske

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-10 Thread Jonathan Cast
On 10 Mar 2008, at 12:37 AM, Donn Cave wrote: On Mar 9, 2008, at 1:07 PM, Henning Thielemann wrote: Errors are programming errors and must be fixed as Denis explained. Thus there is no need for a complex system of handling these situations at run-time. The program error might be unexpect

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-10 Thread Henning Thielemann
On Mon, 10 Mar 2008, Donn Cave wrote: On Mar 9, 2008, at 1:07 PM, Henning Thielemann wrote: How precisely would you handle IndexError if it would be an exception and not just an error? Well, to take a hypothetical example ... I have never looked into JPEG image decoding, but suppose that it

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-10 Thread Luke Palmer
On Mon, Mar 10, 2008 at 7:37 AM, Donn Cave <[EMAIL PROTECTED]> wrote: > > On Mar 9, 2008, at 1:07 PM, Henning Thielemann wrote: > > > > > Errors are programming errors and must be fixed as Denis explained. > > Thus > > there is no need for a complex system of handling these situations at > >

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-10 Thread Donn Cave
On Mar 9, 2008, at 1:07 PM, Henning Thielemann wrote: Errors are programming errors and must be fixed as Denis explained. Thus there is no need for a complex system of handling these situations at run-time. The program error might be unexpected but it isn't the fault of the user or of th

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-09 Thread Henning Thielemann
On Sat, 8 Mar 2008, Donn Cave wrote: > On Mar 8, 2008, at 12:33 PM, Henning Thielemann wrote: > > > On Sat, 8 Mar 2008, Denis Bueno wrote: > ... > >> I am also using STUArray from some time-critical code; however, I > >> don't deal with ArrayException, or any exceptions for that matter. > >> What

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-09 Thread Don Stewart
donn: > > On Mar 8, 2008, at 10:54 PM, Don Stewart wrote: > > [... replying to my poorly informed rant about exceptions ... ] > > > > >I don't understand this complaint -- you can handle all these with > >Control.Exception. > > > >xmonad catches all these things for example, in user code, to p

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-09 Thread Donn Cave
On Mar 8, 2008, at 10:54 PM, Don Stewart wrote: [... replying to my poorly informed rant about exceptions ... ] I don't understand this complaint -- you can handle all these with Control.Exception. xmonad catches all these things for example, in user code, to prevent poorly written module

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Sterling Clover
On the other hand, there are lots of issues that can be worked on here, foax! While tools like the one is ndm is working on seem to offer a way forward, at the moment, there's no standard way that I know of besides "inspection" to determine if code might throw an exception, and this is par

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Brandon S. Allbery KF8NH
On Mar 9, 2008, at 1:54 , Don Stewart wrote: donn: This seems to me one of the disappointments of Haskell - not just a detail that was handled in an awkward way, but a fundamental flaw. I'm not talking about ArrayException, whatever that is, but the notion that errors encountered in functi

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Don Stewart
donn: > > On Mar 8, 2008, at 12:33 PM, Henning Thielemann wrote: > > >On Sat, 8 Mar 2008, Denis Bueno wrote: > ... > >>I am also using STUArray from some time-critical code; however, I > >>don't deal with ArrayException, or any exceptions for that matter. > >>What besides an out-of-bounds read or

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Donn Cave
On Mar 8, 2008, at 12:33 PM, Henning Thielemann wrote: On Sat, 8 Mar 2008, Denis Bueno wrote: ... I am also using STUArray from some time-critical code; however, I don't deal with ArrayException, or any exceptions for that matter. What besides an out-of-bounds read or write might throw an Arr

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Henning Thielemann
On Sat, 8 Mar 2008, Denis Bueno wrote: On Sat, Mar 8, 2008 at 12:29 AM, Xiao-Yong Jin <[EMAIL PROTECTED]> wrote: I'm using STUArray in some of my time critical number crunching code. I would like to know some way to catch the exceptions raised in the ST monad, ie. ArrayException. I am al

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Xiao-Yong Jin
"Denis Bueno" <[EMAIL PROTECTED]> writes: > On Sat, Mar 8, 2008 at 9:54 AM, Xiao-Yong Jin <[EMAIL PROTECTED]> wrote: >> > ArrayException? If it is out-of-bounds reading or writing, surely >> > that indicates a bug in your program that you'd rather fix than catch >> > the exception, no? >> >>

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Denis Bueno
On Sat, Mar 8, 2008 at 9:54 AM, Xiao-Yong Jin <[EMAIL PROTECTED]> wrote: > > ArrayException? If it is out-of-bounds reading or writing, surely > > that indicates a bug in your program that you'd rather fix than catch > > the exception, no? > > In my case, because I choose a index of the array

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Xiao-Yong Jin
"Denis Bueno" <[EMAIL PROTECTED]> writes: > On Sat, Mar 8, 2008 at 12:29 AM, Xiao-Yong Jin <[EMAIL PROTECTED]> wrote: >> I'm using STUArray in some of my time critical number >> crunching code. I would like to know some way to catch the >> exceptions raised in the ST monad, ie. ArrayException.

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-08 Thread Denis Bueno
On Sat, Mar 8, 2008 at 12:29 AM, Xiao-Yong Jin <[EMAIL PROTECTED]> wrote: > I'm using STUArray in some of my time critical number > crunching code. I would like to know some way to catch the > exceptions raised in the ST monad, ie. ArrayException. I am also using STUArray from some time-critic

[Haskell-cafe] Exception handling when using STUArray

2008-03-07 Thread Xiao-Yong Jin
Dear list, I'm using STUArray in some of my time critical number crunching code. I would like to know some way to catch the exceptions raised in the ST monad, ie. ArrayException. Looking through the Control.Exception module, I understand that those functions can only be used within IO monad. So