Remove property token adjustment

This commit is contained in:
InversionSpaces 2023-10-31 11:44:32 +00:00
parent 78ee753c7b
commit 27d72f2bff

View File

@ -96,20 +96,18 @@ class ValuesAlgebra[S[_], Alg[_]: Monad](using
}
case prop @ PropertyToken(value, properties) =>
prop.adjust.fold(
for {
valueRaw <- valueToRaw(value)
result <- valueRaw.flatTraverse(raw =>
properties
.foldLeftM(raw) { case (prev, op) =>
OptionT(
resolveSingleProperty(prev.`type`, op)
).map(prop => ApplyPropertyRaw(prev, prop))
}
.value
)
} yield result
)(valueToRaw)
for {
valueRaw <- valueToRaw(value)
result <- valueRaw.flatTraverse(raw =>
properties
.foldLeftM(raw) { case (prev, op) =>
OptionT(
resolveSingleProperty(prev.`type`, op)
).map(prop => ApplyPropertyRaw(prev, prop))
}
.value
)
} yield result
case dvt @ NamedValueToken(typeName, fields) =>
(for {
@ -311,15 +309,14 @@ class ValuesAlgebra[S[_], Alg[_]: Monad](using
}
def valueToCall(v: ValueToken[S]): Alg[Option[(ValueRaw, ArrowType)]] =
valueToRaw(v).flatMap(
_.flatTraverse {
case ca: CallArrowRaw => (ca, ca.baseType).some.pure[Alg]
case apr @ ApplyPropertyRaw(_, IntoArrowRaw(_, arrowType, _)) =>
(apr, arrowType).some.pure[Alg]
// TODO: better error message (`raw` formatting)
case raw => report.error(v, s"Expected arrow call, got $raw").as(none)
}
)
valueToRaw(v).flatMap(_.flatTraverse {
case ca: CallArrowRaw =>
(ca, ca.baseType).some.pure[Alg]
case apr @ ApplyPropertyRaw(_, IntoArrowRaw(_, arrowType, _)) =>
(apr, arrowType).some.pure[Alg]
// TODO: better error message (`raw` formatting)
case raw => report.error(v, s"Expected arrow call, got $raw").as(none)
})
def valueToTypedRaw(v: ValueToken[S], expectedType: Type): Alg[Option[ValueRaw]] =
OptionT(valueToRaw(v))