squiggle/packages/squiggle-lang/src/rescript/FunctionRegistry
2022-09-29 19:48:31 +04:00
..
FunctionRegistry_Core.res CallStack, location -> frame, WIP 2022-09-29 19:48:31 +04:00
FunctionRegistry_Helpers.res refactor into SqError 2022-09-26 04:44:08 +04:00
FunctionRegistry_Library.res tests; drop mathjs; new FR helpers; disable type tests 2022-09-19 21:46:37 +04:00
README.md tests; drop mathjs; new FR helpers; disable type tests 2022-09-19 21:46:37 +04:00

Function Registry

The function registry is a library for organizing function definitions.

The main interface is fairly constrained. Basically, write functions like the following, and add them to a big array.

  Function.make(
    ~name="Normal",
    ~definitions=[
        FnDefinition.make(
            ~name="normal",
            ~inputs=[FRTypeDistOrNumber, FRTypeDistOrNumber],
            ~run=(
                inputs,
                env,
            ) =>
                inputs
                ->Prepare.ToValueTuple.twoDistOrNumber
                ->E.R.bind(
                Process.twoDistsOrNumbersToDistUsingSymbolicDist(
                    ~fn=E.Tuple2.toFnCall(SymbolicDist.Normal.make),
                    ~env,
                    ~values=_,
                ),
                )
                ->E.R2.fmap(Wrappers.evDistribution)
        )
    ],
  )

The Function name is just there for future documentation.

Key Files

FunctionRegistry_Core Key types, internal functionality, and a Registry module with a call function to call function definitions.

FunctionRegistry_Library A list of all the Functions defined in the Function Registry.

The definition arrays are stored in FR_* modules, by convention.

FunctionRegistry_Helpers A list of helper functions for the FunctionRegistry_Library.