> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Modules and use

> A module is one RSL file. Another module reads it through use, and a host serves a module by what it declares.

A **module** is one RSL file and the definitions it holds.
Another module reads those definitions through `use`.
So one rating function serves every process that needs its premium.

## `use`

A process in the staffing example reads its rating function in three lines:

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
use ts = "rater.rsl"
```

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
            policy: ts.Policy,
```

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
            premium: Premium = ts(self.policy).premium
```

| Line | What it does |
| - | - |
| `use ts = "rater.rsl"` | Names the module `ts` |
| `policy: ts.Policy` | Takes one argument of the function as an input, with its names and types |
| `ts(self.policy).premium` | Calls the function and reads one value of its result |

A module reads each value of another module through a call, by the value's path.
The used module compiles alone, and its steps stay free to change.
Each read is a call, so one spelling marks each place that depends on the other module.
A table row is the one exception: `ts.Tables.GlClass[self.class]` reads it as a lookup.

## RSL 0.4 components

| The module declares | A host serves it as |
| - | - |
| `component: rater` and `RatingOutcomes` | A rating function: requests in, results out |
| `component: guideline`, `Roles` and `Acts` | A process: a log for each submission |

`rslc check` holds each file to its `component`, and [`E-COMPONENT`](https://docs.canary.effectiveai.app/rsl/reference/check-messages/guidelines#e-component) names a form that belongs to the other kind.

In RSL 0.5, `rslc check` checks references in every function body in the
module and the modules it uses. It also compiles a selected function entry.
A module can pass this check without an entry. Exporting the module for rating
requires a selected rater function.

### Calling a compiled rater from RSL 0.5

An RSL 0.5 process can use a portable compiled rater artifact beside its entry
file. Name the artifact after the module the process uses, for example
`example.rating.rslart`, then write `use rated = example.rating`. The artifact
may have been compiled from an RSL 0.4 or 0.5 rater. Its callable entry is
`rated.rate(record)`, and the result names are the artifact's published
outcomes. The compiler checks the record and result against the artifact's
kernel and contract. A process bundle embeds the exact artifact and checks its
implementation pin and call links when it opens.

## Other sharing forms

| Form | Shares |
| - | - |
| `import "types.rsl"` | The sections of a fragment file, merged into the file that imports it |
| `package … version …` | Questions that several rating functions ask in the same words |
| `Policy extends base.Policy` | A record of a used library, which a state rater extends with its own inputs, steps and rules |

## Related

* [Guidelines](https://docs.canary.effectiveai.app/rsl/reference/language.md#guidelines) in the language reference lists each form of a call.
* [`import`](https://docs.canary.effectiveai.app/rsl/reference/language#import), [Shared facts](https://docs.canary.effectiveai.app/rsl/reference/language.md#shared-facts) and [State raters](https://docs.canary.effectiveai.app/rsl/reference/language.md#state-raters) give the other forms.
* [Split a rater into files](https://docs.canary.effectiveai.app/rsl/how-to/split-a-rater-into-files.md) puts them to work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.