Opened 3 years ago

Closed 3 years ago

#10429 closed bug (invalid)

GHC fails to import instance

Reported by: crockeea Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The following code compiles in 7.8.4 but fails to compile in 7.10.1.

Tagged.hs

module Tagged where
import Control.Monad.Trans
newtype TaggedT s m b = TagT (m b)
instance MonadTrans (TaggedT s)

Main.hs

import Control.Monad.Trans.Class
import Tagged

returnT :: (MonadTrans t) 
        => t m a -> t m a
returnT a = undefined

f :: TaggedT Int m a -> TaggedT Int m a
f = returnT

GHC complains

    Could not deduce (MonadTrans (TaggedT Int))
      arising from a use of ‘returnT’

If I change the import in Main to Control.Monad.Trans, 7.10.1 accepts the program. Since the import Control.Monad.Trans is actually a folder, the class MonadTrans must refer to the definition in Control.Monad.Trans.Class, so GHC should find the instance.

Change History (1)

comment:1 Changed 3 years ago by rwbarton

Resolution: invalid
Status: newclosed

You have two versions of transformers installed under 7.10. See http://www.yesodweb.com/blog/2014/09/woes-multiple-package-versions or search Google for "No instance for MonadTrans" for more information.

Also see #9611 about improving the error message in this case.

Note: See TracTickets for help on using tickets.