Skip to content

Using MORK

charlie derr edited this page Oct 1, 2025 · 5 revisions

MORK usage

Documenting how to use MORK after one has gotten it up and running.

Commands

MORK has mm2 at its core and there are commands to execute different actions that use mm2 to do specific tasks. The following commands are exposed through an HTTP server and will make use of mm2 in some way or form. For the sake of adhering to the MORK interface conventions we will use Arguments as HTTP url paths put in the same sequence provided below. Properties are HTTP query parameters, sequence doesn't matter.

import

Fetches a file from the web or local machine , parses it, and loads the data into the space. status can be monitored via polling the status command or through status_stream.

Arguments:

Name Type Required Description
pattern String Yes The pattern to specify the expression to import. from the data. (See mm2 operational sematics for more)
template String Yes The template to specify the form of the expressions in the space. (See mm2 operational sematics for more)

Properties:

Name Type Required Description
uri String Yes The URI to fetch the file from. Supports http, https, and file schemes.

clear

Clears all data at the specified path. Should be used cautiously as it is unrecoverable.

Arguments:

Name Type Required Description
expr Expr Yes The expression defining a subspace from which to clear. The path is relative to the first variable in the expression, e.g. (test (data $v) _)

copy

Copies (by reference) the contents of source to dest..

Arguments:

Name Type Required Description
src_expr Expr Yes The expression defining a subspace from which to copy. The path is relative to the first variable in the expression.
dst_expr Expr Yes The expression defining a destination subspace into which to copy. The path is relative to the first variable in the expression.

explore

Explore a limited number of paths below a focus position within an expression's subspace. This allows for traversing the data in a structured way. You can use this if you are requesting huge data that will take up a lot of memory.

Usage:

  1. Start exploration from an expr by passing an empty focus_token.
  2. The command returns up to 256 pairs of (focus_token, sample_expr). Each pair represents a disjoint set of values.
  3. Recursively call explore with a returned focus_token to explore deeper into that subset.
  4. An empty () response means the subspace is empty or the end of a branch has been reached.

Arguments:

Name Type Required Description
expr String Yes The pattern to match within the space, from which to begin traversal.
focus_token Bytes Yes An encoded representation of a subset of the subspace. Pass a zero-length value to begin exploration at the root of the expression's subspace.

transform

Executes a multi-pattern, multi-template transformation. The patterns and templates are provided in the POST body of the request as a single S-Expression. (See mm2 operational sematics for more).

POST Body Format:

(transform (, (pattern0 ...) (pattern1 ...) ... ) (, (template0 ...) (template1 ...) ... ) )

Clone this wiki locally