squiggle/packages/squiggle-lang/src/rescript/FunctionRegistry
Vyacheslav Matyukhin 1187c0330a
faster filter
2022-09-09 17:04:32 +04:00
..
Library faster filter 2022-09-09 17:04:32 +04:00
FunctionRegistry_Core.res project 2022-08-10 11:53:39 +02:00
FunctionRegistry_Helpers.res cleanup: More Dangers cleanup 2022-09-06 14:25:03 +02:00
FunctionRegistry_Library.res tweak: Move new functions to the "Danger" namespace 2022-09-04 15:31:18 +02:00
README.md Fixing lint and tests 2022-05-23 14:28:32 -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",
            ~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. The function defintions

Key Files

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

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

FunctionRegistry_Helpers A list of helper functions for the FunctionRegistry_Library.