Ticket #2399 (closed feature request: fixed)
Template Haskell: support for view patterns
|Reported by:||fons||Owned by:||igloo|
|Keywords:||Cc:||rwbarton@…, audreyt@…, duncan2nd@…, reiner.pope@…, id@…, vogt.adam@…|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||Blocked By:|
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) .
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"