-
Notifications
You must be signed in to change notification settings - Fork 139
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
add generic traverse method, a la Data.Traversable #69
Comments
GOOD IDEA. |
It's actually difficult to be very efficient (I think). The problem is that the efficient way to build a vector is to write to a mutable vector and freeze. But when you are traversing, you have an arbitrary applicative involved blocking your ability to do efficient ST stuff. So, you can only build up ST actions as closures, or use an intermediate list/stream. You can do better than creating a list first, of course. But it might always be a bit lackluster. I think it's a good thing to have, though. |
I think it might look like this. Feel free to disregard the lens import, I was just using it for testing. |
It would also be very useful to have |
Cant we define the stream / bundle version efficiently of traverse
|
Without contributing anything useful so far here, I'd benefit a lot from the |
Maybe. The trouble is that Stream and Bundle need an underlying monad, but traverse only gives us an applicative. But I think we can get away with a monad transformer that carries the applicative "along for the ride," as if it were some kind of monoidal functor. |
I am very interested in having some way of traversing vectors efficiently, especially in the way of the |
@dolio now that primMonad is stackable, can we do something for mutable vectors that partially addresses this? |
BUMP |
this and some related stuff will be in the next minor and major releases both |
Unboxed vectors can't be Traversable due to the Unbox constraint on the element type, but it would be very useful if there were an analogous generic traverse method:
Even better would be if it were efficient, i.e., didn't just convert to and from lists (like the Traversable instance for boxed vectors does) -- but I'm not sure if this is even possible.
sequence
comes close, except that it requiresMonad m
andVector v (m a)
, which will typically not hold for unboxed vectors.The text was updated successfully, but these errors were encountered: