2022-06-24 10:15:38 +00:00
|
|
|
module IEV = ReducerInterface_InternalExpressionValue
|
|
|
|
type internalExpressionValue = IEV.t
|
2022-06-06 21:42:49 +00:00
|
|
|
|
2022-07-13 16:37:39 +00:00
|
|
|
let dispatch = (call: IEV.functionCall, _: GenericDist.env): option<
|
2022-06-24 10:15:38 +00:00
|
|
|
result<internalExpressionValue, QuriSquiggleLang.Reducer_ErrorValue.errorValue>,
|
2022-06-06 21:42:49 +00:00
|
|
|
> => {
|
|
|
|
switch call {
|
2022-06-24 10:15:38 +00:00
|
|
|
| ("toString", [IEvTimeDuration(t)]) => IEV.IEvString(DateTime.Duration.toString(t))->Ok->Some
|
|
|
|
| ("minutes", [IEvNumber(f)]) => IEV.IEvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some
|
2022-06-23 18:38:07 +00:00
|
|
|
| ("fromUnit_minutes", [IEvNumber(f)]) =>
|
2022-06-24 10:15:38 +00:00
|
|
|
IEV.IEvTimeDuration(DateTime.Duration.fromMinutes(f))->Ok->Some
|
|
|
|
| ("hours", [IEvNumber(f)]) => IEV.IEvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some
|
2022-06-23 18:38:07 +00:00
|
|
|
| ("fromUnit_hours", [IEvNumber(f)]) =>
|
2022-06-24 10:15:38 +00:00
|
|
|
IEV.IEvTimeDuration(DateTime.Duration.fromHours(f))->Ok->Some
|
|
|
|
| ("days", [IEvNumber(f)]) => IEV.IEvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some
|
|
|
|
| ("fromUnit_days", [IEvNumber(f)]) =>
|
|
|
|
IEV.IEvTimeDuration(DateTime.Duration.fromDays(f))->Ok->Some
|
|
|
|
| ("years", [IEvNumber(f)]) => IEV.IEvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some
|
2022-06-23 18:38:07 +00:00
|
|
|
| ("fromUnit_years", [IEvNumber(f)]) =>
|
2022-06-24 10:15:38 +00:00
|
|
|
IEV.IEvTimeDuration(DateTime.Duration.fromYears(f))->Ok->Some
|
|
|
|
| ("toHours", [IEvTimeDuration(f)]) => IEV.IEvNumber(DateTime.Duration.toHours(f))->Ok->Some
|
|
|
|
| ("toMinutes", [IEvTimeDuration(f)]) => IEV.IEvNumber(DateTime.Duration.toMinutes(f))->Ok->Some
|
|
|
|
| ("toDays", [IEvTimeDuration(f)]) => IEV.IEvNumber(DateTime.Duration.toDays(f))->Ok->Some
|
|
|
|
| ("toYears", [IEvTimeDuration(f)]) => IEV.IEvNumber(DateTime.Duration.toYears(f))->Ok->Some
|
2022-06-23 18:38:07 +00:00
|
|
|
| ("add", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) =>
|
2022-06-24 10:15:38 +00:00
|
|
|
IEV.IEvTimeDuration(DateTime.Duration.add(d1, d2))->Ok->Some
|
2022-06-23 18:38:07 +00:00
|
|
|
| ("subtract", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) =>
|
2022-06-24 10:15:38 +00:00
|
|
|
IEV.IEvTimeDuration(DateTime.Duration.subtract(d1, d2))->Ok->Some
|
2022-06-23 18:38:07 +00:00
|
|
|
| ("multiply", [IEvTimeDuration(d1), IEvNumber(d2)]) =>
|
2022-06-24 10:15:38 +00:00
|
|
|
IEV.IEvTimeDuration(DateTime.Duration.multiply(d1, d2))->Ok->Some
|
2022-06-23 18:38:07 +00:00
|
|
|
| ("divide", [IEvTimeDuration(d1), IEvNumber(d2)]) =>
|
2022-06-24 10:15:38 +00:00
|
|
|
IEV.IEvTimeDuration(DateTime.Duration.divide(d1, d2))->Ok->Some
|
|
|
|
| ("divide", [IEvTimeDuration(d1), IEvTimeDuration(d2)]) => IEV.IEvNumber(d1 /. d2)->Ok->Some
|
2022-06-06 21:42:49 +00:00
|
|
|
| _ => None
|
|
|
|
}
|
2022-06-08 15:21:20 +00:00
|
|
|
}
|