
#10987: -i option requires named module -------------------------------------+------------------------------------- Reporter: crockeea | Owner: osa1 Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): Here's one more thing about this issue. In the same layout: {{{ ➜ trac10987 ghci -itest Bar.hs GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help <no location info>: can't find file: Bar.hs Failed, modules loaded: none. }}} I'd think this is OK, but the user manuals says: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/separate- compilation.html#search-path
In --make mode or GHCi, GHC will look for a source file for Foo and arrange to compile it first.
GHC uses the same strategy in each of these cases for finding the appropriate file.
This strategy is as follows: GHC keeps a list of directories called the search path. For each of these directories, it tries appending basename.extension to the directory, and checks whether the file exists. The value of basename is the module name with dots replaced by the directory separator ('/' or '\', depending on the system), and extension is a
... source
extension (hs, lhs) if we are in --make mode or GHCi, or hisuf otherwise.
...
-idirs This flag appends a colon-separated list of dirs to the search path.
From the user manual is seems like GHC should have looked into directories in `-i`. We should either update the user manual or modify GHC. Personally, I think GHC should never use `-i` when looking for files, and it should never look for files unless the input has a file format. Otherwise there'll always be some confusing when a file is found, but module loder could also find the same file, because file loader makes no assumptions on what module to find in the file but module loader makes an assumption about this, leading to different outcomes depending on which one runs. Also, man page says "finding imports" for `-i` and it doesn't say anything about "search path" or how files are searched etc. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10987#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler