scalus
scalus copied to clipboard
Data Lenses API. (enhanchement)
DataLense is an expression Data=>Data, which can be generated from the access function. I.e. in data we have two new methods:
Data.fromDataLensed[A,B](data: Data, indexFunction: A=>B): B
Data.lense[A,B]: Data => Data
which will generate data access API calls in compile time.
Usage:
val firstInput = Data.fromDataLensed((s:ScriptContext) => s.inputs.head)
Developers can control what to do: use lensed access or fully deserialize objects.
The initial sketch of the implementation design: https://github.com/nau/scalus/pull/7
(Type inference can be better ...)