Skip to content

Instantly share code, notes, and snippets.

@sw17ch
Created May 16, 2013 03:55
Show Gist options
  • Save sw17ch/5589272 to your computer and use it in GitHub Desktop.
Save sw17ch/5589272 to your computer and use it in GitHub Desktop.
Just discovered language-c-quote. Wow.
{-# LANGUAGE QuasiQuotes #-}
module Data.Cauterize.Generators.C where
import Text.PrettyPrint.Mainland
import Language.C.Quote.C
genC :: IO ()
genC = print $ ppr f
where
ty = [cty|int|]
idnt = "x"
fname = "foo"
param = [cparam|$ty:ty $id:idnt|]
f = [cfun|$ty:ty $id:fname($param:param) { return $id:idnt; }|]
{-
Result of this:
int foo(int x)
{
return x;
}
-}
@jasonroelofs
Copy link

Confused, is this Haskell generated from C code or vice versa?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment