Created
May 16, 2013 03:55
-
-
Save sw17ch/5589272 to your computer and use it in GitHub Desktop.
Just discovered language-c-quote. Wow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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; | |
} | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Confused, is this Haskell generated from C code or vice versa?