# Modules

Module

![](/files/u8V3B4SlzZiaD44Uypnc)

You can group functions and variables in separate library modules.

MainModule

![](/files/7MNZViG2n9y1ZZewKqKO)

Up to now, everything we encountered were main modules, i.e., a prolog followed by a main query.

LibraryModule

![](/files/86DQIoQlR9dwf5dF45Wc)

A library module does not contain any query - just functions and variables that can be imported by other modules.

A library module must be assigned to a namespace. For convenience, this namespace is bound to an alias in the module declaration. All variables and functions in a library module must be prefixed with this alias.

### A library module

```

module namespace my = "http://www.example.com/my-module";
declare variable $my:variable := { "foo" : "bar" };
declare variable $my:n := 42;
declare function my:function($i as integer) { $i * $i };
    
```

ModuleImport

![](/files/IGvGHRBxkX33WBWFJ7FB)

Here is a main module which imports the former library module. An alias is given to the module namespace (my). Variables and functions from that module can be accessed by prefixing their names with this alias. The alias may be different than the internal alias defined in the imported module.

### An importing main module

```

import module namespace other= "http://www.example.com/my-module";
other:function($other:n)
    
```

Result (run with Zorba):1764


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rumbledb.org/the-jsoniq-language/jsoniq-specification/modules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
