Skip to content

Commit 323a550

Browse files
keep args as objs inside of CallObj instead of exps
1 parent 3ca8568 commit 323a550

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/services/diff/obj.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ const baseBuiltInDiffFunc =
3636
Effect.flatMap((diffFn) =>
3737
Match.value(diffFn).pipe(
3838
Match.when("sin", () =>
39-
Effect.succeed(
40-
CallObj.make({
41-
fn: BuiltInObj.make({ fn: "cos" }),
42-
args,
43-
}),
39+
Schema.decodeUnknown(PolynomialObj)(args[0]).pipe(
40+
Effect.flatMap((g) =>
41+
chainRule(
42+
CallObj.make({
43+
fn: BuiltInObj.make({ fn: "cos" }),
44+
args,
45+
}),
46+
g,
47+
x,
48+
),
49+
),
4450
),
4551
),
4652
Match.when("cos", () =>

src/services/evaluator/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import type { Obj } from "@/schemas/objs/union";
1818
import { PolynomialObj } from "@/schemas/objs/unions/polynomials";
1919
import { fnTokenSchema } from "@/schemas/token/function-literal";
2020
import { Effect, Either, Match, Schema } from "effect";
21-
import { left } from "effect/Either";
2221
import type { ParseError } from "effect/ParseResult";
2322
import type { KennethParseError } from "src/errors/kenneth/parse";
2423
import type { DiffExp } from "src/schemas/nodes/exps/diff";
@@ -138,7 +137,9 @@ const nodeEvalMatch = (env: Environment) =>
138137
Schema.decodeUnknownEither(BuiltInDiffObj)(fnEval);
139138

140139
return yield* Either.isRight(either) && identoverlap
141-
? Effect.succeed(CallObj.make({ fn: either.right, args }))
140+
? Effect.succeed(
141+
CallObj.make({ fn: either.right, args: argsEval }),
142+
)
142143
: applyFunction(obj)(argsEval);
143144
}),
144145
),

0 commit comments

Comments
 (0)