scalus icon indicating copy to clipboard operation
scalus copied to clipboard

Data Lenses API. (enhanchement)

Open rssh opened this issue 1 year ago • 0 comments

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 ...)

rssh avatar May 12 '24 11:05 rssh