Template haskell - generate functions

Run Settings
LanguageHaskell
Language Version
Run Command
{-# LANGUAGE TemplateHaskell #-} import Functions $(generateFunctions [("foo", "meringue"), ("bar", "sauce")]) main = putStrLn $ concat [foo, "-", bar]
module Functions ( generateFunctions ) where import Language.Haskell.TH generateFunctions :: [(String, String)] -> Q [Dec] generateFunctions = mapM generate where generate (name, val) = funD (mkName name) [fnClause val] fnClause val = clause [] (fnBody val) [] fnBody val = normalB $ litE $ stringL val
Editor Settings
Theme
Key bindings
Full width
Lines