我目前正在尝试使用ideon解决项目euler上的问题7。我正在实现素数生成器。这就是我所拥有的:
import Data.Sequence ((|>), empty, viewl, EmptyL, length, index)
isprime primes n = let
factors = viewl primes
inner EmptyL = True
inner (factor :< others) = if n `mod` factor == 0 then False else inner others
in inner primes
nextPrime primes = let
findPrime n = if isPrime primes n then n else findPrime (n + 1)
in primes |> (findPrime $ primes `index` (length primes + 1))
result = head $ foldr (.) id (replicate 1000 nextPrime) [2]
main = putStr $ show result
问题是,ideone返回一个编译错误:prog.hs:1:42:模块Data.Sequence' does not export
EmptyL'(参见https://ideone.com/vlSNX#view_edit_box)。
我做错了什么,或者是否存在ideone问题?
答案 0 :(得分:4)
EmptyL
是ViewL
类型的数据构造函数。导入它的语法是:
import Data.Sequence (ViewL (EmptyL, (:<))
或只是
import Data.Sequence (ViewL (..))