Module structure

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Module structure

Colin Paul Adams
If I want to write part of the code for my program as a library, and
so put those modules into a hierarchical module structure (with the
non-library code in no module), do I have to structure the directories
in a special way to get the module search to work?
--
Colin Adams
Preston Lancashire
Reply | Threaded
Open this post in threaded view
|

Module structure

Chaddaï Fouché
On Fri, Feb 27, 2009 at 5:36 PM, Colin Paul Adams
<[hidden email]> wrote:
> If I want to write part of the code for my program as a library, and
> so put those modules into a hierarchical module structure (with the
> non-library code in no module), do I have to structure the directories
> in a special way to get the module search to work?

Yes, module My.Pretty.Little.Module must be in file
"My/Pretty/Little/Module.hs" in one of the root directories (which can
be specified on the command line to ghc, or in the .cabal file if you
use an unusual directory structure).
Note that this only apply before compiling, the executable is independent.

--
Jeda?
Reply | Threaded
Open this post in threaded view
|

Module structure

Colin Paul Adams
>>>>> "Chadda?" == Chadda? Fouch? <[hidden email]> writes:

    Chadda?> On Fri, Feb 27, 2009 at 5:36 PM, Colin Paul Adams
    Chadda?> <[hidden email]> wrote:
    >> If I want to write part of the code for my program as a
    >> library, and so put those modules into a hierarchical module
    >> structure (with the non-library code in no module), do I have
    >> to structure the directories in a special way to get the module
    >> search to work?

    Chadda?> Yes, module My.Pretty.Little.Module must be in file
    Chadda?> "My/Pretty/Little/Module.hs" in one of the root
    Chadda?> directories (which can be specified on the command line
    Chadda?> to ghc, or in the .cabal file if you use an unusual
    Chadda?> directory structure).  Note that this only apply before
    Chadda?> compiling, the executable is independent.

Thank you.
Where do I find out what the root directories are? Is mt project
directory one of them?
--
Colin Adams
Preston Lancashire
Reply | Threaded
Open this post in threaded view
|

Module structure

David Frey
In reply to this post by Chaddaï Fouché
On Fri, 27 Feb 2009 18:26:51 +0100, Chadda? Fouch?
<[hidden email]> wrote:

> On Fri, Feb 27, 2009 at 5:36 PM, Colin Paul Adams
> <[hidden email]> wrote:
>> If I want to write part of the code for my program as a library, and
>> so put those modules into a hierarchical module structure (with the
>> non-library code in no module), do I have to structure the directories
>> in a special way to get the module search to work?
>
> Yes, module My.Pretty.Little.Module must be in file
> "My/Pretty/Little/Module.hs" in one of the root directories (which can
> be specified on the command line to ghc, or in the .cabal file if you
> use an unusual directory structure).
> Note that this only apply before compiling, the executable is
independent.

This last line sounds a bit fishy to me.  I think what would happen here is
that you would create a separate module, but when your application is
linked, any code that is used from that module would be compiled and
included into your binary.  I suspect that what Colin may have been looking
for are instructions on how to create a standalone library that his
application can dynamically link to.  I'm curious about this as well.
Reply | Threaded
Open this post in threaded view
|

Module structure

Colin Paul Adams
>>>>> "David" == David Frey <[hidden email]> writes:

    David> I suspect that what Colin may have been
    David> looking for are instructions on how to create a standalone
    David> library that his application can dynamically link to.  I'm
    David> curious about this as well.

No, I was only interested in how to structure the library on disk.
--
Colin Adams
Preston Lancashire