[GHC] #11552: ScopedTypeVariables / InstanceSigs do not work in GHC 8.0

#11552: ScopedTypeVariables / InstanceSigs do not work in GHC 8.0 -------------------------------------+------------------------------------- Reporter: bitemyapp | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc1 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: -------------------------------------+------------------------------------- {{{ {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE ScopedTypeVariables #-} module MyMaybeT where newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) } instance (Functor m) => Functor (MaybeT m) where fmap f (MaybeT ma) = MaybeT $ (fmap . fmap) f ma instance forall f . (Applicative f) => Applicative (MaybeT f) where pure :: a -> MaybeT f a pure x = MaybeT (pure (pure x)) (<*>) :: forall a b . Applicative f => MaybeT f (a -> b) -> MaybeT f a -> MaybeT f b (MaybeT fab) <*> (MaybeT mma) = let fab' :: f (Maybe (a -> b)) fab' = fab in MaybeT $ undefined }}} Works fine in 7.10.3, breaks in GHC 8.0: {{{ Prelude> :l code/myMaybeT1.hs [1 of 1] Compiling MyMaybeT ( code/myMaybeT1.hs, interpreted ) code/myMaybeT1.hs:13:10: error: Malformed instance: forall f. (Applicative f) => Applicative (MaybeT f) code/myMaybeT1.hs:14:3: error: The class method signature for ‘pure’ lacks an accompanying binding (The class method signature must be given where ‘pure’ is declared) code/myMaybeT1.hs:17:3: error: The class method signature for ‘<*>’ lacks an accompanying binding (The class method signature must be given where ‘<*>’ is declared) code/myMaybeT1.hs:17:37: error: Not in scope: type variable ‘f’ code/myMaybeT1.hs:17:49: error: Not in scope: type variable ‘f’ code/myMaybeT1.hs:17:70: error: Not in scope: type variable ‘f’ code/myMaybeT1.hs:17:84: error: Not in scope: type variable ‘f’ Failed, modules loaded: none. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11552 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11552: ScopedTypeVariables / InstanceSigs do not work in GHC 8.0 -------------------------------------+------------------------------------- Reporter: bitemyapp | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc1 Resolution: | 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: | -------------------------------------+------------------------------------- Description changed by bitemyapp: @@ -53,0 +53,5 @@ + + {{{ + $ ghci --version + The Glorious Glasgow Haskell Compilation System, version 8.0.0.20160122 + }}} New description: {{{ {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE ScopedTypeVariables #-} module MyMaybeT where newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) } instance (Functor m) => Functor (MaybeT m) where fmap f (MaybeT ma) = MaybeT $ (fmap . fmap) f ma instance forall f . (Applicative f) => Applicative (MaybeT f) where pure :: a -> MaybeT f a pure x = MaybeT (pure (pure x)) (<*>) :: forall a b . Applicative f => MaybeT f (a -> b) -> MaybeT f a -> MaybeT f b (MaybeT fab) <*> (MaybeT mma) = let fab' :: f (Maybe (a -> b)) fab' = fab in MaybeT $ undefined }}} Works fine in 7.10.3, breaks in GHC 8.0: {{{ Prelude> :l code/myMaybeT1.hs [1 of 1] Compiling MyMaybeT ( code/myMaybeT1.hs, interpreted ) code/myMaybeT1.hs:13:10: error: Malformed instance: forall f. (Applicative f) => Applicative (MaybeT f) code/myMaybeT1.hs:14:3: error: The class method signature for ‘pure’ lacks an accompanying binding (The class method signature must be given where ‘pure’ is declared) code/myMaybeT1.hs:17:3: error: The class method signature for ‘<*>’ lacks an accompanying binding (The class method signature must be given where ‘<*>’ is declared) code/myMaybeT1.hs:17:37: error: Not in scope: type variable ‘f’ code/myMaybeT1.hs:17:49: error: Not in scope: type variable ‘f’ code/myMaybeT1.hs:17:70: error: Not in scope: type variable ‘f’ code/myMaybeT1.hs:17:84: error: Not in scope: type variable ‘f’ Failed, modules loaded: none. }}} {{{ $ ghci --version The Glorious Glasgow Haskell Compilation System, version 8.0.0.20160122 }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11552#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11552: ScopedTypeVariables / InstanceSigs do not work in GHC 8.0 -------------------------------------+------------------------------------- Reporter: bitemyapp | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc1 Resolution: | 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: | -------------------------------------+------------------------------------- Comment (by rwbarton): Not sure whether this change was intentional, but you don't need the `forall f .`, and the code compiles fine without it. See http://ghc.readthedocs.org/en/latest/glasgow_exts.html#class-and-instance- declarations. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11552#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11552: ScopedTypeVariables / InstanceSigs do not work in GHC 8.0 -------------------------------------+------------------------------------- Reporter: bitemyapp | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc1 Resolution: | 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: | -------------------------------------+------------------------------------- Comment (by bitemyapp): That has fixed it for GHC 8.0 and 7.10.3, thank you! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11552#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11552: ScopedTypeVariables / InstanceSigs do not work in GHC 8.0 -------------------------------------+------------------------------------- Reporter: bitemyapp | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc1 Resolution: | 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: | -------------------------------------+------------------------------------- Changes (by goldfire): * owner: => goldfire Comment: I think I know what caused this regression, and there's no good reason for it. It is simple, so I'll add this to my queue. (I'm 98% sure that this is caused by my changes to the parser in order to account for the kind `*`.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11552#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11552: ScopedTypeVariables / InstanceSigs do not work in GHC 8.0 -------------------------------------+------------------------------------- Reporter: bitemyapp | Owner: goldfire Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | typecheck/should_compile/T11552 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => typecheck/should_compile/T11552 * resolution: => fixed Comment: I'm not sure what you had in mind, Richard, but I fixed this as part of #11519. I'll add another regression test though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11552#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11552: ScopedTypeVariables / InstanceSigs do not work in GHC 8.0
-------------------------------------+-------------------------------------
Reporter: bitemyapp | Owner: goldfire
Type: bug | Status: closed
Priority: normal | Milestone: 8.0.1
Component: Compiler | Version: 8.0.1-rc1
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: GHC rejects | Test Case:
valid program | typecheck/should_compile/T11552
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones
participants (1)
-
GHC