[racket] Question about package, library and module

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Dec 17 08:20:47 EST 2010

At Thu, 16 Dec 2010 19:55:40 +0100, Manfred Lotz wrote:
> It is not quite clear to me how package, library and modules
> relate together.

At Thu, 16 Dec 2010 20:50:47 -0800, prad wrote:
> On Thu, 16 Dec 2010 19:55:40 +0100
> Manfred Lotz <manfred.lotz at arcor.de> wrote:
> 
> > I further assume that, e.g.  (require something) imports a module
> > named something. The next question is where and how to set a module
> > path.
> >
> i like to know about this too.
> 
> following the ideas in the modules section of the guide
> (http://docs.racket-lang.org/guide/module-basics.html), i found my
> collects directory:
> ~/.racket/5.0.2/collects
> 
> but when i put a file utils (or utils.rkt) in there my 
> (require utils)
> gives
> stdin::254: utils: standard-module-name-resolver: collection not found:
> error

"Library" and "module" are synonyms, more or less, because a library is
implemented by a module.

A "collection" consists of a set of libraries and sub-collections that
are normally grouped together into a directory. That is, a collection
is implemented as a directory. A "collects" directory like
"~/.racket/5.0.2/collects" holds collections, not libraries or modules.

The term "package" is roughly a synonym for "collection", especially as
distributed via Planet.


When a library is installed in a collection, you refer to it using a
path of collection and sub-collection names followed by a module name.
As a special case, a top-level collection name can be used as a library
name, which is just a shorthand for the collection name followed by the
module name "main". 

So,

  (require utils)

is a shorthand for

 (require utils/main)

Putting "utils.rkt" in a "collects" directory like
"~/.racket/5.0.2/collects" doesn't work because a single file cannot be
a collection. Instead, create "utils/main.rkt".



Posted on the users mailing list.