[GHC] #1454: Confusing or bug: :t and :i don't return same type

GHC trac at galois.com
Fri Aug 17 20:19:04 EDT 2007


#1454: Confusing or bug: :t and :i don't return same type
----------------------------------+-----------------------------------------
    Reporter:  iampure at gmail.com  |        Owner:         
        Type:  bug                |       Status:  closed 
    Priority:  normal             |    Milestone:         
   Component:  GHCi               |      Version:  6.6.1  
    Severity:  normal             |   Resolution:  invalid
    Keywords:                     |   Difficulty:  Unknown
          Os:  Unknown            |     Testcase:         
Architecture:  Unknown            |  
----------------------------------+-----------------------------------------
Changes (by igloo):

  * resolution:  => invalid
  * status:  reopened => closed

Comment:

 Here's a self-contained example:
 {{{
 {-# LANGUAGE UndecidableInstances,
              NoMonomorphismRestriction,
              MultiParamTypeClasses,
              FunctionalDependencies,
              FlexibleContexts,
              FlexibleInstances #-}

 module Foo where

 class (Monad m) => MonadState s m | m -> s where
     get :: m s
     put :: s -> m ()

 data Bar a b = Bar a b

 gget :: (Zork a b m) => m b
 gget = do Bar a b <- get
           return b

 class (MonadState (Bar a b) m) => Zork a b m | m -> a b where
 instance (MonadState (Bar a b) m, Monad m) => Zork a b m where
 }}}

 {{{
 $ ghci z.hs
 GHCi, version 6.7.20070817: http://www.haskell.org/ghc/  :? for help
 Loading package base ... linking ... done.
 [1 of 1] Compiling Foo              ( z.hs, interpreted )
 Ok, modules loaded: Foo.
 *Foo> :i gget
 gget :: (Zork a b m) => m b     -- Defined at z.hs:17:0-3
 *Foo> :t gget
 gget :: (MonadState (Bar a b) m) => m b
 *Foo>
 }}}

 This seems entirely reasonable to me. If you ask for info about the name
 gget then you get the type that you told the compiler it has. If you ask
 the compiler for the type of the expression gget, then when infering the
 type it uses the information from the instances that exist and the fundeps
 to infer the second type.

 Note that if you comment out the type signature then GHC infers the second
 type for gget, and both :i and :t thus give that type:

 {{{
 *Foo> :i gget
 gget :: (MonadState (Bar t1 t2) t) => t t2
         -- Defined at z.hs:17:0-3
 *Foo> :t gget
 gget :: (MonadState (Bar t1 t2) t) => t t2
 *Foo>
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1454>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list