[Haskell-cafe] Template Haskell vs Rewrite Rules?
jake.mcarthur at gmail.com
Thu Apr 19 18:58:38 CEST 2012
I once experimented with something similar. This is a preprocessor.
This was a long time ago, and I don't use it.
On Thu, Apr 19, 2012 at 8:40 AM, Ismael Figueroa Palet
<ifigueroap at gmail.com> wrote:
> Hi Michael!
> Thanks (again) for your answer.
> 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?
> Thanks for the zeroth reference too, one question remains for me: what are
> the constrasts/differences between TH and RewriteRules? :-)
> 2012/4/19 Michael Sloan <mgsloan at gmail.com>
>> You're in luck! This is something I've wanted to implement before in
>> the past, and your email reminded me. While pretty awful, it could be
>> used for doing some interesting value-interception instrumentation in
>> Haskell. Recently I've been messing with TH a lot, so this initial
>> implementation was rather straightforward.
>> Note: Relatively untested implementation, let me know if you find any
>> It only does this transformation to direct function application,
>> unfortunately. In order to properly overload apply for infix
>> operators, you'll need to be able to resolve fixities at compile time.
>> This could be done by using the code in
>> and using the fixity information yielded by TH's "reify". Someone
>> aught to have done this before, but I haven't seen it.
>> Handling the applications involved in do-notation, comprehensions,
>> enumerations, and anything else that's such direct syntax sugar would
>> also be a bit of work (but could be very useful for other TH
>> quasiquoting stuff!).
>> You might also be interested in this:
>> Hope that helps!
>> -Michael Sloan
>> On Wed, Apr 18, 2012 at 9:49 AM, Ismael Figueroa Palet
>> <ifigueroap at gmail.com> wrote:
>> > I'm working on getting annotated versions of all instances of a function
>> > of
>> > a typeclass, and was wondering what are the relation/differences between
>> > Template Haskell and the Rewrite Rules section. Of course this is
>> > specific
>> > to GHC.
>> > Another question, in Racket, primitive function application is denoted
>> > #%app. And using macros I can re-export #%app to be a different function
>> > f,
>> > so a program:
>> > (g a) is rewritten into (f g a)
>> > is there a way to do the same thing using TH or Rewrite Rules?
>> > Thanks
>> > --
>> > Ismael
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe