timothyhobbs | 7 Nov 21:36 2012
Picon

Where is the documentation on exception types kept?

Hello,
I am trying to catch an "thread blocked on MVar indefinitely exception."  Of course I can use ::SomeException as explained in http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception.html#g:3 but there is no explanation as to how to find the more case specific exceptions.  http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-MVar.html#t:MVar does not discuss exceptions at all!  Indeed, I don't know of any haddock pages that include descriptions of exception types :( :O

Thanks,
Timothy
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Simon Hengel | 7 Nov 21:53 2012
Picon

Re: Where is the documentation on exception types kept?

Hi,

> I am trying to catch an "thread blocked on MVar indefinitely exception."  Of
> course I can use ::SomeException as explained in http://hackage.haskell.org/
> packages/archive/base/latest/doc/html/Control-Exception.html#g:3 but there 
> is no explanation as to how to find the more case specific exceptions.  
> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-
> Concurrent-MVar.html#t:MVar does not discuss exceptions at all!  Indeed, I 
> don't know of any haddock pages that include descriptions of exception types
> :( :O

In this particular case it's easy:

http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/Control-Exception.html#t:BlockedIndefinitelyOnMVar

But in general, figuring out the exception type is not straight forward.
Personally, I think an uncaught exception should print the type of that
exception (e.g. use a derived show instance).  But most of them have a
show instance that is useful for end-users.

The upcoming 1.4.0 release of Hspec will print the type of uncaught
exceptions in test cases.  So if you are into BDD/TDD that might be
useful;)

Cheers,
Simon
timothyhobbs | 7 Nov 22:03 2012
Picon

Re: Where is the documentation on exception types kept?

I really like to be able to find these things in documentation and if not documentation than source code.  However thank you for your reply, in this case it has helped me :)

Timothy


---------- Původní zpráva ----------
Od: Simon Hengel <sol <at> typeful.net>
Datum: 7. 11. 2012
Předmět: Re: [Haskell-cafe] Where is the documentation on exception types kept?

Hi,

> I am trying to catch an "thread blocked on MVar indefinitely exception."  Of
> course I can use ::SomeException as explained in http://hackage.haskell.org/
> packages/archive/base/latest/doc/html/Control-Exception.html#g:3 but there
> is no explanation as to how to find the more case specific exceptions. 
> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-
> Concurrent-MVar.html#t:MVar does not discuss exceptions at all!  Indeed, I
> don't know of any haddock pages that include descriptions of exception types
> :( :O

In this particular case it's easy:

http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/Control-Exception.html#t:BlockedIndefinitelyOnMVar

But in general, figuring out the exception type is not straight forward.
Personally, I think an uncaught exception should print the type of that
exception (e.g. use a derived show instance). But most of them have a
show instance that is useful for end-users.

The upcoming 1.4.0 release of Hspec will print the type of uncaught
exceptions in test cases. So if you are into BDD/TDD that might be
useful;)

Cheers,
Simon
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Albert Y. C. Lai | 7 Nov 22:08 2012
Picon

Re: Where is the documentation on exception types kept?

On 12-11-07 03:36 PM, timothyhobbs <at> seznam.cz wrote:
> I am trying to catch an "thread blocked on MVar indefinitely
> exception."  Of course I can use ::SomeException as explained in
> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception.html#g:3
> but there is no explanation as to how to find the more case specific
> exceptions.

In general, because Exception instances are Typeable instances, you can 
get a name, and then you can use that for searches.

import Control.Exception
import Data.Typeable

main = do
   aida <- try (readFile "no")
   case aida of
     Left (SomeException e) -> print (typeOf e)
timothyhobbs | 7 Nov 23:19 2012
Picon

Re: Where is the documentation on exception types kept?

Thanks!  That is a neat way.  At least for exceptions which I know to exists and know how to trigger ;)

Tim


---------- Původní zpráva ----------
Od: Albert Y. C. Lai <trebla <at> vex.net>
Datum: 7. 11. 2012
Předmět: Re: [Haskell-cafe] Where is the documentation on exception types kept?

On 12-11-07 03:36 PM, timothyhobbs <at> seznam.cz wrote:
> I am trying to catch an "thread blocked on MVar indefinitely
> exception." Of course I can use ::SomeException as explained in
> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception.html#g:3
> but there is no explanation as to how to find the more case specific
> exceptions.

In general, because Exception instances are Typeable instances, you can
get a name, and then you can use that for searches.

import Control.Exception
import Data.Typeable

main = do
aida <- try (readFile "no")
case aida of
Left (SomeException e) -> print (typeOf e)

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane