Skip to content

Instantly share code, notes, and snippets.

@haitlahcen
Created January 26, 2019 15:08
Show Gist options
  • Save haitlahcen/de33a593added86f86fc9a126d5b4164 to your computer and use it in GitHub Desktop.
Save haitlahcen/de33a593added86f86fc9a126d5b4164 to your computer and use it in GitHub Desktop.
# ======================================== header.h =============================================
#define TRUE 1
# ======================================== X.hs =================================================
module X where
x = 1
# ======================================== Test.hs ==============================================
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE CPP #-}
module Test where
import X
import GHC.Types
import Control.Monad
import Language.Haskell.TH
#include "header.h"
curryN :: Int -> Q Exp
curryN n = do
f <- newName "f"
xs <- replicateM n (newName "x")
let args = map VarP (f:xs)
ntup = TupE (map VarE xs)
return $ LamE args (AppE (VarE f) ntup)
data List a = Nil | Cons a (List a)
x = Cons 4 (Cons 2 Nil)
y = TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment