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

Michael Snoyman michael at snoyman.com
Mon Feb 25 13:41:19 CET 2013


On Mon, Feb 25, 2013 at 2:15 PM, Alexander Kjeldaas <
alexander.kjeldaas at gmail.com> wrote:

> On Mon, Feb 25, 2013 at 12:46 PM, Simon Hengel <sol at typeful.net> wrote:
>
>> On Mon, Feb 25, 2013 at 10:40:29AM +0100, Twan van Laarhoven wrote:
>> > I think there is no need to have a separate REWRITE_WITH_LOCATION
>> > rule. What if the compiler instead rewrites 'currentLocation' to the
>> > current location? Then you'd just define the rule:
>> >
>> > {-# REWRITE "errorLoc" error = errorLoc currentLocation #-}
>>
>> REWRITE rules are only enabled with -O.  Source locations are also
>> useful during development (when you care more about compilation time
>> than efficient code and hence use -O0).  So I'm not sure whether it's a
>> good idea to lump those two things together.
>>
>>
> I could imagine that source locations being useful when debugging rewrite
> rules for example.
>
> I think your argument makes sense, but why not fix that specifically?
>
> {-# REWRITE ALWAYS "errorLoc" error = errorLoc currentLocation #-}
>
>
>
At that point, we've now made two changes to REWRITE rules:

1. They can takes a new ALWAYS parameters.
2. There's a new, special identifier currentLocation available.

What would be the advantage is of that approach versus introducing a single
new REWRITE_WITH_LOCATION pragma?

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130225/863ccffb/attachment.htm>


More information about the Haskell-Cafe mailing list