temochka / enclojure / Enclojure

Enclojure is a Clojure-like scripting language for Elm apps. Enclojure is experimental software and subject to breaking API changes.

Initialize


type alias Env io =
Common.Env io

An execution environment. Think of this as the current state of the interpreter.

init : Env io

Initialize a fresh Enclojure execution environment

Pure programs


type alias Exception =
Common.Exception

An Enclojure exception value.

evalPure : EvalOptions -> Env io -> String -> Result Exception ( Common.Value io, Env io )

Evaluates a given Enclojure program in a provided environment. Returns an error on exception, and a tuple of returned value and changed environment on successful execution. Throws if the program attempts any side effects. May cause an infinite loop if EvalOptions.maxOps is not specified.

Side-effecting programs


type EvalResult io
    = RunIO io (Result Exception (Common.Value io) -> Step io)
    | Continue (Step io)
    | Error Exception
    | Done (Common.Value io)

Returned by eval


type alias Step io =
Located (Common.Step io)

Represents an unfinished computation that can be continued using continueEval.

eval : EvalOptions -> Env io -> String -> ( EvalResult io, Env io )

Evaluates a given Enclojure program in a provided environment. Returns a tuple of the evaluation result and modified environment. May cause an infinite loop if EvalOptions.maxOps is not specified.

continueEval : EvalOptions -> Step io -> ( EvalResult io, Env io )

Continue evaluation from a previously returned step.

Manipulating execution environment

getStepEnv : Step io -> Env io

Get the execution environment of an eval step.

setStepEnv : Env io -> Step io -> Step io

Modify the execution environment of an eval step.

getStepValue : Step io -> Maybe (Common.Value io)

Get the value of an eval step unless the step returned a side effect.

Extracting documentation


type Doc
    = SpecialFormDoc
    | MacroDoc
    | FunctionDoc

Represents the type of a documentation entry.


type alias FnInfo =
Common.FnInfo

Basic function info: name, doc, and a list of signatures.

documentation : Env io -> List ( Doc, FnInfo )

Returns a list of documentation entries for a given evaluation environment.