data.sequence中没有EmptyL?

时间:2011-06-20 15:01:50

标签: haskell primes

我目前正在尝试使用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问题?

1 个答案:

答案 0 :(得分:4)

EmptyLViewL类型的数据构造函数。导入它的语法是:

import Data.Sequence (ViewL (EmptyL, (:<))

或只是

import Data.Sequence (ViewL (..))