
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
2013/2/25 Michael Snoyman
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