Type specification error


I’m encountering a baffling type error involving the following function:

roll :: Int -> Int -> (List Int -> Int) -> Effect Int
roll m n s = s <$> (sequence $ replicate n $ randomInt 1 m)

the error is

  Could not match type


  with type


while trying to match type List Int
  with type List Int
while checking that expression (apply sequence) ((apply (replicate n)) ((randomInt 1) m))
  has type t0 (List Int)
in value declaration roll

where t0 is an unknown type

when I remove the type signature and check the type, it’s

forall a. Int -> Int -> (List Int -> a) -> Effect a

Am I not allowed to specify the type further?


It’s hard to know without seeing the whole file, but you are probably mixing up strict and lazy lists (strict data type, with the lazy functions or vice versa). The error isn’t printing the qualification. It’s confusing.

1 Like
import Data.List.Lazy.Types as L
roll :: Int -> Int -> (L.List Int -> Int) -> Effect Int

seemed to do the trick, so I guess laziness was the issue.



We have an issue for this, it’s definitely a pretty common problem! It’s high on my list of things-to-fix-when-I-get-a-chance.