packages feed

ghc-exactprint-1.9.0.0: tests/examples/pre-ghc910/TupleN.hs

{-# LANGUAGE TemplateHaskell #-}
module TupleN where
import Language.Haskell.TH

tuple :: Int -> ExpQ
tuple n = [|\list -> $(tupE (exprs [|list|])) |]
  where
    exprs list = id [infixE (Just (list))
                           (varE '(!!))
                           (Just (litE $ integerL (toInteger num)))
                      | num <- [0..(n - 1)]]