Dear Template Haskell users

There was a little exchange about TH quasiquotes a few weeks back (see below).  
I've made a ticket and some concrete proposals here
        http://hackage.haskell.org/trac/ghc/ticket/5348

Do take a look, if you care about TH quasiquotes.

Simon

| -----Original Message-----
| From: [email protected] [mailto:glasgow-haskell-users-
| [email protected]] On Behalf Of Simon Marlow
| Sent: 11 July 2011 13:43
| To: [email protected]
| Cc: GHC users; Ben Millwood
| Subject: Re: Quoting a quasi-quote
| 
| On 30/06/2011 14:52, Yitzchak Gale wrote:
| > It was pointed out by Ben Millwood on the Cafe
| > that there is an undocumented way to escape the
| > closing oxford bracket of a quasi-quote using
| > a backslash:
| >
| > [s|This quasi-quote contains this, \|], an escaped
| > closing oxford bracket.|]
| >
| > The backslash itself cannot be escaped in this
| > way:
| >
| > [s|Also contains an escaped bracket \\|] |]
| >
| > Thus there is a fairly strong limitation on the
| > contents of a quasi-quote: it can never end
| > in a backslash.
| >
| > This behavior is not mentioned in the GHC docs.
| > Is it a mistake, or is it meant to be a supported
| > feature?
| >
| > This behavior is a bit surprising to me. Since the
| > whole point of a quasi-quoter is to allow the user
| > to define syntax, you would think that the syntax
| > for the quasi-quote itself would be as quiet as
| > possible and stay out of the way. People who
| > need to be able to escape the closing bracket
| > can easily define their own syntax to do so.
| >
| > In any case, if this is indeed a feature, it certainly
| > should be documented.
| 
| It looks intentional to me:
| 
| lex_quasiquote :: String -> P String
| lex_quasiquote s = do
|    i <- getInput
|    case alexGetChar' i of
|      Nothing -> lit_error i
| 
|      Just ('\\',i)
|       | Just ('|',i) <- next -> do
|               setInput i; lex_quasiquote ('|' : s)
|       | Just (']',i) <- next -> do
|               setInput i; lex_quasiquote (']' : s)
|       where next = alexGetChar' i
| 
|      Just ('|',i)
|       | Just (']',i) <- next -> do
|               setInput i; return s
|       where next = alexGetChar' i
| 
|      Just (c, i) -> do
|        setInput i; lex_quasiquote (c : s)
| 
| 
| Indeed, it also seems strange that "\\]" is interpreted as "]".
| 
| That's all I know.  I agree we should either document or remove the feature.
| 
| Cheers,
|       Simon
| 
| 
| _______________________________________________
| Glasgow-haskell-users mailing list
| [email protected]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to