Ticket #132 (new defect)

Opened 4 months ago

Last modified 3 weeks ago

MonadTrans instance is not exported

Reported by: m09 Owned by:
Priority: major Milestone:
Version: Keywords:
Cc:

Description

Which mean it's impossible to easily embed IO actions in the InputT m Monad:

{-# LANGUAGE UnicodeSyntax #-}

import           Control.Monad.Trans
import           Data.Array.IO
import           System.Console.Haskeline

type Board = IOArray Int Int

problem ∷ Board → IO Int
problem board = runInputT defaultSettings . lift $ readArray board 1

main ∷ IO ()
main = (newArray (0, 3) 42 ∷ IO Board) >> return ()

-- [1 of 1] Compiling Main             ( main.hs, main.o )
-- 
-- main.hs:13:7:
--     No instance for (MonadTrans InputT) arising from a use of `lift'
--     Possible fix: add an instance declaration for (MonadTrans InputT)
--     In the expression: lift
--     In a stmt of a 'do' block: lift $ readArray board 1
--     In the expression: do { lift $ readArray board 1 }

Change History

follow-up: ↓ 2   Changed 3 months ago by judah

Sorry for the delay in response. This works for me with ghc-7.6.1 and haskeline-0.7.1.2. Which version are you using of ghc and of the haskeline, mtl and transformers packages? (You can use ghc-pkg list to see which packages you have installed.)

Are you using mtl-1.*? Haskeline uses the transformers package, so you need to install a more recent version of mtl that's compatible with transformers (I believe >=2.0 would suffice.) Please let me know whether that solves the problem for you.

in reply to: ↑ 1   Changed 3 weeks ago by MichaelBurge

Hey,

I ran into this same issue and updating my mtl to 2.2 solved it.

Note: See TracTickets for help on using tickets.