Helper functions for defining Enclojure callables.
Enclojure.Common.Callable io
Represents a callable (anonymous function).
new : Callable io
Creates a new empty callable.
Unlike Elm, one Enclojure function can have more than one "arity": the number of arguments it accepts. Arities can be fixed (positional arguments only) or variadic (some or no positional arguments + a list of remaining arguments).
fixedArity : a -> (a -> Result Enclojure.Common.Exception (Enclojure.Common.IO io)) -> Enclojure.Common.Arity io a
Build an arity that accepts positional args a
and doesn’t accept any varargs.
variadicArity : { argNames : a, restArgName : Enclojure.Common.Value io } -> ({ args : a, rest : List (Enclojure.Common.Value io) } -> Result Enclojure.Common.Exception (Enclojure.Common.IO io)) -> Enclojure.Common.Arity io a
Build an arity that accepts positional args a
and varargs.
toArityFunction : (a -> Result Enclojure.Common.Exception (Enclojure.Common.IO io)) -> a -> Enclojure.Common.Env io -> Enclojure.Common.Continuation io -> Enclojure.Common.Step io
Converts a simplified arity to full arity.
Most Enclojure callables don’t need to modify the environment or to access the continuation.
Thus, it's easier to define them as functions of a -> Result Exception (IO io)
.
setArity0 : Enclojure.Common.Arity io () -> Callable io -> Callable io
Overwrite the arity 0 (no positional arguments) on a callable.
setArity1 : Enclojure.Common.Arity io (Enclojure.Common.Value io) -> Callable io -> Callable io
Overwrite the arity 1 (one positional argument) on a callable
setArity2 : Enclojure.Common.Arity io ( Enclojure.Common.Value io, Enclojure.Common.Value io ) -> Callable io -> Callable io
Overwrite the arity 2 (two positional arguments) on a callable
setArity3 : Enclojure.Common.Arity io ( Enclojure.Common.Value io, Enclojure.Common.Value io, Enclojure.Common.Value io ) -> Callable io -> Callable io
Overwrite the arity 3 (three positional arguments) on a callable
signatures : Callable io -> List (List String)
Returns the list of signatures of a given callable.