[GHC] #13905: ApplicativeDo is too strict with newtype patterns

#13905: ApplicativeDo is too strict with newtype patterns -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.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: -------------------------------------+------------------------------------- The fix to #13875 went a little too far, and interprets newtype constructor patterns as strict. It's not clear to me how to fix this, as the `Name` of the constructor doesn't seem to give any clue as to whether it is a newtype constructor or a data constructor. The comment at the top of `basicTypes/Name.hs` indicates {{{ -- * 'Name.Name' is the type of names that have had their scoping and binding resolved. They -- have an 'OccName.OccName' but also a 'Unique.Unique' that disambiguates Names that have -- the same 'OccName.OccName' and indeed is used for all 'Name.Name' comparison. Names -- also contain information about where they originated from, see "Name#name_sorts" }}} which suggests that this information should be available, but I don't know what's involved in propagating it to the right place. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13905 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13905: ApplicativeDo is too strict with newtype patterns -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 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 simonmar): I don't think this is fixable, I documented it in Phab:D3691 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13905#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13905: ApplicativeDo is too strict with newtype patterns -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 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 dfeuer): I'm not trying to be annoying, but may I ask why you don't think it's fixable? Don't we already know, at this point, where the constructor name comes from? I see the documentation, and the documentation is fine, but I suspect idiomatic code will run into this, and people will likely be surprised to see explicit `~` laziness around newtype constructors. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13905#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13905: ApplicativeDo is too strict with newtype patterns -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 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 simonmar): We do ApplicativeDo rearrangement in the renamer, and we don't have the mapping from Names to TyThings until the typechecker, so at least superficially it seems hard. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13905#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13905: ApplicativeDo is too strict with newtype patterns -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 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 simonpj): That is extremely annoying, and so clearly an artefact of GHC's architecture, rather than any solid reason, that we should question it. For example we could 1. Keep track in the renamer of what local data constructors are newtypes. (We already know this for imported ones.) 2. Rename and typecheck all data/class decls before we even start on the value declarations. A bit like we do for top-level Template Haskell splices. The second of these looks more solid to me. I recall that there's a similar issue with record fields, when the renamer wants to know what fields a particular data constructor has. Currently we use a variant of (1) I think; but (2) would solve it and thereby simplify that code. So I quite like (2). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13905#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13905: ApplicativeDo is too strict with newtype patterns -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 Resolution: | Keywords: ApplicativeDo 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 simonpj): * keywords: => ApplicativeDo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13905#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC