Or-patterns as GHC extension
Or-patterns is a way of grouping together patterns that match to the same value. A construct like
fun 0 _ = E
fun _ 0 = E
Could more concisely be written as, for example
fun 0 _
|| _ 0 = E
As a concrete example why this is beautiful and how it could look, see Red-black trees in a functional setting, C. Okasaki [1].
I don't know enough about GHC internals to know the obvious way to implement this, but I would gladly give it a try given pointers in the right direction.
[1] http://www.eecs.usma.edu/webs/people/okasaki/jfp99.ps
Trac metadata
Trac field | Value |
---|---|
Version | |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |