[Haskell-cafe] Invalid declaration names in TH that typecheck

Sean Leather leather at cs.uu.nl
Fri Oct 17 07:33:46 EDT 2008


[I posted this on the Template Haskell list, but nobody seemed interested.
Thus, I'm re-posting it here for higher coverage.]

Apparently, I can create a function declaration (FunD) with a name
containing an invalid sequence of characters. It passes typechecking and
compiles. It even shows up in GHCi!

The function name is "ep:#:", and the ":#:" is derived from an infix type
constructor. In GHCi (6.8.3), I type "ep", hit <Tab> to get the list of
completions, and, sure enough, there it is! When I try to use it, GHCi
interprets it as two distinct symbols, "ep" and ":#:", as it should.

Template Haskell's claim to fame is that it allows you to do "type-safe
compile-time meta-programming," and while this issue is perhaps considered
lexical rather than type-level, I'm wondering if there should be some
additional error checking (somewhere) to account for this. I admit though,
that I wouldn't know how to do this easily within the bounds of the TH API.
The Name type is common to functions, infix operators, and everything else.
That which is valid for one is not necessarily so for the other.

Regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081017/48b5df8d/attachment.htm


More information about the Haskell-Cafe mailing list