
17 Jul
2010
17 Jul
'10
6:45 p.m.
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
5421
Age (days ago)
5421
Last active (days ago)
0 comments
1 participants
participants (1)
-
Alex Rozenshteyn