Ticket #1803 (new feature request)

Opened 7 months ago

Last modified 6 months ago

Include qCurrentLoc in the Quasi class

Reported by: guest Assigned to:
Priority: normal Milestone: 6.10 branch
Component: Template Haskell Version: 6.6.1
Severity: normal Keywords:
Cc: alfonso.acosta@gmail.com Difficulty: Unknown
Test Case: Architecture: Unknown
Operating System: Unknown

Description

From the "Notes on Template Haskell 2"[1] document.

currentLoc :: Q (FilePath, Int)

 -- Returns the location of the top-level splice being executed.

[1] http://research.microsoft.com/~simonpj/tmp/notes2.ps

Change History

10/29/07 17:25:36 changed by guest

  • cc set to alfonso.acosta@gmail.com.

11/05/07 17:53:54 changed by guest

I would like to point out that this, apparently not-so-useful feature, can be crucial when using TH to create embedded languages.

Sometimes, a semantic error cannot be detected in the very same splice in which code is generated. By storing the exact location in which the splice was called, the embedded compiler could later point the user to the exact origin of the error, providing rich error reports.

Unfortunately, the lack of qCurrentLoc, makes it impossible.

11/06/07 02:32:03 changed by simonpj

Compared to other proposals like adding type families to TH, this one is very easy to do. I'm sure we can do it for 6.10.

Simon