Is there a Haskell/ML-like compiler to C?

寵の児 提交于 2019-12-20 10:21:04

问题


People have written games for the iPhone in Scheme. Because (some) Scheme-compilers compile down to C, it was easy to mix with Objective-C and integrate with XCode.

I am aware of patches for Haskell and OCaml compilers to enable ARM/iOS-backends. But those appear unofficial and experimental/unstable.

I prefer a static haskell/ML-type type-system over Scheme's dynamic typing. Is there a stable ML/SML/Haskell compiler which generates C-code so that it can be used in a similar way as Scheme/Gambit-C?


回答1:


I can't help with ML, but have you looked at JHC? JHC is a whole-program optimizing Haskell compiler that targets portable C, and iPhone support can be added by putting

[iphone]
cc=arm-apple-darwin-gcc
merge=le32

in ~/.jhc/targets.ini

More Haskell information is on the Haskell wiki and the JHC manual.




回答2:


(I am not certain that this toolchain has been attempted specifically on the IPhone yet.)

MLTon is a whole-program optimizing Standard ML compiler. You can keep around your C code by passing -keep g to MLTon at compilation, e.g:

c:/Program Files (x86)/MLton/bin/mlton.bat" -verbose 1 -keep g test.sml

It can also generate ARM code natively.




回答3:


nhc98: http://www.haskell.org/nhc98/

Full Haskell '98. Of course many libs now rely on more advanced ghc-only features. But Haskell '98 is plenty capable for general purpose programming.



来源:https://stackoverflow.com/questions/4722439/is-there-a-haskell-ml-like-compiler-to-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!