[GHC] #3185: Compiler error implies incorrect implicit import of a ((->)a) Monad instance

GHC trac at galois.com
Wed Apr 22 08:12:17 EDT 2009


#3185: Compiler error implies incorrect implicit import of a ((->)a) Monad
instance
-------------------+--------------------------------------------------------
Reporter:  jkff    |          Owner:          
    Type:  bug     |         Status:  new     
Priority:  normal  |      Component:  Compiler
 Version:  6.10.2  |       Severity:  normal  
Keywords:          |       Testcase:          
      Os:  Linux   |   Architecture:  x86     
-------------------+--------------------------------------------------------
 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)
 }}}

 Compile it:

 {{{
 jkff at 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3185>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list