[Haskell-cafe] Re: Template haskell instance checking

heatsink kyz7tnt02 at sneakemail.com
Thu Mar 2 14:00:26 EST 2006

>>Is there a way, in template haskell, to find out what instance 
>Not at the moment, I'm afraid, but it's the kind of question that TH
>ought to be able to answer.  I could offer guidance if someone wanted to
>implement it.

I have a concern about how computed class memberships would work.  Class 
membership is global, so creating a class instance is a globally visible 
side effect of TH code.  Once you add the ability for TH code to inspect 
instances, the side effects mean that the order in which different splices 
get executed affects the compiler output.  This is probably a bad thing.  
I'm not sure how it could be designed to work nicely; the only approach I 
can think of at the moment is to give splice evaluation a dataflow execution 
semantics that causes splices to execute and possibly reexecute at the 
"appropriate" times.  I'd like to hear if anyone else has ideas on how to 
solve this problem.

.....tian: I think that's a good point in general about conditional code 
generation.  I wasn't thinking about conditional generation based on 
compile-time settings, but rather reusable TH library functions that inspect 
the class memberships of their arguments.  Of course, this can be used for 
good or evil :)


More information about the Haskell-Cafe mailing list