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

Twan van Laarhoven twanvl at gmail.com
Mon Feb 25 10:40:29 CET 2013


On 25/02/13 07:06, Michael Snoyman wrote:
> Quite a while back, Simon Hengel and I put together a proposal[1] for a new
> feature in GHC. The basic idea is pretty simple: provide a new pragma that could
> be used like so:
>
> error :: String -> a
> errorLoc :: IO Location -> String -> a
> {-# REWRITE_WITH_LOCATION error errorLoc #-}
>
> Then all usages of `error` would be converted into calls to `errorLoc` by the
> compiler, passing in the location information of where the call originated from.
> Our three intended use cases are:

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 #-}

I'm also pretty sure that something like this has been proposed in the past.


Twan



More information about the Haskell-Cafe mailing list