Skip to content

Instantly share code, notes, and snippets.

@xenophobia
Created April 14, 2012 07:10
Show Gist options
  • Save xenophobia/2382581 to your computer and use it in GitHub Desktop.
Save xenophobia/2382581 to your computer and use it in GitHub Desktop.
{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
import Language.Haskell.TH
import Control.Monad
mapT :: Int -> ExpQ -> ExpQ
mapT count f = do
vars <- replicateM count $ newName "x"
lamE [tupP $ map varP vars] (tupE $ map (appE f . varE) vars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment