Template Haskell: support for view patterns
TH's Pat
type doesn't include a constructor for view patterns, which would ceratinly be useful.
As an example, Reid Barton suggested using view patterns for creating a regular expression quasiquoter (rx
) [1].
For example, to check if a string matches certain regular expresion:
example x = case x of
[$rx|.*foo.*] -> "contains foo"
_ -> "doesn't contain foo"
Using pattern views, the quasiquoter would expand to
example x = case x of
((=~".*foo.*")->True) -> "contains foo"
_ -> "doesn't contain foo"
[1] http://www.haskell.org/pipermail/template-haskell/2008-June/thread.html#669
Trac metadata
Trac field | Value |
---|---|
Version | 6.9 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Template Haskell |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |