Conversation
Use `!?` for vector `ix` rather than manual range calculations. Once [this PR](haskell/vector#347) lands, that will also make the lookups eager, as they should be.
phadej
left a comment
There was a problem hiding this comment.
Eager here means that we don't retain the original sequence/vector, i.e. f x is f <element value> and not f <think to lookup element>?
If my understanding is right, could you amend commit message(s) with that, so it would be clearer what these changes do.
| Nothing -> pure m | ||
| #else | ||
| ix i f m | ||
| | 0 <= i && i < Seq.length m = f (Seq.index m i) <&> \a -> Seq.update i a m |
There was a problem hiding this comment.
Is here impossible to seq things to avoid thunk, Would
let x = Seq.index m i `seq` (f x <&> ...)
do anything?
There was a problem hiding this comment.
Using seq with index would force too much, forcing not only the lookup but also the element itself.
There was a problem hiding this comment.
I see. as later then 0.5.8 containers are bundled with GHC-8.2, I don't think we need to do here anything. (If someone have problems due this lazyness, and they could upgrade GHC or/and containers)
There was a problem hiding this comment.
@phadej Do you mean we shouldn't worry about the leak for older containers? I agree. Trying to plug it in that context will be very inefficient when f is actually strict.
|
@phadej For |
|
What is the status of this PR? If I'm reading correctly, this is very nearly done modulo documentation/changelog concerns. (I'm asking since I'm doing a roundup of recent PRs before an upcoming |
|
Haven't looked at this in ages. Can try to look today. |
|
ping @treeowl |
|
Pong! I will try to look at this today. |
ixlook up eagerly forSeq.ixuse!?for vectors, which should eventually make those lookups eager too.