Skip to content

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
@cmeeren

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

image

What am I doing wrong?

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions