#2399: Template Haskell: support for view patterns
--------------------------------+-------------------------------------------
Reporter: fons | Owner:
Type: feature request | Status: new
Priority: normal | Component: Template Haskell
Version: 6.9 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown | Os: Unknown
--------------------------------+-------------------------------------------
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
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2399>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs