|
too liberal handling of instance imports?: msg#00011lang.haskell.glasgow.bugs
I was pretty sure this is a well-known and long-standing bug, but I can't find it in the sf bug tracker, and the user guide "Known bugs" section claims in 12.1.1.5 "None known", so I thought I'd ask here. The problem, as I recall it, is that ghc's import chasing collects instances as it follows dependencies, without respecting the actual import relationships between modules. For instance, the following compiles, but shouldn't (in my understanding, at least:-): --------------------------------------------- module A where f = print ((Left "hi" >>= Right) :: Either String String) --------------------------------------------- module B where import Control.Monad.Error() --------------------------------------------- module Main where import B import A main = f --------------------------------------------- Could someone please confirm that this is a bug, not a mis- understanding? Switching the order of imports in Main should not have an impact on program correctness, but it does (win xp, ghci 6.4.1; missing instance (Monad (Either String))). Similarly, after a failed load (with flipped imports) in ghci, a simple :m +Control.Monad.Error :m -Control.Monad.Error :r should not succeed, but it does. In a larger program (think of A and B as independent sub-projects, from different vendors..), this is even harder to track (btw, can one infer the compilation order from ghc -M output? I was at a loss trying to find out why a certain module A was compiled at the time it was, for one order of imports, but not for another - when the compilation of A fails, the modules that caused A to be compiled have yet to appear in the output.. ). Cheers, Claus
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: ghc-pkg --global has strange semantics, Frederik Eaton |
|---|---|
| Next by Date: | Bug in GHC type system, Baltasar Trancon y Widemann |
| Previous by Thread: | RE: ghc-pkg --global has strange semantics, Simon Marlow |
| Next by Thread: | RE: too liberal handling of instance imports?, Simon Marlow |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |