[Haskell-cafe] RFC: rewrite-with-location proposal

Gershom Bazerman gershomb at gmail.com
Tue Feb 26 16:51:17 CET 2013


On 2/25/13 9:42 AM, Simon Peyton-Jones wrote:
>
> I'm afraid the rewrite-rule idea won't work.  RULES are applied during 
> optimisation, when tons of inlining has happened and the program has 
> been shaken around a lot. No reliable source location information is 
> available there.
>
> See http://hackage.haskell.org/trac/ghc/wiki/ExplicitCallStack; and 
> please edit it.
>
> One idea I had, which that page does not yet describe, is to have an 
> implicit parameter,
> something like ?loc::Location, with
>
> errLoc :: ?loc:Location => String -> a
>
> errLoc s = error ("At " ++ ?loc ++ "\n" ++ s)
>
> This behave exactly like an ordinary implicit parameter, EXCEPT that 
> if there is no binding for ?loc::Location, then the current location 
> is used.  Thus
>

I like the general approach of this proposal quite a bit. I'd very much 
like Location to be not just a string, but a record type. Ideally we 
could recover not just module name, line and character, but also the 
name of the function that takes the location. This would eliminate an 
entire swath of use-cases for Template Haskell. For example, I've worked 
out a template-haskell-free version of the Cloud Haskell closure API, 
which hopefully is getting merged in at some point. The major drawback 
it has is that the user is required to provide a globally-unique 
identifier for each closure, ideally stable across compilations. The 
current TH code solves this by grabbing the function and module name. If 
we could get direct access to these things without requiring template 
haskell, that would be quite nice. Other types of RPC libraries I've 
worked on could similarly benefit from this.

Cheers,
Gershom


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130226/ba7ea213/attachment.htm>


More information about the Haskell-Cafe mailing list