Created
June 22, 2014 08:37
-
-
Save fmap/7e424a1147ee3edbd988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
import Language.Haskell.TH (ExpQ, Exp(LamE, VarE, TupE), Pat(VarP), newName) | |
tuple :: Int -> ExpQ | |
tuple n = do | |
x <- newName "x" | |
return $ LamE [VarP x] (TupE . replicate n $ VarE x) | |
-- $(tuple 3) "fnord" == ("fnord","fnord","fnord") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment