Get Started

1. Get the source

mino is two files: mino.h and mino.c. Copy them into your project, or clone the repository:

git clone https://github.com/leifericf/mino.git

2. Compile

Build the standalone REPL:

cd mino
make

Or compile mino directly into your own program:

cc -std=c99 -o myapp myapp.c mino.c

No build system, package manager, or external dependencies required.

3. Embed in your C program

A minimal embedding creates a runtime, registers a host function, evaluates mino code, and extracts the result:

#include "mino.h"
#include <stdio.h>

/* A host function exposed to mino as (add-tax amount). */
static mino_val_t *host_add_tax(mino_val_t *args, mino_env_t *env)
{
    long long amount;
    (void)env;
    if (!mino_is_cons(args) || !mino_to_int(args->as.cons.car, &amount))
        return mino_nil();
    return mino_float((double)amount * 1.08);
}

int main(void)
{
    mino_env_t *env = mino_new();          /* env + core bindings */
    mino_register_fn(env, "add-tax", host_add_tax);

    mino_val_t *result = mino_eval_string(
        "(def prices [100 200 300])\n"
        "(reduce + (map add-tax prices))\n",
        env);

    if (result) {
        double total;
        if (mino_to_float(result, &total))
            printf("total with tax: %.2f\n", total);
    }

    mino_env_free(env);
    return 0;
}

Key points:

4. Try the REPL

The standalone REPL is useful for exploring the language interactively:

$ ./mino
mino> (def greet (fn (name) (str "hello, " name "!")))
#<fn>
mino> (greet "world")
"hello, world!"
mino> (map greet ["alice" "bob" "carol"])
("hello, alice!" "hello, bob!" "hello, carol!")
mino> (doc 'map)
"(map f coll) -- apply f to each element, return a list of results."

5. Next steps