[GHC] #12224: Replace placeHolderPunRhs with a PlaceHolder value

#12224: Replace placeHolderPunRhs with a PlaceHolder value -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- At the moment `placeHolderPunRhs` is defined as {{{#!hs placeHolderPunRhs :: LHsExpr RdrName -- The RHS of a punned record field will be filled in by the renamer -- It's better not to make it an error, in case we want to print it when debugging placeHolderPunRhs = noLoc (HsVar pun_RDR) pun_RDR = mkUnqual varName (fsLit "pun-right-hand-side") }}} Rather use a type of `PostRn id (LHsExpr id)` where this is used. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12224 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12224: Replace placeHolderPunRhs with a PlaceHolder value -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by alanz): It seems that to do this I need to have a `Functor` instance for `PostRn id`, which does not seem possible. Any pointers? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12224#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12224: Replace placeHolderPunRhs with a PlaceHolder value -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): alanz, presumably you're talking this datatype in `HsPat`? {{{#!hs -- For details on above see note [Api annotations] in ApiAnnotation data HsRecField' id arg = HsRecField { hsRecFieldLbl :: Located id, hsRecFieldArg :: arg, -- ^ Filled in by renamer when punning hsRecPun :: Bool -- ^ Note [Punning] } deriving (Data, Functor, Foldable, Traversable) }}} And you want to change `hsRecFieldArg` to be of type `PostRn id arg`? If so, I don't think you'll be able to derive `Functor`, `Foldable`, or `Traversable` anymore, since GHC won't know what code to fill in for the irreducible type family `PostRn id arg`. One possible workaround is to define your `Functor` instances manually: {{{#!hs instance Functor (HsRecField' Id) where fmap f (HsRecField a b c) = HsRecField a (f b) c instance Functor (HsRecField' Name) where fmap _ (HsRecField a b c) = HsRecField a b c instance Functor (HsRecField' RdrName) where fmap _ (HsRecField a b c) = HsRecField a b c }}} and similarly for `Foldable` and `Traversable`. It's not the prettiest solution, but I think it might work for GHC's purposes. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12224#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12224: Replace placeHolderPunRhs with a PlaceHolder value -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by alanz): I tried that, but get {{{ compiler/hsSyn/HsPat.hs:331:57: Couldn't match expected type ‘PostRn id b’ with actual type ‘b’ ‘b’ is a rigid type variable bound by the type signature for fmap :: (a -> b) -> HsRecField' id lbl a -> HsRecField' id lbl b at compiler/hsSyn/HsPat.hs:331:3 Relevant bindings include a :: PostRn id a (bound at compiler/hsSyn/HsPat.hs:331:25) f :: a -> b (bound at compiler/hsSyn/HsPat.hs:331:8) fmap :: (a -> b) -> HsRecField' id lbl a -> HsRecField' id lbl b (bound at compiler/hsSyn/HsPat.hs:331:3) In the second argument of ‘HsRecField’, namely ‘(f a)’ In the expression: HsRecField ln (f a) p }}} I had to bring in an `id` separate from the `lbl` to get the `Data` instances to come out. My interpretation of the error message is that it is impossible to define `fmap` for this type. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12224#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12224: Replace placeHolderPunRhs with a PlaceHolder value -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): alanz, can you show me the diff? From the error message, I'm wondering if you're trying to do something like `instance Functor (HsRecField' id)`, which won't work. You need to instantiate `id` with a concrete type in each `Functor` instance in order to `PostRn id` to reduce enough. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12224#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12224: Replace placeHolderPunRhs with a PlaceHolder value -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by alanz): See https://phabricator.haskell.org/D2683 I started doing individual instances, but it broke elsewhere -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12224#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12224: Replace placeHolderPunRhs with a PlaceHolder value -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: task | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): D2683 Wiki Page: | -------------------------------------+------------------------------------- Changes (by alanz): * differential: => D2683 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12224#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12224: Replace placeHolderPunRhs with a PlaceHolder value -------------------------------------+------------------------------------- Reporter: alanz | Owner: alanz Type: task | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1 (Parser) | Resolution: wontfix | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2683 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * differential: D2683 => Phab:D2683 * resolution: => wontfix Comment: It seems that we decided this wouldn't be worthwhile. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12224#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC