Move namespace from fnDefinition to fn
This commit is contained in:
parent
3c396e0ccc
commit
3f09f5f307
|
@ -40,16 +40,20 @@ and frValueDictParam = (string, frValue)
|
||||||
and frValueDistOrNumber = FRValueNumber(float) | FRValueDist(DistributionTypes.genericDist)
|
and frValueDistOrNumber = FRValueNumber(float) | FRValueDist(DistributionTypes.genericDist)
|
||||||
|
|
||||||
type fnDefinition = {
|
type fnDefinition = {
|
||||||
nameSpace: option<string>,
|
|
||||||
requiresNamespace: bool,
|
requiresNamespace: bool,
|
||||||
name: string,
|
name: string,
|
||||||
inputs: array<frType>,
|
inputs: array<frType>,
|
||||||
run: (array<internalExpressionValue>, array<frValue>, GenericDist.env)=> result<internalExpressionValue, string>
|
run: (
|
||||||
|
array<internalExpressionValue>,
|
||||||
|
array<frValue>,
|
||||||
|
GenericDist.env,
|
||||||
|
) => result<internalExpressionValue, string>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type function = {
|
type function = {
|
||||||
name: string,
|
name: string,
|
||||||
definitions: array<fnDefinition>,
|
definitions: array<fnDefinition>,
|
||||||
|
nameSpace: string,
|
||||||
examples: array<string>,
|
examples: array<string>,
|
||||||
description: option<string>,
|
description: option<string>,
|
||||||
isExperimental: bool,
|
isExperimental: bool,
|
||||||
|
@ -338,9 +342,8 @@ module FnDefinition = {
|
||||||
let toLambda = (t: t) =>
|
let toLambda = (t: t) =>
|
||||||
Reducer_Module.convertOptionToFfiFn(t.name, toFfiFn(t))->Reducer_Module.eLambdaFFIValue
|
Reducer_Module.convertOptionToFfiFn(t.name, toFfiFn(t))->Reducer_Module.eLambdaFFIValue
|
||||||
|
|
||||||
let make = (~nameSpace=None, ~requiresNamespace=true, ~name, ~inputs, ~run, ()): t => {
|
let make = (~requiresNamespace=true, ~name, ~inputs, ~run, ()): t => {
|
||||||
name: name,
|
name: name,
|
||||||
nameSpace: nameSpace,
|
|
||||||
requiresNamespace: requiresNamespace,
|
requiresNamespace: requiresNamespace,
|
||||||
inputs: inputs,
|
inputs: inputs,
|
||||||
run: run,
|
run: run,
|
||||||
|
@ -358,8 +361,17 @@ module Function = {
|
||||||
isExperimental: bool,
|
isExperimental: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
let make = (~name, ~definitions, ~examples=?, ~description=?, ~isExperimental=false, ()): t => {
|
let make = (
|
||||||
|
~name,
|
||||||
|
~nameSpace,
|
||||||
|
~definitions,
|
||||||
|
~examples=?,
|
||||||
|
~description=?,
|
||||||
|
~isExperimental=false,
|
||||||
|
(),
|
||||||
|
): t => {
|
||||||
name: name,
|
name: name,
|
||||||
|
nameSpace: nameSpace,
|
||||||
definitions: definitions,
|
definitions: definitions,
|
||||||
examples: examples |> E.O.default([]),
|
examples: examples |> E.O.default([]),
|
||||||
isExperimental: isExperimental,
|
isExperimental: isExperimental,
|
||||||
|
@ -377,7 +389,8 @@ module Function = {
|
||||||
|
|
||||||
module Registry = {
|
module Registry = {
|
||||||
let toJson = (r: registry) => r->E.A2.fmap(Function.toJson)
|
let toJson = (r: registry) => r->E.A2.fmap(Function.toJson)
|
||||||
let definitions = (r: registry) => r->E.A2.fmap(d => d.definitions)->E.A.concatMany
|
let definitionsWithFunctions = (r: registry) =>
|
||||||
|
r->E.A2.fmap(fn => fn.definitions->E.A2.fmap(def => (def, fn)))->E.A.concatMany
|
||||||
|
|
||||||
/*
|
/*
|
||||||
There's a (potential+minor) bug here: If a function definition is called outside of the calls
|
There's a (potential+minor) bug here: If a function definition is called outside of the calls
|
||||||
|
@ -409,21 +422,17 @@ module Registry = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let allNamespaces = (t: registry) =>
|
//todo: get namespace from project.
|
||||||
t
|
let allNamespaces = (t: registry) => t->E.A2.fmap(r => r.nameSpace)->E.A.uniq
|
||||||
->E.A2.fmap(r => r.definitions)
|
|
||||||
->Belt.Array.concatMany
|
|
||||||
->E.A2.fmap(r => r.nameSpace)
|
|
||||||
->E.A.O.concatSomes
|
|
||||||
->E.A.uniq
|
|
||||||
|
|
||||||
let makeModules = (prevBindings: Reducer_Module.t, t: registry): Reducer_Module.t => {
|
let makeModules = (prevBindings: Reducer_Module.t, t: registry): Reducer_Module.t => {
|
||||||
let nameSpaces = allNamespaces(t)
|
let nameSpaces = allNamespaces(t)
|
||||||
let nameSpaceBindings = nameSpaces->E.A2.fmap(nameSpace => {
|
let nameSpaceBindings = nameSpaces->E.A2.fmap(nameSpace => {
|
||||||
let definitions = t->definitions->E.A2.filter(d => d.nameSpace === Some(nameSpace))
|
let definitions =
|
||||||
|
t->definitionsWithFunctions->E.A2.filter(((_, fn)) => fn.nameSpace === nameSpace)
|
||||||
|
|
||||||
let newModule = E.A.reduce(definitions, Reducer_Module.emptyStdLib, (acc, d) => {
|
let newModule = E.A.reduce(definitions, Reducer_Module.emptyStdLib, (acc, (def, _)) => {
|
||||||
acc->Reducer_Module.defineFunction(d.name, FnDefinition.toFfiFn(d))
|
acc->Reducer_Module.defineFunction(def.name, FnDefinition.toFfiFn(def))
|
||||||
})
|
})
|
||||||
(nameSpace, newModule)
|
(nameSpace, newModule)
|
||||||
})
|
})
|
||||||
|
|
|
@ -31,7 +31,7 @@ module Declaration = {
|
||||||
}
|
}
|
||||||
|
|
||||||
module PointSet = {
|
module PointSet = {
|
||||||
let nameSpace = Some("PointSet")
|
let nameSpace = "PointSet"
|
||||||
let requiresNamespace = true
|
let requiresNamespace = true
|
||||||
|
|
||||||
let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
|
let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => {
|
||||||
|
@ -56,9 +56,9 @@ module PointSet = {
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="PointSet.makeContinuous",
|
~name="PointSet.makeContinuous",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~name="makeContinuous",
|
~name="makeContinuous",
|
||||||
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
||||||
|
@ -70,9 +70,9 @@ module PointSet = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="PointSet.makeDiscrete",
|
~name="PointSet.makeDiscrete",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~name="makeDiscrete",
|
~name="makeDiscrete",
|
||||||
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))],
|
||||||
|
@ -86,10 +86,11 @@ module PointSet = {
|
||||||
}
|
}
|
||||||
|
|
||||||
module Functionn = {
|
module Functionn = {
|
||||||
let nameSpace = Some("Function")
|
let nameSpace = "Function"
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Function.declare",
|
~name="Function.declare",
|
||||||
|
~nameSpace,
|
||||||
~description="Adds metadata to a function of the input ranges. Works now for numeric and date inputs. This is useful when making predictions. It allows you to limit the domain that your prediction will be used and scored within.",
|
~description="Adds metadata to a function of the input ranges. Works now for numeric and date inputs. This is useful when making predictions. It allows you to limit the domain that your prediction will be used and scored within.",
|
||||||
~examples=[
|
~examples=[
|
||||||
`declareFn({
|
`declareFn({
|
||||||
|
@ -103,7 +104,6 @@ module Functionn = {
|
||||||
~isExperimental=true,
|
~isExperimental=true,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~name="declare",
|
~name="declare",
|
||||||
~inputs=[Declaration.frType],
|
~inputs=[Declaration.frType],
|
||||||
|
@ -119,7 +119,7 @@ module Functionn = {
|
||||||
}
|
}
|
||||||
|
|
||||||
module DistributionCreation = {
|
module DistributionCreation = {
|
||||||
let nameSpace = Some("Dist")
|
let nameSpace = "Dist"
|
||||||
module TwoArgDist = {
|
module TwoArgDist = {
|
||||||
let process = (~fn, ~env, r) =>
|
let process = (~fn, ~env, r) =>
|
||||||
r
|
r
|
||||||
|
@ -128,7 +128,6 @@ module DistributionCreation = {
|
||||||
|
|
||||||
let make = (name, fn) => {
|
let make = (name, fn) => {
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=false,
|
~requiresNamespace=false,
|
||||||
~name,
|
~name,
|
||||||
~inputs=[FRTypeDistOrNumber, FRTypeDistOrNumber],
|
~inputs=[FRTypeDistOrNumber, FRTypeDistOrNumber],
|
||||||
|
@ -139,7 +138,6 @@ module DistributionCreation = {
|
||||||
|
|
||||||
let makeRecordP5P95 = (name, fn) => {
|
let makeRecordP5P95 = (name, fn) => {
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=false,
|
~requiresNamespace=false,
|
||||||
~name,
|
~name,
|
||||||
~inputs=[FRTypeRecord([("p5", FRTypeDistOrNumber), ("p95", FRTypeDistOrNumber)])],
|
~inputs=[FRTypeRecord([("p5", FRTypeDistOrNumber), ("p95", FRTypeDistOrNumber)])],
|
||||||
|
@ -152,7 +150,6 @@ module DistributionCreation = {
|
||||||
let makeRecordMeanStdev = (name, fn) => {
|
let makeRecordMeanStdev = (name, fn) => {
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~name,
|
~name,
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=false,
|
~requiresNamespace=false,
|
||||||
~inputs=[FRTypeRecord([("mean", FRTypeDistOrNumber), ("stdev", FRTypeDistOrNumber)])],
|
~inputs=[FRTypeRecord([("mean", FRTypeDistOrNumber), ("stdev", FRTypeDistOrNumber)])],
|
||||||
~run=(_, inputs, env) =>
|
~run=(_, inputs, env) =>
|
||||||
|
@ -170,7 +167,6 @@ module DistributionCreation = {
|
||||||
|
|
||||||
let make = (name, fn) =>
|
let make = (name, fn) =>
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=false,
|
~requiresNamespace=false,
|
||||||
~name,
|
~name,
|
||||||
~inputs=[FRTypeDistOrNumber],
|
~inputs=[FRTypeDistOrNumber],
|
||||||
|
@ -182,6 +178,7 @@ module DistributionCreation = {
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Normal",
|
~name="Normal",
|
||||||
|
~nameSpace,
|
||||||
~examples=["normal(5,1)", "normal({p5: 4, p95: 10})", "normal({mean: 5, stdev: 2})"],
|
~examples=["normal(5,1)", "normal({p5: 4, p95: 10})", "normal({mean: 5, stdev: 2})"],
|
||||||
~definitions=[
|
~definitions=[
|
||||||
TwoArgDist.make("normal", twoArgs(SymbolicDist.Normal.make)),
|
TwoArgDist.make("normal", twoArgs(SymbolicDist.Normal.make)),
|
||||||
|
@ -194,10 +191,11 @@ module DistributionCreation = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Lognormal",
|
~name="Lognormal",
|
||||||
|
~nameSpace,
|
||||||
~examples=[
|
~examples=[
|
||||||
"lognormal(0.5, 0.8)",
|
"lognormal(0.5, 0.8)",
|
||||||
"lognormal({p5: 4, p95: 10})",
|
"lognormal({p5: 4, p95: 10})",
|
||||||
"lognormal({mean: 5, stdev: 2})"
|
"lognormal({mean: 5, stdev: 2})",
|
||||||
],
|
],
|
||||||
~definitions=[
|
~definitions=[
|
||||||
TwoArgDist.make("lognormal", twoArgs(SymbolicDist.Lognormal.make)),
|
TwoArgDist.make("lognormal", twoArgs(SymbolicDist.Lognormal.make)),
|
||||||
|
@ -213,12 +211,14 @@ module DistributionCreation = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Uniform",
|
~name="Uniform",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`uniform(10, 12)`],
|
~examples=[`uniform(10, 12)`],
|
||||||
~definitions=[TwoArgDist.make("uniform", twoArgs(SymbolicDist.Uniform.make))],
|
~definitions=[TwoArgDist.make("uniform", twoArgs(SymbolicDist.Uniform.make))],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Beta",
|
~name="Beta",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`beta(20, 25)`, `beta({mean: 0.39, stdev: 0.1})`],
|
~examples=[`beta(20, 25)`, `beta({mean: 0.39, stdev: 0.1})`],
|
||||||
~definitions=[
|
~definitions=[
|
||||||
TwoArgDist.make("beta", twoArgs(SymbolicDist.Beta.make)),
|
TwoArgDist.make("beta", twoArgs(SymbolicDist.Beta.make)),
|
||||||
|
@ -228,24 +228,28 @@ module DistributionCreation = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Cauchy",
|
~name="Cauchy",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`cauchy(5, 1)`],
|
~examples=[`cauchy(5, 1)`],
|
||||||
~definitions=[TwoArgDist.make("cauchy", twoArgs(SymbolicDist.Cauchy.make))],
|
~definitions=[TwoArgDist.make("cauchy", twoArgs(SymbolicDist.Cauchy.make))],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Gamma",
|
~name="Gamma",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`gamma(5, 1)`],
|
~examples=[`gamma(5, 1)`],
|
||||||
~definitions=[TwoArgDist.make("gamma", twoArgs(SymbolicDist.Gamma.make))],
|
~definitions=[TwoArgDist.make("gamma", twoArgs(SymbolicDist.Gamma.make))],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Logistic",
|
~name="Logistic",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`logistic(5, 1)`],
|
~examples=[`logistic(5, 1)`],
|
||||||
~definitions=[TwoArgDist.make("logistic", twoArgs(SymbolicDist.Logistic.make))],
|
~definitions=[TwoArgDist.make("logistic", twoArgs(SymbolicDist.Logistic.make))],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="To (Distribution)",
|
~name="To (Distribution)",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`5 to 10`, `to(5,10)`, `-5 to 5`],
|
~examples=[`5 to 10`, `to(5,10)`, `-5 to 5`],
|
||||||
~definitions=[
|
~definitions=[
|
||||||
TwoArgDist.make("to", twoArgs(SymbolicDist.From90thPercentile.make)),
|
TwoArgDist.make("to", twoArgs(SymbolicDist.From90thPercentile.make)),
|
||||||
|
@ -258,18 +262,21 @@ module DistributionCreation = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Exponential",
|
~name="Exponential",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`exponential(2)`],
|
~examples=[`exponential(2)`],
|
||||||
~definitions=[OneArgDist.make("exponential", SymbolicDist.Exponential.make)],
|
~definitions=[OneArgDist.make("exponential", SymbolicDist.Exponential.make)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Bernoulli",
|
~name="Bernoulli",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`bernoulli(0.5)`],
|
~examples=[`bernoulli(0.5)`],
|
||||||
~definitions=[OneArgDist.make("bernoulli", SymbolicDist.Bernoulli.make)],
|
~definitions=[OneArgDist.make("bernoulli", SymbolicDist.Bernoulli.make)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="PointMass",
|
~name="PointMass",
|
||||||
|
~nameSpace,
|
||||||
~examples=[`pointMass(0.5)`],
|
~examples=[`pointMass(0.5)`],
|
||||||
~definitions=[OneArgDist.make("pointMass", SymbolicDist.Float.makeSafe)],
|
~definitions=[OneArgDist.make("pointMass", SymbolicDist.Float.makeSafe)],
|
||||||
(),
|
(),
|
||||||
|
@ -278,13 +285,12 @@ module DistributionCreation = {
|
||||||
}
|
}
|
||||||
|
|
||||||
module Number = {
|
module Number = {
|
||||||
let nameSpace = Some("Number")
|
let nameSpace = "Number"
|
||||||
let requiresNamespace = false
|
let requiresNamespace = false
|
||||||
|
|
||||||
module NumberToNumber = {
|
module NumberToNumber = {
|
||||||
let make = (name, fn) =>
|
let make = (name, fn) =>
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~name,
|
~name,
|
||||||
~inputs=[FRTypeNumber],
|
~inputs=[FRTypeNumber],
|
||||||
|
@ -302,7 +308,6 @@ module Number = {
|
||||||
module ArrayNumberDist = {
|
module ArrayNumberDist = {
|
||||||
let make = (name, fn) => {
|
let make = (name, fn) => {
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=false,
|
~requiresNamespace=false,
|
||||||
~name,
|
~name,
|
||||||
~inputs=[FRTypeArray(FRTypeNumber)],
|
~inputs=[FRTypeArray(FRTypeNumber)],
|
||||||
|
@ -329,35 +334,61 @@ module Number = {
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Floor",
|
~name="Floor",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[NumberToNumber.make("floor", Js.Math.floor_float)],
|
~definitions=[NumberToNumber.make("floor", Js.Math.floor_float)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Ceiling",
|
~name="Ceiling",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[NumberToNumber.make("ceil", Js.Math.ceil_float)],
|
~definitions=[NumberToNumber.make("ceil", Js.Math.ceil_float)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Absolute Value",
|
~name="Absolute Value",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[NumberToNumber.make("abs", Js.Math.abs_float)],
|
~definitions=[NumberToNumber.make("abs", Js.Math.abs_float)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(~name="Exponent", ~definitions=[NumberToNumber.make("exp", Js.Math.exp)], ()),
|
Function.make(
|
||||||
Function.make(~name="Log", ~definitions=[NumberToNumber.make("log", Js.Math.log)], ()),
|
~name="Exponent",
|
||||||
|
~nameSpace,
|
||||||
|
~definitions=[NumberToNumber.make("exp", Js.Math.exp)],
|
||||||
|
(),
|
||||||
|
),
|
||||||
|
Function.make(
|
||||||
|
~name="Log",
|
||||||
|
~nameSpace,
|
||||||
|
~definitions=[NumberToNumber.make("log", Js.Math.log)],
|
||||||
|
(),
|
||||||
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Log Base 10",
|
~name="Log Base 10",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[NumberToNumber.make("log10", Js.Math.log10)],
|
~definitions=[NumberToNumber.make("log10", Js.Math.log10)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(~name="Log Base 2", ~definitions=[NumberToNumber.make("log2", Js.Math.log2)], ()),
|
Function.make(
|
||||||
Function.make(~name="Round", ~definitions=[NumberToNumber.make("round", Js.Math.round)], ()),
|
~name="Log Base 2",
|
||||||
|
~nameSpace,
|
||||||
|
~definitions=[NumberToNumber.make("log2", Js.Math.log2)],
|
||||||
|
(),
|
||||||
|
),
|
||||||
|
Function.make(
|
||||||
|
~name="Round",
|
||||||
|
~nameSpace,
|
||||||
|
~definitions=[NumberToNumber.make("round", Js.Math.round)],
|
||||||
|
(),
|
||||||
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Sum",
|
~name="Sum",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[ArrayNumberDist.make("sum", r => r->E.A.Floats.sum->Wrappers.evNumber->Ok)],
|
~definitions=[ArrayNumberDist.make("sum", r => r->E.A.Floats.sum->Wrappers.evNumber->Ok)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Product",
|
~name="Product",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
ArrayNumberDist.make("product", r => r->E.A.Floats.product->Wrappers.evNumber->Ok),
|
ArrayNumberDist.make("product", r => r->E.A.Floats.product->Wrappers.evNumber->Ok),
|
||||||
],
|
],
|
||||||
|
@ -365,21 +396,25 @@ module Number = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Min",
|
~name="Min",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[ArrayNumberDist.make("min", r => r->E.A.Floats.min->Wrappers.evNumber->Ok)],
|
~definitions=[ArrayNumberDist.make("min", r => r->E.A.Floats.min->Wrappers.evNumber->Ok)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Max",
|
~name="Max",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[ArrayNumberDist.make("max", r => r->E.A.Floats.max->Wrappers.evNumber->Ok)],
|
~definitions=[ArrayNumberDist.make("max", r => r->E.A.Floats.max->Wrappers.evNumber->Ok)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Mean",
|
~name="Mean",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[ArrayNumberDist.make("mean", r => r->E.A.Floats.mean->Wrappers.evNumber->Ok)],
|
~definitions=[ArrayNumberDist.make("mean", r => r->E.A.Floats.mean->Wrappers.evNumber->Ok)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Geometric Mean",
|
~name="Geometric Mean",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
ArrayNumberDist.make("geomean", r => r->E.A.Floats.geomean->Wrappers.evNumber->Ok),
|
ArrayNumberDist.make("geomean", r => r->E.A.Floats.geomean->Wrappers.evNumber->Ok),
|
||||||
],
|
],
|
||||||
|
@ -387,11 +422,13 @@ module Number = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Standard Deviation",
|
~name="Standard Deviation",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[ArrayNumberDist.make("stdev", r => r->E.A.Floats.stdev->Wrappers.evNumber->Ok)],
|
~definitions=[ArrayNumberDist.make("stdev", r => r->E.A.Floats.stdev->Wrappers.evNumber->Ok)],
|
||||||
(),
|
(),
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Variance",
|
~name="Variance",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
ArrayNumberDist.make("variance", r => r->E.A.Floats.stdev->Wrappers.evNumber->Ok),
|
ArrayNumberDist.make("variance", r => r->E.A.Floats.stdev->Wrappers.evNumber->Ok),
|
||||||
],
|
],
|
||||||
|
@ -399,6 +436,7 @@ module Number = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Sort",
|
~name="Sort",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
ArrayNumberDist.make("sort", r =>
|
ArrayNumberDist.make("sort", r =>
|
||||||
r->E.A.Floats.sort->E.A2.fmap(Wrappers.evNumber)->Wrappers.evArray->Ok
|
r->E.A.Floats.sort->E.A2.fmap(Wrappers.evNumber)->Wrappers.evArray->Ok
|
||||||
|
@ -408,6 +446,7 @@ module Number = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Cumulative Sum",
|
~name="Cumulative Sum",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
ArrayNumberDist.make("cumsum", r =>
|
ArrayNumberDist.make("cumsum", r =>
|
||||||
r->E.A.Floats.cumsum->E.A2.fmap(Wrappers.evNumber)->Wrappers.evArray->Ok
|
r->E.A.Floats.cumsum->E.A2.fmap(Wrappers.evNumber)->Wrappers.evArray->Ok
|
||||||
|
@ -417,6 +456,7 @@ module Number = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Cumulative Prod",
|
~name="Cumulative Prod",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
ArrayNumberDist.make("cumprod", r =>
|
ArrayNumberDist.make("cumprod", r =>
|
||||||
r->E.A.Floats.cumsum->E.A2.fmap(Wrappers.evNumber)->Wrappers.evArray->Ok
|
r->E.A.Floats.cumsum->E.A2.fmap(Wrappers.evNumber)->Wrappers.evArray->Ok
|
||||||
|
@ -426,6 +466,7 @@ module Number = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="Diff",
|
~name="Diff",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
ArrayNumberDist.make("diff", r =>
|
ArrayNumberDist.make("diff", r =>
|
||||||
r->E.A.Floats.diff->E.A2.fmap(Wrappers.evNumber)->Wrappers.evArray->Ok
|
r->E.A.Floats.diff->E.A2.fmap(Wrappers.evNumber)->Wrappers.evArray->Ok
|
||||||
|
@ -437,7 +478,7 @@ module Number = {
|
||||||
}
|
}
|
||||||
|
|
||||||
module Dict = {
|
module Dict = {
|
||||||
let nameSpace = Some("Dict")
|
let nameSpace = "Dict"
|
||||||
module Internals = {
|
module Internals = {
|
||||||
type t = ReducerInterface_InternalExpressionValue.map
|
type t = ReducerInterface_InternalExpressionValue.map
|
||||||
|
|
||||||
|
@ -482,9 +523,9 @@ module Dict = {
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="merge",
|
~name="merge",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~name="merge",
|
~name="merge",
|
||||||
~inputs=[FRTypeDict(FRTypeAny), FRTypeDict(FRTypeAny)],
|
~inputs=[FRTypeDict(FRTypeAny), FRTypeDict(FRTypeAny)],
|
||||||
|
@ -502,9 +543,9 @@ module Dict = {
|
||||||
//TODO: Change to use new mergeMany() function.
|
//TODO: Change to use new mergeMany() function.
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="mergeMany",
|
~name="mergeMany",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~name="mergeMany",
|
~name="mergeMany",
|
||||||
~inputs=[FRTypeArray(FRTypeDict(FRTypeAny))],
|
~inputs=[FRTypeArray(FRTypeDict(FRTypeAny))],
|
||||||
|
@ -522,9 +563,9 @@ module Dict = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="keys",
|
~name="keys",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~name="keys",
|
~name="keys",
|
||||||
~inputs=[FRTypeDict(FRTypeAny)],
|
~inputs=[FRTypeDict(FRTypeAny)],
|
||||||
|
@ -540,9 +581,9 @@ module Dict = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="values",
|
~name="values",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~name="values",
|
~name="values",
|
||||||
~inputs=[FRTypeDict(FRTypeAny)],
|
~inputs=[FRTypeDict(FRTypeAny)],
|
||||||
|
@ -558,9 +599,9 @@ module Dict = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="toList",
|
~name="toList",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~name="toList",
|
~name="toList",
|
||||||
~inputs=[FRTypeDict(FRTypeAny)],
|
~inputs=[FRTypeDict(FRTypeAny)],
|
||||||
|
@ -576,9 +617,9 @@ module Dict = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="fromList",
|
~name="fromList",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=true,
|
~requiresNamespace=true,
|
||||||
~name="fromList",
|
~name="fromList",
|
||||||
~inputs=[FRTypeArray(FRTypeArray(FRTypeAny))],
|
~inputs=[FRTypeArray(FRTypeArray(FRTypeAny))],
|
||||||
|
@ -596,7 +637,7 @@ module Dict = {
|
||||||
}
|
}
|
||||||
|
|
||||||
module List = {
|
module List = {
|
||||||
let nameSpace = Some("List")
|
let nameSpace = "List"
|
||||||
let requiresNamespace = true
|
let requiresNamespace = true
|
||||||
|
|
||||||
module Internals = {
|
module Internals = {
|
||||||
|
@ -625,10 +666,10 @@ module List = {
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="List.make",
|
~name="List.make",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
//Todo: If the second item is a function with no args, it could be nice to run this function and return the result.
|
//Todo: If the second item is a function with no args, it could be nice to run this function and return the result.
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~name="make",
|
~name="make",
|
||||||
~inputs=[FRTypeNumber, FRTypeAny],
|
~inputs=[FRTypeNumber, FRTypeAny],
|
||||||
|
@ -645,9 +686,9 @@ module List = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="List.upTo",
|
~name="List.upTo",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~name="upTo",
|
~name="upTo",
|
||||||
~inputs=[FRTypeNumber, FRTypeNumber],
|
~inputs=[FRTypeNumber, FRTypeNumber],
|
||||||
|
@ -662,9 +703,9 @@ module List = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="List.first",
|
~name="List.first",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~name="first",
|
~name="first",
|
||||||
~inputs=[FRTypeArray(FRTypeAny)],
|
~inputs=[FRTypeArray(FRTypeAny)],
|
||||||
|
@ -680,9 +721,9 @@ module List = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="List.last",
|
~name="List.last",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=false,
|
~requiresNamespace=false,
|
||||||
~name="last",
|
~name="last",
|
||||||
~inputs=[FRTypeArray(FRTypeAny)],
|
~inputs=[FRTypeArray(FRTypeAny)],
|
||||||
|
@ -698,9 +739,9 @@ module List = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="List.reverse",
|
~name="List.reverse",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace=false,
|
~requiresNamespace=false,
|
||||||
~name="reverse",
|
~name="reverse",
|
||||||
~inputs=[FRTypeArray(FRTypeAny)],
|
~inputs=[FRTypeArray(FRTypeAny)],
|
||||||
|
@ -718,7 +759,7 @@ module List = {
|
||||||
}
|
}
|
||||||
|
|
||||||
module Scoring = {
|
module Scoring = {
|
||||||
let nameSpace = Some("Dist")
|
let nameSpace = "Dist"
|
||||||
let requiresNamespace = false
|
let requiresNamespace = false
|
||||||
|
|
||||||
let runScoring = (estimate, answer, prior, env) => {
|
let runScoring = (estimate, answer, prior, env) => {
|
||||||
|
@ -730,9 +771,9 @@ module Scoring = {
|
||||||
let library = [
|
let library = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="logScore",
|
~name="logScore",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~name="logScore",
|
~name="logScore",
|
||||||
~inputs=[
|
~inputs=[
|
||||||
|
@ -764,7 +805,6 @@ module Scoring = {
|
||||||
),
|
),
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~name="logScore",
|
~name="logScore",
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~inputs=[FRTypeRecord([("estimate", FRTypeDist), ("answer", FRTypeDistOrNumber)])],
|
~inputs=[FRTypeRecord([("estimate", FRTypeDist), ("answer", FRTypeDistOrNumber)])],
|
||||||
~run=(_, inputs, env) => {
|
~run=(_, inputs, env) => {
|
||||||
|
@ -784,10 +824,10 @@ module Scoring = {
|
||||||
),
|
),
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="klDivergence",
|
~name="klDivergence",
|
||||||
|
~nameSpace,
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(
|
FnDefinition.make(
|
||||||
~name="klDivergence",
|
~name="klDivergence",
|
||||||
~nameSpace,
|
|
||||||
~requiresNamespace,
|
~requiresNamespace,
|
||||||
~inputs=[FRTypeDist, FRTypeDist],
|
~inputs=[FRTypeDist, FRTypeDist],
|
||||||
~run=(_, inputs, env) => {
|
~run=(_, inputs, env) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user