Skip to content

inferred type of an implicit parameter rejected (associated type)

The following module:

{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoMonomorphismRestriction #-}

module Test where

class C t where
    type TF t
    ttt :: TF t -> t

b :: (C t, ?x :: TF t) => t
b = ttt ?x 

compiles fine with ghc 6.12.3 but ghc 7.0.3 says:

    Could not deduce (?x::TF t)
      arising from a use of implicit parameter `?x'
    from the context (C t, ?x::TF t)
      bound by the type signature for b :: (C t, ?x::TF t) => t
      at Test.hs:13:1-10
    In the first argument of `ttt', namely `?x'
    In the expression: ttt ?x
    In an equation for `b': b = ttt ?x

Moreover, when I comment out the type declaration for b, ghc 7.0.3 compiles it and the inferred type for b is identical to the one that was commented out:

*Test> :t b
b :: (C t, ?x::TF t) => t
Trac metadata
Trac field Value
Version 7.0.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information