Changes between Initial Version and Version 1 of Ticket #7396


Ignore:
Timestamp:
Nov 7, 2012 2:12:13 AM (18 months ago)
Author:
simonpj
Comment:

The error I get is

T7396.hs:5:1: parse error on input `$'

which of course is right, absent TH. Is that what happened to you?

I think one could improve the error mesage by parsing a top-level declaration splice (which is otherwise not legal Haskell 98), and then reporting "Perhaps you meant -XTemplateHaskell" in the renamer, or something like that.

But for expression splices it's not so easy:

f x = g $(foo)

really does mean something in Haskell 98, namely

f x = f $ foo

So in expressions we can't parse as TH and reject later.

If you want to have a shot at this, by all means. One difficulty is that the lexer recognises the token "$(" as a single lexeme when TH is on. It can't do that when TH is off. Maybe in the parser you can have a new production

topdecl ::= '$' '(' exp ')'

but I have not thought through all the consequences.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #7396

    • Property Difficulty changed from to Unknown
    • Property Type changed from bug to feature request
  • Ticket #7396 – Description

    initial v1  
    77 
    88$(derive makeBinary ''Test) 
    9 }} 
     9}}} 
    1010 
    1111Until, stupid me, I realized that the TemplateHaskell PRAGMA was missing. Could this message be a bit more friendly pointing me to the real issue?