id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
23	fundep bug across module boundary	nobody	nobody	"{{{
Consider these two files:

BugImport.hs

module BugImport where
import IOExts

class Monad m => RefMonad m r | m -> r where
  newRef :: a -> m (r a)
  readRef :: r a -> m a
  writeRef :: r a -> a -> m ()

instance RefMonad IO IORef where
  newRef = newIORef
  readRef = readIORef
  writeRef = writeIORef

Bug.hs

import IOExts
import BugImport

foo () = do r <- newRef 1
               readRef r

main = do i <- foo ()
              print i

The type of foo is 

(RefMonad m r, Num a) => () -> m a

so the fundep is needed to resolve the overloading. Bug
ghc complains:

Ambiguous type variable(s) 'r' in the constraint
`RefMonad IO r'
arising from use of `foo' at Bug.hs:7
In a do statement: i <- foo ()

i.e. the fundep is lost. This is compiled with
ghc5.02.1, -package 
lang, -fglasgow-exts.

If all the definitions are placed in one module, on the
other hand,
then compilation succeeds. Alternatively, if these two
modules are
loaded into ghci, then they are accepted.
}}}"	bug	closed	normal		Compiler	5.02	None										
