I was intrigued when I heard that GHC can output a file to C .
The Glasgow Haskell Compiler (GHC) compiles to native code on a number of different architectures—as well as to ANSI C—using C-- as an intermediate language.
So I installed the Haskell Platform and created a simple .hs file.
main = putStrLn "Hello, World!"
And according to the manual.
-C Stop after generating C (.hc file)
Now I run the command.
ghc -C test.hs
But it doesn't create a .hc file, nor does it stop mid-compilation.
$ ls
test.exe test.hi test.hs test.o
--ddump-cmm
) or the assembly (-ddump-asm
) but I'm afraid that's as close as you get. GHC generates really weird code, but you can learn to make sense of "GHC-style" imperative code. – Wind