codesnippets:templatehaskell
This is an old revision of the document!
TemplateHaskell
Creating code at compile time
- Example, creates a curry function for arbitrary large curry functions
module Curry ( curryN ) where import Control.Monad import Language.Haskell.TH curryN :: Int -> Q Exp curryN n = do f <- newName "f" xs <- replicateM n (newName "x") let args = map VarP (f:xs) ntup = TupE (map (pure . VarE) xs) return $ LamE args (AppE (VarE f) ntup)
You could leave a comment if you were logged in.
codesnippets/templatehaskell.1651015723.txt.gz · Last modified: (external edit)
