Using setl and view for the same optic in one function gives error "The type Data.Identity does not match the type Data.Const" #344
Open
Description
I'm trying to use optics to set a record field together with the record's UpdatedAt: DateTimeOffset
field only if the field value has changed.
I have created the following generic function, which doesn't compile:
let inline private setField valueOptic value updatedAtOptic now source =
let oldVal = view valueOptic source
if value = oldVal then source
else
setl valueOptic value source
|> setl updatedAtOptic now
What am I doing wrong?