#2399: Template Haskell: support for view patterns
---------------------------------+------------------------------------------
    Reporter:  fons              |        Owner:  igloo       
        Type:  feature request   |       Status:  new         
    Priority:  low               |    Milestone:  _|_         
   Component:  Template Haskell  |      Version:  6.11        
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:  Unknown     
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------
Changes (by reinerp):

  * owner:  => igloo


Comment:

 I've attached patches (to ghc, template-haskell, and the testsuite) which
 implement and test the request. The {{{Pat}}} datatype in template-haskell
 now has a constructor {{{ViewP Exp Pat}}}, which is recognised when
 splicing. Also, GHC no longer complains about "exotic patterns" when
 writing things like {{{[p|(id -> x)|]}}}.

 My thought about view patterns versus Simon's "compositional pattern
 guards": view patterns are simpler. In particular, an important motivation
 seems to be for pattern quasiquoters. The main feature such quasiquoters
 require is being able to do computation before performing the pattern
 match, and the {{{ViewP}}} constructor expresses exactly that, and no
 more.

 In my patch, I have left the {{{ViewP}}} case of
 {{{Language.Haskell.TH.Lib.rename}}} as a {{{fail}}}. To implement this
 case would seem to require extending {{{rename}}} to expressions as well
 as just patterns; and in any case, I am not sure of the purpose of this
 function.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2399#comment:14>
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

Reply via email to