[Haskell-beginners] Template Haskell confusion
Alex Rozenshteyn
rpglover64 at gmail.com
Sat Jul 17 18:45:17 EDT 2010
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100717/24c0f1d5/attachment.html
More information about the Beginners
mailing list