Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should prism and lens be defined as #57

Open
phadej opened this issue Apr 2, 2017 · 1 comment
Open

Should prism and lens be defined as #57

phadej opened this issue Apr 2, 2017 · 1 comment

Comments

@phadej
Copy link

phadej commented Apr 2, 2017

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)

@phadej phadej changed the title Should prism be defined as Should prism and lens be defined as Apr 2, 2017
@paf31
Copy link
Contributor

paf31 commented Apr 2, 2017

That sounds like an improvement to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants