[GHC] #9270: GHC HEAD accepts a manual instance decl but not equivalent TH decl

#9270: GHC HEAD accepts a manual instance decl but not equivalent TH decl ------------------------------------+------------------------------------- Reporter: Feuerbach | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- If I try to build the traverse-with-class package with GHC HEAD, I get an error: {{{ Data/Generics/Traversable/Instances.hs:21:1: Illegal type constructor or class name: ācā When splicing a TH declaration: instance c_0 a_1 => Data.Generics.Traversable.Core.GTraversable c_0 (Data.Maybe.Maybe a_1) where Data.Generics.Traversable.Core.gtraverse = \f_2 x_3 -> case x_3 of Data.Maybe.Nothing -> Control.Applicative.pure Data.Maybe.Nothing Data.Maybe.Just arg_4 -> (Control.Applicative.<*>) (Control.Applicative.pure Data.Maybe.Just) (f_2 arg_4) }}} This code used to compile with all the previous versions. Additionally, if I replace the TH splice with the generated instance declaration (with minimal corrections to make all names resolve), it is accepted: {{{ instance c_0 a_1 => Data.Generics.Traversable.Core.GTraversable c_0 (Maybe a_1) where gtraverse = \f_2 x_3 -> case x_3 of Nothing -> Control.Applicative.pure Nothing Just arg_4 -> (Control.Applicative.<*>) (Control.Applicative.pure Just) (f_2 arg_4) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9270 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9270: GHC HEAD accepts a manual instance decl but not equivalent TH decl -------------------------------------+------------------------------------ Reporter: Feuerbach | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by goldfire): * status: new => closed * resolution: => invalid Comment: The code in `traverse-with-class` is incorrect and should lead to exactly this error. It calls `classP` on a type variable `c`. `classP` is meant to make a class-predicate, and should be passed the name of a class, not a type variable. The fact that this worked previously was in error. To be fair, using a type variable in a constraint was not possible before GHC 7.9, so the author of `traverse-with-class` didn't really have another choice. Now that TH supports a full variety of constraints, the code can be rewritten to use `AppT` and `VarT` instead of `classP`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9270#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9270: GHC HEAD accepts a manual instance decl but not equivalent TH decl -------------------------------------+------------------------------------ Reporter: Feuerbach | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by Feuerbach): That helped, thank you! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9270#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC