first I’d like to appreciate your time answering my question.
First, please take a quick look at my code. You don’t have to understand the code, just pay attention to the types.
This return an error that says,
Couldn't match expected type `Int' with actual type `Integer'
Expected type: [Int]
Actual type: [Integer]
In the first argument of `myfun', namely `primes'
In the expression: myfun primes
Failed, modules loaded: none.
I can run this successfully with no error if I change the types to Int instead of Integer, so for example, “primes :: [Int]”
However, I am required to keep it integer for the program to be able to take large numbers.
Thank you very much for your help in advance.
The error is coming from
(!!)inmyfun:which a newer GHC would have probably informed you about (I think). Try this:
fromIntegeris polymorphic in its result type, so here the type system infers you want anInt. hoogle knows a lot about these kind of questions.