Puzzling (to me) type error message

Colin Adams colinpauladams at googlemail.com
Tue Mar 24 04:00:10 EDT 2009

I'm trying out concurrent haskell (never mind that the code isn't
actually very concurrent - I'm just trying to get things to compile

So with the following code, I get:

play_move :: IORef Game_state -> IO ()
play_move game_state_ior = do
 (_, state, _) <- readIORef game_state_ior
 putStr "Playing AI: "
 start_time <- getCurrentTime
 ai_in_channel <- newChan
 ai_out_channel <- newChan
 writeChan ai_in_channel state
 ai_thread_id <- forkIO (run_ai ai_in_channel ai_out_channel)
 move <- readChan ai_out_channel
 end_time <- move `seq` (modifyIORef game_state_ior $!
                                    update_interactive_from_move move)
>> getCurrentTime
 putStrLn $ show $ (diffUTCTime end_time start_time)

run_ai :: Chan Non_interactive_state -> Chan Move.Move -> IO ()
run_ai in_channel out_channel = do
  state <- readChan in_channel
  let move = recommended_move state
  writeChan out_channel move

UI.hs:625:45: Not in scope: type constructor or class `Move.Move'

If I then comment-out the type signature for run_ai, it compiles fine
with the following warning message:

    Warning: Definition but no type signature for `run_ai'
             Inferred type: run_ai :: Chan Non_interactive_state
                                      -> Chan Move.Move
                                      -> IO ()

Ghc 6.10.1 on Mac OS X.

What is going on?

More information about the Glasgow-haskell-users mailing list