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

Joachim Breitner mail at joachim-breitner.de
Mon Feb 25 10:17:11 CET 2013


Hi,

Am Montag, den 25.02.2013, 10:13 +0100 schrieb Simon Hengel:
> On Mon, Feb 25, 2013 at 09:57:04AM +0100, Joachim Breitner wrote:
> > Hi,
> > 
> > Am Montag, den 25.02.2013, 08:06 +0200 schrieb Michael Snoyman:
> > > 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 #-}
> > 
> > in light of attempts to split base into a pure part (without IO) and
> > another part, I wonder if the IO wrapping is really necessary.
> > 
> > Can you elaborate the reason why a simple "Location ->" is not enough?
> 
> The IO helps with reasoning.  Without it you could write code that does
> something different depending on the call site.  Here is an example:
> 
> 
>     someBogusThingy :: Int
>     someBogusThingy = ..
> 
>     someBogusThingyLoc :: Location -> Int
>     someBogusThingyLoc loc
>       | (even . getLine) loc = 23
>       | otherwise            = someBogusThingyLoc
> 
>     {-# REWRITE_WITH_LOCATION someBogusThingy someBogusThingyLoc #-}
> 
> Now someBogusThingy behaves different depending on whether the call site
> is on an even or uneven line number.  Admittedly, the example is
> contrived, but I hope it illustrates the issue.

ok, I mentally applied REWRITE_WITH_LOCATION before wondering about
reasoning about the code. But you are right that it would be nice if the
rewrite rule would be valid as well.

I’m not firmly commited either way.

Greetings,
Joachim

-- 
Joachim "nomeata" Breitner
Debian Developer
  nomeata at debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nomeata at joachim-breitner.de | http://people.debian.org/~nomeata

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130225/5d142712/attachment.pgp>


More information about the Haskell-Cafe mailing list