Skip to content

lens-join/* functions produce non-lenses when views overlap #301

@lexi-lambda

Description

@lexi-lambda

It’s quite easy to produce a lens with, for example, lens-join/list that is not actually a lens; that is, it does not respect the lens laws. Specifically, the produced lens violates set-get consistency when the views of the sublenses overlap. Here’s an example:

> (let ([l (lens-join/list first-lens first-lens)])
    (lens-view l (lens-set l '(a b) '(1 2))))
'(2 2)

This produces '(2 2), but the set-get consistency law demands that it produce '(1 2).

The documentation sort of notes this in the following comment:

If any of the lenses share views, then when setting the later lenses override the earlier ones.

However, I don’t think this is phrased quite scarily enough. I think it should be reworded to make it quite clear that the lens-join/* functions do not produce legal lenses when given lenses with overlapping views.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions