Opened 9 years ago

Closed 9 years ago

#3185 closed bug (invalid)

Compiler error implies incorrect implicit import of a ((->)a) Monad instance

Reported by: jkff Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.10.2
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Take the following (incorrect) source:

fun :: Integer -> String
fun x = "123"

main = do
  s <- readFile ""
  let m = read s
  writeFile "file.out" (return fun m)

Compile it:

jkff@jkff-laptop:~$ ghci tmp.hs
GHCi, version 6.10.2:  :? 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 )

    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.

Change History (1)

comment:1 Changed 9 years ago by jkff

Resolution: invalid
Status: newclosed

Oops, people explained to me the real reason of this behavior, which turned out to be quite logical. Closing as invalid.

Note: See TracTickets for help on using tickets.