3 ms·
That's a good question, but the only answer in the thread is something that can easily be implemented in Template Haskell. genFoo :: String -> DecsQ ge
by TheCoelacanth 13y ago
That's a good question, but the only answer in the thread is something that can easily be implemented in Template Haskell.
genFoo :: String -> DecsQ
genFoo name = [d| instance Foo $(return t) where quux = $(return f) |]
where f = VarE . mkName ("quuxify" ++ name)
t = ConT (mkName name)
genFoos :: [String] -> DecsQ
genFoos = foldl' (liftM2 (++)) (return []) . map genFoo