将Haskell程序编译为C [英] Compile Haskell programs to C

查看:111
本文介绍了将Haskell程序编译为C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须遵循尝试将其编译为C的Haskell程序。
我已经查看过此SO帖子,但在那里找不到答案。

I have to following Haskell program I'm trying to compile to C. I've looked at this SO post, but could not get an answer there.

quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
  where
    lesser  = filter (<  p) xs
    greater = filter (>= p) xs

main = print(quicksort([5,2,1,0,8,3]))

这是我尝试的内容:

$ ghc -C main.hs

我得到的是:

ghc: the option -C is only available with an unregisterised GHC
Usage: For basic information, try the `--help' option.

这有点奇怪,因为当我查看帮助时会看到以下内容:

This is a bit weird because when I look at the help I see this:


-C生成C(.hc输出)后停止

-C stop after generating C (.hc output)


推荐答案

编译为C现在是一种特殊用途的技巧,主要用于在新架构上进行引导。因此,默认情况下不支持。 GHC Wiki 提供了一些在启用此支持的情况下自行构建GHC的说明;标准版本和可编译为C的版本之间的主要区别是使用-enable-unregisterified 标志进行配置。另请参见构建GHC的完整页面列表-这非常复杂,因此,如果您决定这样做,可以方便使用。

Compiling to C is now a special-purpose trick, used primarily for bootstrapping on new architectures. Consequently by default it is not supported. The GHC wiki has some instructions for building GHC yourself with this support enabled; the chief difference between a standard build and a build that enables compiling to C is to configure with the --enable-unregisterised flag. See also the full list of pages on building GHC -- it is quite complicated, so you'll want to keep this handy if you decide to do so.

这篇关于将Haskell程序编译为C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆