I'm trying to learn Template Haskell.

I decided to try to write a mapTup function which takes function and a tuple (e.g. mapTup id (1,"hi",'a') ) and, well, applies the function to each cell.

The closest I've gotten so far is this:

> {-# LANGUAGE TemplateHaskell #-}
> module MapTup
> where
> import Language.Haskell.TH
> import Control.Monad
> mapTup fun tup = do
>   funE <- runQ $ [| $fun |]
>   TupE tupContents <- runQ $ [| $tup |]
>   return $ TupE $ map (AppE funE) tupContents

The problem is that I can't figure out how to get the representation of the values bound to fun and tup.

Sorry if I'm wording this badly.  My head hurts from meta-programming ;)

--
          Alex R