[GHC] #3919: Or-patterns as GHC extension
GHC
ghc-devs at haskell.org
Tue Dec 15 02:50:16 UTC 2015
#3919: Or-patterns as GHC extension
-------------------------------------+-------------------------------------
Reporter: BjornEdstrom | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: ⊥
Component: Compiler | Version:
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 osa1):
If we could come up with a nice syntax for function definitions with or-
patterns this would be really useful for GHC's own code too.
Often we have to re-compile GHC many times and test on some programs to
discover all the places we need to update after adding a new data
constructor, because of "catch-all" code like this:
{{{#!haskell
f A = ...
f B = ...
f unexpected = pprTrace "f" (ppr unexpected)
}}}
With or patterns, we could do this instead:
{{{#!haskell
f A = ...
f B = ...
f unexpected@(C{} | D{} | E{}) = pprTrace "f" (ppr unexpected)
}}}
(just made up a syntax)
This would be very convenient, because now I get a warning after adding
data constructor D - instead of discovering this code after a runtime
failure. And what happens if I couldn't discover this code because I
couldn't come up with an example program that makes GHC run this function?
So it's a bit tricky and annoying right now, and it's costing us time
because of recompilations and tests.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/3919#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list