[Haskell-beginners] Trouble with liftIO in ReaderT

John Smith voldermort at hotmail.com
Sun Jan 30 15:16:36 CET 2011


I'm trying to attach a handler to a Gtk2Hs event, and get the error:

No instance for (Control.Monad.IO.Class.MonadIO
                    (mtl-1.1.0.2:Control.Monad.Reader.ReaderT (GHC.Ptr.Ptr EAny) IO))
   arising from a use of `liftIO'
Possible fix:
   add an instance declaration for
   (Control.Monad.IO.Class.MonadIO
      (mtl-1.1.0.2:Control.Monad.Reader.ReaderT (GHC.Ptr.Ptr EAny) IO))

This occurs with the sample at http://www.haskell.org/haskellwiki/Gtk2Hs/Tutorials/Intro

import Graphics.UI.Gtk
import Control.Monad.Trans(liftIO)

main = do
   initGUI
   window <- windowNew
   window `on` deleteEvent $ liftIO mainQuit >> return False
   -- i.e., on window deleteEvent (liftIO mainQuit >> return False)
   widgetShow window
   mainGUI

Why can't GHC find the instance MonadIO m => MonadIO (ReaderT r m)?




More information about the Beginners mailing list