Skip to content

Instantly share code, notes, and snippets.

@supki
Created May 26, 2012 07:32
Show Gist options
  • Save supki/2792778 to your computer and use it in GitHub Desktop.
Save supki/2792778 to your computer and use it in GitHub Desktop.
Construct $name = putStrLn "$name" function via Template Haskell.
{-# LANGUAGE TemplateHaskell #-}
module Pisya where
import PisyaTH
$(anal ["pemis", "gnoi", "sosiska", "sobachka"])
{-# LANGUAGE TemplateHaskell #-}
module PisyaTH where
import Language.Haskell.TH
anal xs = mapM func xs
where func xs = funD (mkName xs) [clause [] (normalB $ appE (varE (mkName "putStrLn")) [e| xs |]) []]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment