Skip to content

Should prism and lens be defined as  #57

Open
@phadej

Description

@phadej
prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b
prism setter getter pab = dimap getter (either id setter) (right pab)

Then there won't be unnecessary rmap preprocessing.

lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
lens getter setter pab = dimap (\s -> (getter s, s)) (\(b, s) -> setter s b) (first' pab)

and here we won't apply setter to s before actually needed (making of pair is unavoidable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions