Lint for Umur
Value: [1e-8 to 1e-6]
This commit is contained in:
parent
2c452163b6
commit
0e9996256e
|
@ -21,7 +21,7 @@ let callInternal = (call: functionCall, _environment): result<'b, errorValue> =>
|
|||
}
|
||||
|
||||
let constructRecord = arrayOfPairs => {
|
||||
Belt.Array.map(arrayOfPairs, pairValue =>
|
||||
Belt.Array.map(arrayOfPairs, pairValue =>
|
||||
switch pairValue {
|
||||
| EvArray([EvString(key), valueValue]) => (key, valueValue)
|
||||
| _ => ("wrong key type", pairValue->toStringWithType->EvString)
|
||||
|
|
|
@ -19,7 +19,7 @@ let dispatchMacroCall = (
|
|||
environment,
|
||||
reduceExpression: ExpressionT.reducerFn,
|
||||
): result<expression, errorValue> => {
|
||||
let doBindStatement = (bindingExpr: expression, statement: expression, environment) =>
|
||||
let doBindStatement = (bindingExpr: expression, statement: expression, environment) =>
|
||||
switch statement {
|
||||
| ExpressionT.EList(list{ExpressionT.EValue(EvCall("$let")), symbolExpr, statement}) => {
|
||||
let rExternalBindingsValue = reduceExpression(bindingExpr, bindings, environment)
|
||||
|
@ -37,9 +37,8 @@ let dispatchMacroCall = (
|
|||
}
|
||||
| _ => REAssignmentExpected->Error
|
||||
}
|
||||
|
||||
|
||||
let doBindExpression = (bindingExpr: expression, statement: expression, environment) =>
|
||||
let doBindExpression = (bindingExpr: expression, statement: expression, environment) =>
|
||||
switch statement {
|
||||
| ExpressionT.EList(list{ExpressionT.EValue(EvCall("$let")), symbolExpr, statement}) => {
|
||||
let rExternalBindingsValue = reduceExpression(
|
||||
|
@ -74,7 +73,7 @@ let dispatchMacroCall = (
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let doBlock = (exprs: list<expression>, _bindings: ExpressionT.bindings, _environment): result<
|
||||
expression,
|
||||
errorValue,
|
||||
|
|
|
@ -32,7 +32,7 @@ let parse = (mathJsCode: string): result<t, errorValue> =>
|
|||
let rec reduceExpression = (expression: t, bindings: T.bindings, environment: environment): result<
|
||||
expressionValue,
|
||||
'e,
|
||||
> =>
|
||||
> =>
|
||||
switch expression {
|
||||
| T.EValue(value) => value->Ok
|
||||
| T.EList(list) =>
|
||||
|
@ -119,10 +119,15 @@ let evaluatePartialUsingExternalBindings = (
|
|||
externalBindings: ReducerInterface_ExpressionValue.externalBindings,
|
||||
environment: ReducerInterface_ExpressionValue.environment,
|
||||
): result<externalBindings, errorValue> => {
|
||||
let rAnswer = evaluateUsingOptions(~environment=Some(environment), ~externalBindings=Some(externalBindings), code)
|
||||
let rAnswer = evaluateUsingOptions(
|
||||
~environment=Some(environment),
|
||||
~externalBindings=Some(externalBindings),
|
||||
code,
|
||||
)
|
||||
switch rAnswer {
|
||||
| Ok(EvRecord(externalBindings)) => Ok(externalBindings)
|
||||
| Ok(_) => Error(Reducer_ErrorValue.RESyntaxError(`Partials must end with an assignment or record`))
|
||||
| Error(err) => err->Error
|
||||
| Ok(EvRecord(externalBindings)) => Ok(externalBindings)
|
||||
| Ok(_) =>
|
||||
Error(Reducer_ErrorValue.RESyntaxError(`Partials must end with an assignment or record`))
|
||||
| Error(err) => err->Error
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,10 @@ external castString: unit => string = "%identity"
|
|||
/*
|
||||
As JavaScript returns us any type, we need to type check and cast type propertype before using it
|
||||
*/
|
||||
let jsToEv = (jsValue): result<expressionValue, errorValue> =>
|
||||
let jsToEv = (jsValue): result<expressionValue, errorValue> =>
|
||||
switch Js.typeof(jsValue) {
|
||||
| "boolean" => jsValue->castBool->EvBool->Ok
|
||||
| "number" => jsValue->castNumber->EvNumber->Ok
|
||||
| "string" => jsValue->castString->EvString->Ok
|
||||
| other => RETodo(`Unhandled MathJs literal type: ${Js.String.make(other)}`)->Error
|
||||
}
|
||||
|
||||
|
|
|
@ -2,13 +2,11 @@ module ExpressionValue = ReducerInterface_ExpressionValue
|
|||
type expressionValue = ReducerInterface_ExpressionValue.expressionValue
|
||||
|
||||
let defaultEnv: DistributionOperation.env = {
|
||||
sampleCount: MagicNumbers.Environment.defaultSampleCount,
|
||||
xyPointLength: MagicNumbers.Environment.defaultXYPointLength,
|
||||
}
|
||||
sampleCount: MagicNumbers.Environment.defaultSampleCount,
|
||||
xyPointLength: MagicNumbers.Environment.defaultXYPointLength,
|
||||
}
|
||||
|
||||
let runGenericOperation = DistributionOperation.run(
|
||||
~env=defaultEnv,
|
||||
)
|
||||
let runGenericOperation = DistributionOperation.run(~env=defaultEnv)
|
||||
|
||||
module Helpers = {
|
||||
let arithmeticMap = r =>
|
||||
|
@ -30,14 +28,13 @@ module Helpers = {
|
|||
let catchAndConvertTwoArgsToDists = (args: array<expressionValue>): option<(
|
||||
DistributionTypes.genericDist,
|
||||
DistributionTypes.genericDist,
|
||||
)> =>
|
||||
)> =>
|
||||
switch args {
|
||||
| [EvDistribution(a), EvDistribution(b)] => Some((a, b))
|
||||
| [EvNumber(a), EvDistribution(b)] => Some((GenericDist.fromFloat(a), b))
|
||||
| [EvDistribution(a), EvNumber(b)] => Some((a, GenericDist.fromFloat(b)))
|
||||
| _ => None
|
||||
}
|
||||
|
||||
|
||||
let toFloatFn = (
|
||||
fnCall: DistributionTypes.DistributionOperation.toFloat,
|
||||
|
@ -121,7 +118,7 @@ module Helpers = {
|
|||
mixtureWithGivenWeights(distributions, weights)
|
||||
}
|
||||
|
||||
let mixture = (args: array<expressionValue>): DistributionOperation.outputType =>
|
||||
let mixture = (args: array<expressionValue>): DistributionOperation.outputType =>
|
||||
switch E.A.last(args) {
|
||||
| Some(EvArray(b)) => {
|
||||
let weights = parseNumberArray(b)
|
||||
|
@ -140,7 +137,6 @@ module Helpers = {
|
|||
}
|
||||
| _ => GenDistError(ArgumentError("Last argument of mx must be array or distribution"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module SymbolicConstructors = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user