google-code-export / omega

Automatically exported from code.google.com/p/omega
Other
2 stars 0 forks source link

splicing literal data in pattern positions #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If a Code fragment contains literal data, e.g.
[| 'a' |]
then it would be nice if we could splice this
into pattern positions (e.g. in lhs of case alternatives)

Look at this dialog:

prompt> (let a = False in let b = lift a in [| case a of {True -> 3; $b ->
1} |])
"keyboard input" (line 1, column 1) tabs []:
unexpected "(" at: "let a = Fa...", or reserved word "let" at: " a = False..."
expecting: end of input, ":", "let", pattern, or expression

The parser does not seem to like the "$b" in the pattern. Removing "$"
makes it compile.

Because lift will always create literate data that is packed into code,
this could be made working in a semantically sound way.

Original issue reported on code.google.com by ggr...@gmail.com on 13 Jun 2007 at 1:15

GoogleCodeExporter commented 9 years ago
... create literal data ...

Original comment by ggr...@gmail.com on 19 Dec 2007 at 10:00

GoogleCodeExporter commented 9 years ago
IIRC Template Haskell uses [p| <here> ] to build patterns, TokenDef.hs also 
lists "[p|" as reserved special operator, but the parser does not recognize it.

Original comment by ggr...@gmail.com on 8 Dec 2010 at 11:49