
On 25/02/13 13:41, Michael Snoyman wrote:
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?
You are probably right. Ghc already has some logic in place for doing this with 'assert': -- Return an expression for (assertError "Foo.hs:27") mkAssertErrorExpr = .. finishHsVar name = do { ignore_asserts <- goptM Opt_IgnoreAsserts ; if ignore_asserts || not (name `hasKey` assertIdKey) then return (HsVar name, unitFV name) else do { e <- mkAssertErrorExpr ; return (e, unitFV name) } } So the check is name `hasKey` assertIdKey. I.e. it is a literal check whether the name is assert. Maybe that could be extended to check whether the name is declared as assert-like. Of course the real solution is to have proper stack traces. Twan