I'm struggling to translate my definition of the Sieve of Eratosthenes into Idris. Here is the function so far:
%default total
eratos : Nat -> (l : List Nat) -> { auto ok: NonEmpty l } -> List Nat
eratos limit (prime :: rest) =
if prime * prime > limit -- if we've passed the square root of n
then prime :: xs -- then we're done!
-- otherwise, subtract the multiples of that prime and recurse
else prime :: (eratos limit (rest \\ [prime^2,prime^2+prime..limit]))
main : IO ()
main = printLn $ eratos [2..100]
unfortunately, I'm getting a strange compiler error:
idris --build euler.ipkg
./E003.idr:18:18: error: expected: ")",
dependent type signature
else prime :: (eratos n (xs \\ [prime^2,prime^2+prime..n]))
Why is the compiler looking for a type signature?