[GHC] #9497: Silent typed holes

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: typed holes, | Operating System: warnings | Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: Difficulty: Unknown | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- I have a UI feature request for -fwarn-typed-holes, currently there's two options: 1) typed holes are on (default) and GHC prints errors for types holes or 2) typed holes are off and GHC will print "not in scope" error and prematurely end compilation. When writing haskell, I frequently want to typecheck my code before it's completely implemented. Before I used undefined/error, which worked but I was always worried about accidentally forgetting an undefined somewhere. With typed holes this is no longer a problem, but unfortunately the warnings from typed holes are so verbose they drown out the other type errors. This makes typechecking during refactoring rather onerous. I propose adding a -fsilent-typed-holes and/or -ftreat-type-holes-as- undefined which enable typed holes, but silence any compile time warnings. It'd be nice if this flag treated holes as if "-fdefer-type-errors" was on, but ONLY for typed holes. This would let me compile the code and fix warnings, ignoring the holes while developing, while still assuring that, when I remove the flag and compile "for real" I get an error about typed holes. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I think that's a very reasonable suggestion. What would make sense to me is this: * `-XTypedHoles`, by default, generates ''warnings'' not ''errors''. * If you run a program that exhibits such warnings, you get the behaviour of `-fdefer-type-errors` (i.e. a runtime crash) * `-Werror` would make the warning into a fatal error, as usual. * We add a flag `-fno-warn-typed-holes` which switches off warnings if you don't want to see them. This is the part you are asking for. By treating this as "just another warning", we make it less of a special case. However the first point is, I believe, a change in behaviour; i.e. it makes a typed hole into a non-fatal warning by default, rather than a fatal error. To make it fatal you'd have to do `-Werror`, although that makes ''all'' warnings fatal. Does that seem like a reasonable change? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): I don't feel strongly, but I'm -1 on defaulting to a warning over an error. It seems to invite the possibility that holes could make their way into released code, which sometimes has plenty of warnings. It's easy for a distribution tool to check for (and prohibit) `-fdefer-type-errors`, but it would be much harder to avoid holes under the proposed change. I also have to say that the current interface to this feature is very confusing! The flag `-fwarn-typed-holes`, on by default, causes '''errors''' to be reported, not warnings. And, the inverse, `-fno-warn- typed-holes` changes the nature of '''error''' messages, once again, as opposed to suppressing warnings, the usual behavior of `-fno-warn-...` flags. These flags are described in the "Warnings" section of [http://www.haskell.org/ghc/docs/latest/html/users_guide/flag- reference.html the flag reference], rather misleadingly. To be concrete, I propose the following: * By default, holes behave exactly as they do now. * A new flag, `-fdefer-typed-holes` turns typed-hole errors into warnings, just like `-fdefer-type-errors` (which would imply `-fdefer-typed-holes`). * Re-appropriate `-fno-warn-typed-holes` to suppress the warnings generated by `-fdefer-typed-holes`. The current behavior of `-fno-warn- typed-holes` (to turn the usage of holes into out-of-scope errors) would no longer be available. Thoughts? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by merijn): I would prefer the behaviour proposed by goldfire (or some variation of that), that is, I believe TypedHoles should be fatal by default and only optionally non-fatal. I have no opinion on eliminating the current "-fno-warn-typed-holes", if it stays and we get "-fsilent-typed-holes" or something similar, I would be satisfied too. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Crumbs, you are right. I'd forgotten that we'd decided ''not'' to make typed holes into a language extension (see [http://www.haskell.org/pipermail/ghc-devs/2014-January/003758.html this email]), but rather controlled by `-fwarn-typed-holes` which is on by default. I agree with Richard that this is jolly confusing. Two issues with Richard's proposals: * There is no way to switch off typed holes altogether, and revert to {{{ Hole.hs:1:7: Pattern syntax in expression context: _ }}} Maybe that is OK. * What does `-fno-warn-typed-holes` do in the absence of `-fdefer-typed- holes`? No-op with a warning? * What does `-fwarn-typed-holes` do? Perhaps just re-enable the warning after switching off all warnings with `-w`. Modulo just specifying (and documenting) this behaviour, I'd be content with the above. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): Replying to [comment:4 simonpj]:
Two issues with Richard's proposals:
* There is no way to switch off typed holes altogether, and revert to {{{ Hole.hs:1:7: Pattern syntax in expression context: _ }}} Maybe that is OK.
I think this is OK. It's conceivable that a user makes a typo in an identifier that begins with an underscore and will be very confused by the error message. But, that exact same scenario would happen today, unless the user also somehow knows to use an obscure compiler option (`-fno-warn- typed-holes`). One way to mitigate this problem is to have typed-hole error/warning messages link to a description of the feature.
* What does `-fno-warn-typed-holes` do in the absence of `-fdefer-
typed-holes`? No-op with a warning?
It suppresses typed-hole warnings, of which there would be none. This is the same behavior as other `-fno-warn-...` options, when the condition that is being suppressed doesn't happen. I'm not bothered here.
* What does `-fwarn-typed-holes` do? Perhaps just re-enable the warning after switching off all warnings with `-w`.
Yep. One issue with this bikeshed color: having options `-fdefer-type-errors` and `-fdefer-typed-holes` forced users to remember the difference between `type` and `typed`. I think the choices here make sense (`type` in the first, `typed` in the second), but it is a little annoying. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): OK I think we are more or less agreed here. Does someone feel like offering a patch? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: merijn Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by merijn): * owner: => merijn -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: merijn Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by merijn): I'll try and see if I can hack this together. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: merijn Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Merijn: thanks. FYI I think the 7.10 freeze will be mid-Nov. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: merijn Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D442 | -------------------------------------+------------------------------------- Changes (by thomie): * differential: => Phab:D442 * milestone: => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9497: Silent typed holes
-------------------------------------+-------------------------------------
Reporter: merijn | Owner: merijn
Type: feature | Status: new
request | Milestone: 7.10.1
Priority: normal | Version: 7.8.3
Component: Compiler | Keywords: typed holes,
Resolution: | warnings
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: | Blocked By:
None/Unknown | Related Tickets:
Test Case: |
Blocking: |
Differential Revisions: Phab:D442 |
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#9497: Silent typed holes -------------------------------------+------------------------------------- Reporter: merijn | Owner: merijn Type: feature | Status: closed request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: typed holes, Resolution: fixed | warnings Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: Phab:D442 | -------------------------------------+------------------------------------- Changes (by thomie): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9497#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC