问题描述
我必须遵循尝试将其编译为C的Haskell程序。
我已经查看过,但在那里找不到答案。
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现在是一种特殊用途的技巧,主要用于在新架构上进行引导。因此,默认情况下不支持。 提供了一些在启用此支持的情况下自行构建GHC的说明;标准版本和可编译为C的版本之间的主要区别是使用-enable-unregisterified
标志进行配置。另请参见-这非常复杂,因此,如果您决定这样做,可以方便使用。
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!