Making modules: an introduction

Understanding modules

Here we need to distinguish between four things:

  • A Distribution

  • A package

  • A module

  • A class/grammar

Distribution

A Distribution is a set of related source files that are distributed together. This usually includes some modules, some tests, and maybe some other resources.

For a full explanation, see Distributions: An introduction and the following documentation.

package

Packages are nested namespaces of named program elements. Modules, classes and grammars are all types of package.

For a full explanation see Packages.

module

Modules are usually one or more source files that expose Raku constructs, such as classes, roles, grammars, subroutines and variables. Modules are usually used for distributing Raku code as libraries which can be used in another Raku program.

For a full explanation see the pages linked from Using Modules: An Introduction.

class

Classes are a collection of methods and attributes grouped together for convenience. Being a package, they're also a nested namespace.

For further explanation, see:

grammar

Grammars are a specific type of class intended for parsing text. Grammars are composed of rules, tokens and regexes which are actually methods, since grammars are classes.

For a full explanation see Grammars.

Creating and using modules

A module is usually a source file or set of source files that expose Raku constructs [1].

Modules are typically packages (classes, roles, grammars), subroutines, and sometimes variables. In Raku module can also refer to a type of package declared with the module keyword (see Module Packages and the examples below) but here we mostly mean "module" as a set of source files in a namespace.

Documentation about Modules

Want to distribute your modules?

[1]Technically a module is a set of compunits which are usually files but could come from anywhere as long as there is a compunit repository that can provide it. See S11.

See Also

Distributing modules: the configuration and structure

How to structure and configure Raku modules for distribution

Distributions: an introduction

Distributions and how they work

Distributions: testing

Testing your distribution of modules

Distributions: the tools

What can help you write/test/improve your distributions of modules

Distributions: uploading

How to upload your distribution to the ecosystem

Making modules: the code

How to organize your module with regard to its usage

Using modules: the code

How to use Raku modules in your code

Using modules: finding and installing

How to find and install Raku modules

Modules: an introduction

Modules and how they work

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.