raw-feldspar-0.1: src/Data/Inhabited/TH.hs
module Data.Inhabited.TH where
import Language.Haskell.TH
import Language.Syntactic.TH
inhabitedTupleInstances :: Int -> DecsQ
inhabitedTupleInstances n = return
[ instD
[AppT (ConT (mkName "Inhabited")) (VarT a) | a <- take w varSupply]
( AppT
(ConT (mkName "Inhabited"))
(foldl AppT (TupleT w) (map VarT $ take w varSupply))
)
[ FunD
(mkName "example")
[ Clause
[]
(NormalB $ TupE $ map VarE $ replicate w (mkName "example"))
[]
]
]
| w <- [2..n]
]