[Haskell-beginners] The main thread and waiting for other threads
Quentin Moser
quentin.moser at unifr.ch
Wed May 13 02:47:41 EDT 2009
As Daniel Fischer already wrote, this is due to an API change in GHC
6.10. But the old exceptions interface is still available as
Control.OldException; you can simply import that instead of
Control.Exception.
On Tue, 12 May 2009 12:27:06 -0400
Thomas Friedrich <info at suud.de> wrote:
> 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".
>
> -- file: ch24/NiceFork.hs
> import Control.Concurrent
> import Control.Exception (Exception, try)
> import qualified Data.Map as M
>
> data ThreadStatus = Running
> | Finished -- terminated normally
> | Threw Exception -- killed by uncaught exception
> deriving (Eq, Show)
>
> -- | Create a new thread manager.
> newManager :: IO ThreadManager
>
> -- | Create a new managed thread.
> forkManaged :: ThreadManager -> IO () -> IO ThreadId
>
> -- | Immediately return the status of a managed thread.
> getStatus :: ThreadManager -> ThreadId -> IO (Maybe ThreadStatus)
>
> -- | Block until a specific managed thread terminates.
> waitFor :: ThreadManager -> ThreadId -> IO (Maybe ThreadStatus)
>
> -- | Block until all managed threads terminate.
> waitAll :: ThreadManager -> IO ()
>
> 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.
>
>
> Any idea on how to solve this? Exception is a class not a type, so
> what to put there instead?
>
> Cheers,
> Thomas
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
More information about the Beginners
mailing list