[Template-haskell] Newbie question - class dependencies

Hugo Pacheco hpacheco at gmail.com
Sun Jul 8 12:01:21 EDT 2007


Hi,
I'm wondering if I can (ab)use from TH in order to generalize a
context-dependant function into a generic function without that context, as
long as I now that the arguments I'm applying the function to belong to the
class.

I guess this would work similarly to an automatic instance generation
example.

My example would be:

module Main where

myprint :: a -> String
myprint = show

main = do
    putStr $ myprint 1
    putStr $ myprint '2'

My ideia would be to stage the computation of *myprint* until it is called,
where the *Show* instance can be satisfied.

hugo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/template-haskell/attachments/20070708/3c946db4/attachment.htm


More information about the template-haskell mailing list