[Haskell-beginners] The main thread and waiting for other threads
Daniel Fischer
daniel.is.fischer at web.de
Tue May 12 17:57:15 EDT 2009
Am Dienstag 12 Mai 2009 18:27:06 schrieb Thomas Friedrich:
> Hi everyone,
>
> I have a problem with the following example in the Real World Haskell
> book, which aims to develop a module for controlling different threads.
> See,
>
> http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.
>html
>
> in the chapter "The main thread and waiting for other threads".
> When I run this through ghci I get the following failure:
>
> [1 of 1] Compiling NiceFork ( NiceFork.hs, interpreted )
>
> NiceFork.hs:17:26:
> Class `Exception' used as a type
> In the type `Exception'
> In the data type declaration for `ThreadStatus'
> Failed, modules loaded: none.
>
The book was written in the times of GHC 6.8.*, when Exception was a type.
In GHC 6.10, it became a class because it was considered a bad idea to catch general
exceptions, one should use adequate handlers for specific exceptions instead.
Of course, that broke some code out there.
>
> Any idea on how to solve this? Exception is a class not a type, so what
> to put there instead?
For those who want to catch general exceptions, there is
data SomeException = forall e . Exception e => SomeException e
in Control.Exception, which should be roughly equivalent to the old Exception type.
So replace Exception with SomeException in ThreadStatus, perhaps insert a few calls to
toException in the appropriate places (the compiler will help you find them) and it should
work.
>
> Cheers,
> Thomas
>
Cheers,
Daniel
More information about the Beginners
mailing list