Compiler error implies incorrect implicit import of a ((->)a) Monad instance
|Reported by:||jkff||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Rev(s):|
Take the following (incorrect) source:
fun :: Integer -> String fun x = "123" main = do s <- readFile "file.in" let m = read s writeFile "file.out" (return fun m)
jkff@jkff-laptop:~$ ghci tmp.hs GHCi, version 6.10.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( tmp.hs, interpreted ) tmp.hs:8:31: Couldn't match expected type `String' against inferred type `Integer -> String' In the first argument of `return', namely `fun' In the second argument of `writeFile', namely `(return fun m)' In the expression: writeFile "file.out" (return fun m) Failed, modules loaded: none.
The error looks like if the compiler has implicitly imported Control.Monad.Instances including the instance for ((->)a). It shouldn't have done so, because Prelude doesn't include this instance. NoImplicitPrelude doesn't help.