Simple integration of module functionality
This commit is contained in:
parent
c866cc812a
commit
7afae96cf4
|
@ -414,18 +414,18 @@ module Registry = {
|
|||
->E.A.O.concatSomes
|
||||
->E.A.uniq
|
||||
|
||||
let makeModules = (t: registry) => {
|
||||
let makeModules = (prevBindings: Reducer_Module.t, t: registry): Reducer_Module.t => {
|
||||
let nameSpaces = allNamespaces(t)
|
||||
nameSpaces->E.A2.fmap(nameSpace => {
|
||||
let nameSpaceBindings = nameSpaces->E.A2.fmap(nameSpace => {
|
||||
let definitions = t->definitions->E.A2.filter(d => d.nameSpace === Some(nameSpace))
|
||||
|
||||
// E.A.reduce(definitions, Reducer_Module.emptyStdLib, (acc, d) => {
|
||||
// let name = d.name
|
||||
// let definition = FnDefinition.toLambda(d)
|
||||
// let foo = Reducer_Module.defineFunction("Fhi", definition)
|
||||
// })
|
||||
// let module = Module.make(nameSpace, functions)
|
||||
// module
|
||||
let newModule = E.A.reduce(definitions, Reducer_Module.emptyStdLib, (acc, d) => {
|
||||
acc->Reducer_Module.defineFunction(d.name, FnDefinition.toFfiFn(d))
|
||||
})
|
||||
(nameSpace, newModule)
|
||||
})
|
||||
E.A.reduce(nameSpaceBindings, prevBindings, (acc, (name, fn)) =>
|
||||
acc->Reducer_Module.defineModule(name, fn)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ let registry = [
|
|||
~requiresNamespace=true,
|
||||
~name="makeDiscrete",
|
||||
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
||||
~run=(inputs, _) => inputsTodist(inputs, r => Continuous(Continuous.make(r))),
|
||||
~run=(inputs, _) => inputsTodist(inputs, r => Discrete(Discrete.make(r))),
|
||||
(),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -20,4 +20,6 @@ let mathBindings: Bindings.t =
|
|||
->Bindings.fromArray
|
||||
|
||||
let makeBindings = (previousBindings: Bindings.t): Bindings.t =>
|
||||
previousBindings->Bindings.defineModule("Math", mathBindings)
|
||||
previousBindings
|
||||
->Bindings.defineModule("Math", mathBindings)
|
||||
->FunctionRegistry_Core.Registry.makeModules(FunctionRegistry_Library.registry)
|
||||
|
|
Loading…
Reference in New Issue
Block a user