Skip to content

Lens products #28

Description

@cfhammill

From Control.Lens.Unsound


lensProduct :: ALens' s a -> ALens' s b -> Lens' s (a, b)

A lens product. There is no law-abiding way to do this in general. Result is only a valid Lens if the input lenses project disjoint parts of the structure s. Otherwise "you get what you put in" law

view l (set l v s) ≡ v

is violated by

>>> let badLens :: Lens' (Int, Char) (Int, Int); badLens = lensProduct _1 _1
>>> view badLens (set badLens (1,2) (3,'x'))
(2,2)

but we should get (1,2).

Are you looking for alongside?


The answer is yes, we are probably looking for alongside.

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