[GHC] #16209: GHC behaves differently when binding has separate or inlined type declaration

GHC ghc-devs at haskell.org
Mon Jan 21 16:50:41 UTC 2019


#16209: GHC behaves differently when binding has separate or inlined type
declaration
-------------------------------------+-------------------------------------
           Reporter:  fghibellini    |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  7.10.3
           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:
-------------------------------------+-------------------------------------
 {{{#!hs
 {-# LANGUAGE RankNTypes #-}
 {-# LANGUAGE ScopedTypeVariables #-}

 main = do
     let a :: forall t. Functor t => t () = undefined
     let g :: forall u. Functor u => u () = a
     putStrLn "success"
 }}}

 fails with:

 {{{
 source_file.hs:6:44:
     Couldn't match expected type ‘forall (u :: * -> *).
                                   Functor u =>
                                   u ()’
                 with actual type ‘t0 ()’
     When checking that: t0 ()
       is more polymorphic than: forall (u :: * -> *). Functor u => u ()
     In the expression: a
 }}}

 but the following compiles successfully

 {{{#!hs
 {-# LANGUAGE RankNTypes #-}
 {-# LANGUAGE ScopedTypeVariables #-}

 main = do
     let a :: forall t. Functor t => t () = undefined
     let g :: forall u. Functor u => u ()
         g = a
     putStrLn "success"
 }}}

 On GHC 7.10 it works as described above. On newer ones it fails even on
 the "functioning code".

 {{{
 a.hs:5:44: error:
     • Cannot instantiate unification variable ‘a0’
       with a type involving foralls:
         forall (t :: * -> *). Functor t => t ()
         GHC doesn't yet support impredicative polymorphism
     • In the expression: undefined
       In a pattern binding:
         a :: forall (t :: * -> *). Functor t => t () = undefined
       In the expression:
         do let a :: forall t. Functor t => t () = undefined
            let g :: forall u. Functor u => u ()
                g = a
            putStrLn "success"
 }}}

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


More information about the ghc-tickets mailing list