[Haskell-cafe] RFC: rewrite-with-location proposal
Roman Cheplyaka
roma at ro-che.info
Mon Feb 25 16:59:11 CET 2013
* Petr Pudlák <petr.mvd at gmail.com> [2013-02-25 14:02:28+0100]
> 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.
Wrapping it in IO doesn't make it any more referentially transparent, if
you think about it.
Roman
More information about the Haskell-Cafe
mailing list