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 export
EmptyL' (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 (..))
精彩评论