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

[Grate Module] Should collectOf be defined as #62

Closed
syaiful6 opened this issue May 24, 2017 · 2 comments · Fixed by #63
Closed

[Grate Module] Should collectOf be defined as #62

syaiful6 opened this issue May 24, 2017 · 2 comments · Fixed by #63
Labels
purs-0.14 A reminder to address this issue or merge this PR before we release PureScript v0.14.0

Comments

@syaiful6
Copy link
Contributor

syaiful6 commented May 24, 2017

so i played with Grate and Distributive. It look like collectOf should be defined like this:

collectOf :: forall f s t a b. Functor f => Optic (Costar f) s t a (f a) -> (b -> s) -> f b -> t
collectOf g f = zipFWithOf g id <<< map f

so i can do collectOf cotraversed, in psci it yield type:

:t collectOf cotraversed
forall t1 t5 t7 t8. Functor t5 => Distributive t8 => (t1 -> t8 t7) -> t5 t1 -> t8 (t5 t7)

which what i want. But if i apply the current implementation to cotraversed it will yied:

:t collectOf cotraversed
forall t5 t6 t7 t8. Distributive t8 => Distributive t5 => (t7 -> t5 t6) -> t8 t7 -> t5 (t8 t6)

which i believe not what we want. Notice the Distributive constraint appear both in input and output.

@syaiful6
Copy link
Contributor Author

the b type suddenly introduced on my collectOf, it look like because how this type f b -> a composed.

@paf31
Copy link
Contributor

paf31 commented May 25, 2017

Yes, I think this is right. It took me a while to see it, but the grate in collectOf is currently trying to replace the wrong functor. It should be taking the place of the Distributive funtctor, not the other one.

Could you make a PR please?

Thanks!

@thomashoneyman thomashoneyman added the purs-0.14 A reminder to address this issue or merge this PR before we release PureScript v0.14.0 label Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
purs-0.14 A reminder to address this issue or merge this PR before we release PureScript v0.14.0
Development

Successfully merging a pull request may close this issue.

3 participants