
The problem is that Exception is a class. You should use SomeException,
which is a type!
On Tue, May 12, 2009 at 13:27, 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.h...
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@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc.