[Haskell-cafe] RFC: rewrite-with-location proposal
Alexander Kjeldaas
alexander.kjeldaas at gmail.com
Mon Feb 25 15:15:45 CET 2013
My initial thought as I read the proposal was to represent currentLocation
as a lexical bound variable, thus "error" is rewritten to the expression:
let currentLocation = "someplace.hs:123"
in errorLoc currentLocation
there is no referntial transparency issue in that because there is no
global function "currentLocation", it's a lexically bound variable in the
rewrite environment.
Btw, I'm happy that people want to implement whatever they feel like. Feel
free to do whatever makes sense. My comments are not meant to discourage
this :-)
Alexander
On Mon, Feb 25, 2013 at 2:02 PM, Petr Pudlák <petr.mvd at gmail.com> wrote:
>
>
>
> 2013/2/25 Michael Snoyman <michael at snoyman.com>
>
>>
>> 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?
>>
>
> Just a remark: 'currentLocation' is not a function (it's a special
> keyword) but behaves like one - it returns some kind of value. But it's not
> referentially transparent - it returns a different value depending on where
> it's used. This is something that I really don't expect from Haskell. So
> having it return `IO Location` seems therefore much better option. And if
> someone really wants to get the location as a pure value, (s)he can simply
> wrap it with `unsafePerformIO`, which signals code readers to be careful
> with that part.
>
> Best regards,
> Petr
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130225/07159940/attachment.htm>
More information about the Haskell-Cafe
mailing list