开发者

no EmptyL in data.sequence?

I'm currently trying to solve problem 7 on project euler with ideon. I'm implementing a prime numbers generator. Here is what I have:

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 = hea开发者_Python百科d $ foldr (.) id (replicate 1000 nextPrime) [2]

main = putStr $ show result

The problem is, ideone returns me a compilation error: prog.hs:1:42: Module Data.Sequence' does not exportEmptyL' (see https://ideone.com/vlSNX#view_edit_box).

Have I done something wrong, or is there an issue with ideone?


EmptyL is a data constructor for the ViewL type. The syntax to import it is:

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

or just

import Data.Sequence (ViewL (..))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜