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

Indexed version of overA #772

Open
pepeiborra opened this issue Oct 20, 2017 · 1 comment
Open

Indexed version of overA #772

pepeiborra opened this issue Oct 20, 2017 · 1 comment

Comments

@pepeiborra
Copy link
Contributor

Given the arrowized version of over currently in the Control.Lens.Lens module

overA :: Arrow ar => LensLike (Context a b) s t a b -> ar a b -> ar s t

Is there a technical reason for the absence of an indexed version with the obvious type signature ?

ioverA :: Arrow ar => IndexedLensLike i (Context a b) s t a b -> ar (i,a) b -> ar s t
@pepeiborra
Copy link
Contributor Author

Proof of concept (but not good enough):

ioverA :: Arrow ar => IndexedLens i s t a b -> ar (i,a) b -> ar s t
ioverA l p = arr (\x -> (x, iview x)) >>> second p >>> arr (\(x, b) -> storing l b x)
  where
    iview s = getConst $ l (Indexed $ \i -> Const #. (,) i) s

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

No branches or pull requests

1 participant