[GHC] #12185: Can't call rank-2 function with type family constraint

GHC ghc-devs at haskell.org
Fri Jun 10 22:32:03 UTC 2016


#12185: Can't call rank-2 function with type family constraint
-------------------------------------+-------------------------------------
           Reporter:  crockeea       |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
  (Type checker)                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  GHC rejects
  Unknown/Multiple                   |  valid program
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The following code compiles with 7.10.3:
 {{{

 newtype Bar r = Pow r deriving (Eq)
 instance (Foo r) => Foo (Bar r)

 type family Ctx a where Ctx t = (Foo (Bar t), Eq (Bar t))

 run :: (forall t . (Ctx t) => t -> Int) -> Int
 run g = undefined

 foo :: (Foo (Bar t)) => t -> Int
 foo = undefined

 main :: IO ()
 main = print $ run foo
 }}}

 but fails in 8.0.1 with
 {{{
     • Could not deduce (Foo t) arising from a use of ‘foo’
       from the context: Ctx t
         bound by a type expected by the context:
                    Ctx t => t -> Int
         at Main.hs:19:16-22
       Possible fix:
         add (Foo t) to the context of
           a type expected by the context:
             Ctx t => t -> Int
     • In the first argument of ‘run’, namely ‘foo’
       In the second argument of ‘($)’, namely ‘run foo’
       In the expression: print $ run foo
 }}}

 This code seems valid to me: when I call `run foo`, `foo` is specialized
 to `(Foo (Bar t), Eq (Bar t)) => t -> Int)`, which meets the requirement
 of the argument to `run`.

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


More information about the ghc-tickets mailing list