Skip to content

Typeable solver has strange effects

Given:

import Data.Typeable

main = print $ foo $ Just ()

foo :: Typeable (t a) => t a -> String
foo x = let k = show $ typeOf x in k

I get:

TypeableInfer.hs:7:24:
    Could not deduce (Typeable t) arising from a use of `typeOf'
    from the context (Typeable (t a))
      bound by the type signature for
                 foo :: Typeable (t a) => t a -> String
      at TypeableInfer.hs:6:8-38
    In the second argument of `($)', namely `typeOf x'
    In the expression: show $ typeOf x
    In an equation for `k': k = show $ typeOf x

However, the error goes away with the minor modification of:

foo x = show $ typeOf x
Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ndmitchell@gmail.com
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information