[GHC] #7169: Warning for incomplete record field label used as function
GHC
ghc-devs at haskell.org
Mon Jun 19 16:01:09 UTC 2017
#7169: Warning for incomplete record field label used as function
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.7
Resolution: | Keywords: Warnings,
| newcomer
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect | Unknown/Multiple
warning at compile-time | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
I agree with nakaji-dayo here. Emitting a warning upon every use of `quux`
feels like the wrong design choice.
To address goldfire's point above:
> We want to be able to have fields such as `quux` that are used only with
some (but not all) constructors of a type
I agree. I think a reasonable design would be:
* Introduce a flag for this purpose (proposal: `-Wpartial-records`)
* If the flag is enabled and you define a partial record selector (e.g.,
`data A = B1 { b :: Int } | B2 { b :: Int, wat :: Char }`, emit a warning
of the definition site (and only the definition site).
* One can disable this warning by prefixing the partial record selector
with an underscore (e.g., `data A = B1 { b :: Int } | B2 { b :: Int, _wat
:: Char }`). This should allow you to use the partial record for scenarios
where it's handy, but it also gives a visual indication that something is
fishy about that function.
A separate question is if this flag should be implied by `-Wall`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7169#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list