[Haskell-cafe] RFC: rewrite-with-location proposal
Alexander Kjeldaas
alexander.kjeldaas at gmail.com
Mon Feb 25 10:21:26 CET 2013
Immediately, the alternative of introducing bound variables in the
environment that is available to rewrite rules comes to mind as a more
general way of doing this.
So this example from the GHC docs:
{-# RULES
"map/map" forall f g xs. map f (map g xs) = map (f.g) xs
"map/append" forall f xs ys. map f (xs ++ ys) = map f xs ++ map f ys
#-}
For some source:
map f (map g xs)
it is translated into:
let location = "somefile.hs:234"
in map (f.g) xs
So for error:
{-# RULES
"error/location" error s = errorLoc location s
#-}
is translated into:
let location = "somefile.hs:345"
in errorLoc location s
Alexander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130225/f68315a9/attachment.htm>
More information about the Haskell-Cafe
mailing list