[Haskell-beginners] Module import problem
caseyrodarmor at gmail.com
Sun Sep 28 12:20:25 EDT 2008
On Sun, Sep 28, 2008 at 6:08 PM, Chry Cheng <chrycheng at gmail.com> wrote:
> "Casey Rodarmor" <caseyrodarmor at gmail.com> writes:
>> Hi there!
>> I have a problem with importing a module I'd like to use.
>> My working directory, ~/proj, contains:
>> ./Haskore -- a folder containing a version of haskore, this music thingy
>> ./test.hs -- random stuff using haskore
>> The main file in ~/proj/Haskore is ~/proj/Haskore/Haskore.hs, which
>> contains the following module declaration:
>>> module Haskore(module HaskoreLoader) where
>>> import HaskoreLoader
>> I've tried to put all the following in ~/proj/test.hs, with no luck:
>>> import Haskore -- Could not find module `Haskore':
>>> import Haskore.Haskore -- file name does not match module name `Haskore'
>> Am I doing something wrong? Is there a way to place a module in an
>> arbitrary directory, without having to modify it?
>> Thanks so much for your help!
>> Casey Rodarmor
>> Beginners mailing list
>> Beginners at haskell.org
> You have to tell GHC where to find Haskore. To do this, call ghc with the i option:
> ghc -iHaskore/
> then, import using:
> import Haskore
Thanks for the answer, everything works now :-)
I must admit, I'm a little disappointed if that's the only way to get
it to work. On the surface of things, I don't see why one can't just
put a Module in some/arbitrary/directory, and then import it as
some.arbitrary.directory.Module. The need to use a flag on the command
line seems a little unnecessary.
Can anyone give a little insight into why this decision was made?
More information about the Beginners