[GHC] #3919: Or-patterns as GHC extension
GHC
ghc-devs at haskell.org
Fri Sep 30 13:23:28 UTC 2016
#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):
Good point. I think we may require parens around or patterns. So the
parsing rule would be like:
{{{
pat ::= '(' or-pattern-or-pat ')'
| ... (where none of the productions accept '|')
or-pattern-or-pat
::= pat '|' or-pattern-or-pat
| pat
}}}
I personally dislike messier syntax like `:|` and `:|:`, because I'm
hoping to use this syntax instead of `_` patterns, and I may need to chain
a lot of constructors.
{{{
f (T1 ...) = ...
f (T2{} | T3{} | T4{}) = ...
}}}
vs
{{{
f (T1 ...) = ...
f (T2{} :|: T3{} :|: T4{}) = ...
}}}
Second one looks really bad IMHO. In addition, `:|:` is a valid operator
syntax, but `|` is a reserved operator.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/3919#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list