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

mapWithIndex should reuse Data.FunctorWithIndex.mapWithIndexArray #232

Closed
JordanMartinez opened this issue Aug 22, 2022 · 3 comments · Fixed by #233
Closed

mapWithIndex should reuse Data.FunctorWithIndex.mapWithIndexArray #232

JordanMartinez opened this issue Aug 22, 2022 · 3 comments · Fixed by #233

Comments

@JordanMartinez
Copy link
Contributor

This library defines the monomorphic mapWithIndex function as a zipWith function on the initial array and an indices-array constructed using the input array's size. I'd guess it's actually slower than just using FunctorWithIndex.mapWithindex.

The actual monomorphic and dictionary-less mapWithIndex FFI is defined in foldable-traversable via mapWithIndexArray. Perhaps the mapWithIndexArray could be exported in FunctorWithIndex, such that we can re-export here under the name mapWithIndex?

@natefaubion
Copy link

natefaubion commented Aug 22, 2022

I think the FFI implementation needs to move here because foldable-traversable depends on arrays.

Edit: I take that back, it does not depend on arrays. Arrays depends on foldable-traversable.

@natefaubion
Copy link

I think that exporting a monomorphic version that's just an alias of the dictionary version would have identical performance characteristics because it would be partially applied.

@JordanMartinez
Copy link
Contributor Author

Works for me.

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

Successfully merging a pull request may close this issue.

2 participants