OrPatterns: A quasiquoter for or-patterns
A quasiquoter for or-patterns. It allows one additional form for patterns:
f [o| p1 | p2 | p3 |] = rhs
Above, p1
, p2
and p3
are three arbitrary patterns
that bind the same variables. These variables are
available in the expression rhs
. Nesting of or-patterns
is not supported yet.
See also:
http://hackage.haskell.org/package/first-class-patterns supports
\/
(or). However, variables bound with those patterns are not named. This means:
g :: Either (x, y) (y, x) -> (x, y) g [o| Left (x,y) | Right (y,x) |] = (x,y)
-- ends up slightly longer g = elim $ left (pair var var) \/ right flipped ->> (,) where flipped = (\(a,b) -> (b,a)) --> pair var var
http://hackage.haskell.org/trac/ghc/ticket/3919 is the feature request for or-patterns in ghc
Downloads
- OrPatterns-0.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1 |
---|---|
Dependencies | base (>=4.5 && <4.8), containers (>=0.3 && <0.6), haskell-src-exts (>=1.15 && <1.16), haskell-src-meta (>=0.6 && <0.7), mtl (>=2.1 && <2.2), split (>=0.2 && <0.3), syb (>=0.4 && <0.5), template-haskell (>=2.4 && <2.10) [details] |
Tested with | ghc ==7.8.2, ghc ==7.6.2, ghc ==7.4.1 |
License | BSD-3-Clause |
Author | Adam Vogt <vogt.adam@gmail.com> |
Maintainer | Adam Vogt <vogt.adam@gmail.com> |
Category | Development |
Source repo | head: darcs get http://code.haskell.org/~aavogt/OrPatterns |
Uploaded | by AdamVogt at 2014-05-16T06:02:29Z |
Distributions | |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Downloads | 1304 total (1 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Successful builds reported [all 1 reports] |