Host.Code (Beamlet v0.1.0)

Copy Markdown View Source

Discover what is on your beamlet, read its docs and source, and remove modules.

Start with print_modules/0. The print_* functions print what they find and return :ok; remove/1 acts silently and returns :ok. A failure raises with a teaching message, like any other error, and everything printed before it survives.

Explore with eval, then build with define and edit with patch: anything worth calling again belongs in a module. Each eval starts clean, so read what exists first. Other agents and clients share the same pool of modules, and this is how you see its current state. A defined module is read whole with print_source/1, or in pieces: print_outline/1 for its shape, then print_source/2 and print_source/3 for one function or a range of lines.

Everything here acts as you, the token behind the eval: the listing and the docs are filtered by your policy, and a removal is recorded against you. Called from anywhere else, a web request or a process of your own, there is no one to act as, and each function raises saying so.

Summary

Functions

Prints a module's documentation, e.g. print_docs(Host.Code).

Prints full documentation for every arity of a function, e.g. print_docs(Enum, :map).

Prints full documentation for one arity of a function, e.g. print_docs(Enum, :map, 2).

Prints the discoverable module surface of your beamlet.

Prints the outline of a module defined with define: each top-level item with the lines it spans.

Prints what your policy deliberately withholds, the rules in force for your code, and the modules granted only in part.

Prints the source code of a module previously defined with define.

Prints one function of a defined module at every arity, or a range of its lines, e.g. print_source(Shopping.List, :total) or print_source(Shopping.List, 40..80).

Prints one arity of a function of a defined module, e.g. print_source(Shopping.List, :total, 1).

Removes modules defined with define, e.g. remove(Shopping.List).

Functions

remove(module)

@spec remove(module() | [module()]) :: :ok

Removes modules defined with define, e.g. remove(Shopping.List).

The modules are unloaded from your beamlet and their files deleted. Accepts a module or a list of modules removed together as one atomic set. Removal is refused while any module outside the set depends on a target; the error names the dependents. Remove or rework dependents first, or pass the whole group in one call: modules that call each other can only be removed together.