[GHC] #11307: Regresssion: parsing type operators

#11307: Regresssion: parsing type operators -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.11 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: -------------------------------------+------------------------------------- GHC 7.10.3 will parse (but not type-check) the following {{{#!hs {-# LANGUAGE TypeOperators #-} type family (r1 :++: r2); infixr 5 :++: type instance r :++: Nil = r type instance r1 :++: r2 :> a = (r1 :++: r2) :> a }}} Current master (c7830bdb14e0a85a78617314156d101155fdf7aa) fails with {{{#!hs /tmp/Foo.hs:5:15: error: Malformed head of type or class declaration: r1 :++: r2 :> a }}} @simonpj comment on ghc-devs mailing list
`| type instance r1 :++: r2 :> a = (r1 :++: r2) :> a`
What do you expect this to mean? I suppose you could hope that GHC will unravel the fixity of :++: and :>, to determine whether you are giving an instance for :++: or for :>?
That sounds reasonable, but it's not trivial.
Currently the LHS of a 'type instance' decl is ultimately a TyFamEqn, and it looks like this:
{{{#!hs data TyFamEqn name pats = TyFamEqn { tfe_tycon :: Located name , tfe_pats :: pats , tfe_rhs :: LHsType name } }}}
So we've already decided (in the parser) what the type-function name is. But we can't do that in this case, because the parser doesn't understand fixity.
To deal with this we'd need to change to
{{{#!hs data TyFamEqn name pats = TyFamEqn { tfe_lhs :: LHSType name , tfe_rhs :: LHsType name } }}}
so that the LHS was just a type. Now the renamer can re-jiggle its fixities in the usual way, and only in the type checker will we need to decide exactly which type it's an instance of. Easy!
This might be a good change to make! It's a bit like in ClsInstDecl, you'll see that the instance cid_poly_ty is just a LHsSigType, i.e. not decomposed into which class it is.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11307 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11307: Regresssion: parsing type operators -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.11 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 goldfire): I think the change from 7.10 to HEAD is an improvement, because 7.10 is illogical with regard to these shenanigans. This is accepted: {{{#!hs {-# LANGUAGE TypeFamilies, TypeOperators #-} module Parse where type family a :++: b infix 5 :++: data a :> b infix 2 :> type instance Int :++: Char :> Bool = Double }}} But in that `type instance`, the `:++:` should really bind tighter, making an instance declaration for `:>`, which is hogwash of course. So 7.10 is ignoring fixities altogether and just looking for the first operator. Better still would be Simon's suggestion, but I'm inclined to call this new behavior a feature, not a bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11307#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11307: Regresssion: parsing type operators -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.11 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: | -------------------------------------+------------------------------------- Changes (by alanz): * milestone: 8.0.1 => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11307#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11307: Regresssion: parsing type operators -------------------------------------+------------------------------------- Reporter: alanz | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.11 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 goldfire): Implementing Simon's plan will also fix #11400. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11307#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11307: Regresssion: parsing type operators -------------------------------------+------------------------------------- Reporter: alanz | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 11400 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.1 => 8.4.1 Comment: This won't happen for 8.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11307#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11307: Regresssion: parsing type operators
-------------------------------------+-------------------------------------
Reporter: alanz | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.4.1
Component: Compiler | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking: 11400
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#11307: Regresssion: parsing type operators -------------------------------------+------------------------------------- Reporter: alanz | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 11400 Related Tickets: #15759 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #15759 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11307#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC