Hi Michael!<div><br></div><div>Thanks (again) for your answer.</div><div>I'm not quite confident using TH yet, but it seems in your code you must define an 'app' function, and then use [overloadedApp|... |] as a quasiquoteator to inject the overloaded app, right?</div>
<div><br></div><div>Thanks for the zeroth reference too, one question remains for me: what are the constrasts/differences between TH and RewriteRules? :-)</div><div><br></div><div><br><div class="gmail_quote">2012/4/19 Michael Sloan <span dir="ltr"><<a href="mailto:mgsloan@gmail.com" target="_blank">mgsloan@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You're in luck! This is something I've wanted to implement before in<br>
the past, and your email reminded me. While pretty awful, it could be<br>
used for doing some interesting value-interception instrumentation in<br>
Haskell. Recently I've been messing with TH a lot, so this initial<br>
implementation was rather straightforward.<br>
<br>
<a href="https://github.com/mgsloan/overload-app/blob/master/src/Language/Haskell/TH/OverloadApp.hs" target="_blank">https://github.com/mgsloan/overload-app/blob/master/src/Language/Haskell/TH/OverloadApp.hs</a><br>
<br>
Usage:<br>
<a href="https://github.com/mgsloan/overload-app/blob/master/examples/Example1.hs" target="_blank">https://github.com/mgsloan/overload-app/blob/master/examples/Example1.hs</a><br>
<br>
Note: Relatively untested implementation, let me know if you find any problems!<br>
<br>
It only does this transformation to direct function application,<br>
unfortunately. In order to properly overload apply for infix<br>
operators, you'll need to be able to resolve fixities at compile time.<br>
This could be done by using the code in<br>
<a href="http://hackage.haskell.org/trac/haskell-prime/wiki/FixityResolution" target="_blank">http://hackage.haskell.org/trac/haskell-prime/wiki/FixityResolution</a><br>
and using the fixity information yielded by TH's "reify". Someone<br>
aught to have done this before, but I haven't seen it.<br>
<br>
Handling the applications involved in do-notation, comprehensions,<br>
enumerations, and anything else that's such direct syntax sugar would<br>
also be a bit of work (but could be very useful for other TH<br>
quasiquoting stuff!).<br>
<br>
You might also be interested in this:<br>
<br>
<a href="http://hackage.haskell.org/package/zeroth-2009.6.23.3" target="_blank">http://hackage.haskell.org/package/zeroth-2009.6.23.3</a><br>
<br>
Hope that helps!<br>
<br>
-Michael Sloan<br>
<div><div><br>
On Wed, Apr 18, 2012 at 9:49 AM, Ismael Figueroa Palet<br>
<<a href="mailto:ifigueroap@gmail.com" target="_blank">ifigueroap@gmail.com</a>> wrote:<br>
> I'm working on getting annotated versions of all instances of a function of<br>
> a typeclass, and was wondering what are the relation/differences between<br>
> Template Haskell and the Rewrite Rules section. Of course this is specific<br>
> to GHC.<br>
><br>
> Another question, in Racket, primitive function application is denoted<br>
> #%app. And using macros I can re-export #%app to be a different function f,<br>
> so a program:<br>
><br>
> (g a) is rewritten into (f g a)<br>
><br>
> is there a way to do the same thing using TH or Rewrite Rules?<br>
><br>
> Thanks<br>
><br>
> --<br>
> Ismael<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Ismael<br><br>
</div>