tweak: Work out how to apply a function to an

arbitrary value in the Danger domain
This commit is contained in:
NunoSempere 2022-09-04 19:29:22 +02:00
parent b45ab3dba2
commit f82c00a6ed

View File

@ -74,6 +74,8 @@ module Internals = {
) )
result result
} }
let internalZero = ReducerInterface_InternalExpressionValue.IEvNumber(0.0)
let applyFunctionAtZero = (aLambda) => applyFunctionAtPoint(aLambda, internalZero)
} }
@ -127,6 +129,27 @@ let library = [
~definitions=[FunctionToNumberZero.make("functionToZero", x => x)], ~definitions=[FunctionToNumberZero.make("functionToZero", x => x)],
(), (),
), ),
Function.make(
~name="applyFunctionAtZero",
~nameSpace,
~output=EvtArray,
~requiresNamespace=false,
~examples=[`Danger.applyFunctionAtZero({|x| x+1})`],
~definitions=[
FnDefinition.make(
~name="applyFunctionAtPoint",
~inputs=[FRTypeLambda],
~run=(inputs, _, env, reducer) =>
switch inputs {
| [IEvLambda(aLambda)] =>
Internals.applyFunctionAtZero(aLambda, env, reducer)->E.R2.errMap(_ => "Error!")
| _ => Error(impossibleError)
},
(),
),
],
(),
),
Function.make( Function.make(
~name="applyFunctionAtPoint", ~name="applyFunctionAtPoint",
~nameSpace, ~nameSpace,