gpt4 book ai didi

haskell - GHC链接问题

转载 作者:行者123 更新时间:2023-12-02 10:41:43 24 4
gpt4 key购买 nike

我正在尝试编译以下代码。

import Data.List
import Data.Ord
import qualified Data.MemoCombinators as Memo

collatzLength :: Int -> Int
collatzLength = Memo.arrayRange (1, 1000000) collatzLength'
where
collatzLength' 1 = 1
collatzLength' n | odd n = 1 + collatzLength (3 * n + 1)
| even n = 1 + collatzLength (n `quot` 2)

main = print $ maximumBy (comparing fst) $ [(collatzLength n, n) | n <- [1..1000000]]

Haskell 编译器吐出:
euler14.o: In function `s1pw_info':
(.text+0x8dd): undefined reference to `__stginit_datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_'
euler14.o: In function `rfX_info':
(.text+0x35d): undefined reference to `datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_arrayRange_info'
euler14.o: In function `rfX_srt':
(.data+0x4c): undefined reference to `datazmmemocombinatorszm0zi4zi1_DataziMemoCombinators_arrayRange_closure'
collect2: ld returned 1 exit status

我尝试谷歌搜索,但无济于事。有什么地方可以查到这些错误吗?他们的意思是什么?

最佳答案

你必须用 --make 编译旗帜。

关于haskell - GHC链接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7140617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com