Conversation
|
I suggest a change in names : |
62b3b1b to
35277d8
Compare
|
Sure, done! |
|
Should the unsafe versions be added, too? I see that for example |
| where | ||
| n' = max n 0 | ||
| m = length v | ||
| i = max 0 (m - n) |
There was a problem hiding this comment.
What happens if n is negative? What about doing max 0 (m - n') instead? 😄
There was a problem hiding this comment.
Based on the code I read for dropand take functions, I think the use of delay_inline could be important to get the best possible optimizations. I might be wrong because I'm not familiar with fusion, but I think using the same approach as what in done in take and dropis a safe default.
EDIT : As I said in an earlier comment, it would be nice to have the unsafe versions too.
| -- contain less than @n@ elements in which case it is returned unchanged. | ||
| takeEnd :: Vector v a => Int -> v a -> v a | ||
| {-# INLINE_FUSED takeEnd #-} | ||
| takeEnd n v = unsafeSlice i (min n' m) v |
There was a problem hiding this comment.
Based on the use of delay_inline in takefunction, I think this should be:
unsafeSlice i (delay_inline min n' m) v
| where | ||
| n' = max n 0 | ||
| m = length v | ||
| i = max 0 (m - n) |
There was a problem hiding this comment.
Based on the use of delay_inline in take function, I think this should be:
i = delay_inline max 0 (m-n')
| -- contain less than @n@ elements in which case an empty vector is returned. | ||
| dropEnd :: Vector v a => Int -> v a -> v a | ||
| {-# INLINE_FUSED dropEnd #-} | ||
| dropEnd n v = unsafeSlice 0 (max 0 (m - n')) v |
There was a problem hiding this comment.
Here also, I think we need to add a delay_inline for the max
| where | ||
| n' = max n 0 | ||
| m = length v | ||
| i = max 0 (m - n) |
There was a problem hiding this comment.
I guess it's safer to write max 0 (m-n')
| model = V.toList | ||
| unmodel = V.fromList | ||
|
|
||
| naiveTakeEnd :: Int -> [a] -> [a] |
There was a problem hiding this comment.
This test function is duplicated to be used in two files, I would rather put it in a separate module to avoid duplication, like the existing Utilitiesmodule.
There was a problem hiding this comment.
Moved to Utilities
| naiveTakeEnd :: Int -> [a] -> [a] | ||
| naiveTakeEnd n = reverse . take n . reverse | ||
|
|
||
| naiveDropEnd :: Int -> [a] -> [a] |
There was a problem hiding this comment.
Moved to Utilities
|
Thanks for the thorough review! Next step is to add the unsafe versions as well then. I wish it would be less boilerplate-y though |
3591ce1 to
8fc97c6
Compare
|
@markus1189 Yes, it looks like it will be a lot of copy / paste / change one word stuff :) Maybe you can ask a maintainer of the library if it's necessary or not, before doing the work of adding the unsafe versions. (I'm not a maintainer myself) |
3b5c20c to
8b05a50
Compare
|
I added the |
|
|
||
| unsafeTakeEnd :: MVector v a => Int -> v s a -> v s a | ||
| {-# INLINE unsafeTakeEnd #-} | ||
| unsafeTakeEnd n v = unsafeSlice (m - n) m v |
There was a problem hiding this comment.
the second argument is wrong I think, it should be n ?
Maybe adding tests for the unsafe versions would be a good idea (the same tests as for the safe ones)
| -- contain at least @n@ elements but this is not checked. | ||
| unsafeTakeEnd :: Vector v a => Int -> v a -> v a | ||
| {-# INLINE unsafeTakeEnd #-} | ||
| unsafeTakeEnd n v = unsafeSlice (m - n) m v |
There was a problem hiding this comment.
Here too, m should be n
|
I am willing to continue to work on this, but before I do I would like to have some feedback from the maintainers whether this is wanted at all. 😉 |
|
Probably?
I / Dan / Ryan are eyeballs deep in work / oss backlog (or at least I am :))
Hit me up this Saturday morning/ midday on freenode on one of the Haskell
channels (#numerical-haskell may have some folks who can also help review )
if I’ve not looked at it by then. Or Twitter. Handles there are
respectively Carter and cartazio.
Cheers.
…On Wed, Jan 17, 2018 at 2:35 PM Markus Hauck ***@***.***> wrote:
I am willing to continue to work on this, but before I do I would like to
have some feedback from the maintainers whether this is wanted at all. 😉
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#191 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwlqHevG5Hx4seEgYjybb70G7XYMIks5tLktmgaJpZM4RF2gw>
.
|
|
Okay I'll try to fix the issues until Saturday. I don't know yet how much
time I'll have on Saturday, but for the records: what's your timezone? :D
I'm in CET (Frankfurt, Germany)
On Wed, Jan 17, 2018 at 9:29 PM, Carter Tazio Schonwald <
notifications@github.com> wrote:
… Probably?
I / Dan / Ryan are eyeballs deep in work / oss backlog (or at least I am
:))
Hit me up this Saturday morning/ midday on freenode on one of the Haskell
channels (#numerical-haskell may have some folks who can also help review )
if I’ve not looked at it by then. Or Twitter. Handles there are
respectively Carter and cartazio.
Cheers.
On Wed, Jan 17, 2018 at 2:35 PM Markus Hauck ***@***.***>
wrote:
> I am willing to continue to work on this, but before I do I would like to
> have some feedback from the maintainers whether this is wanted at all. 😉
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#191 (comment)>, or
mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/
AAAQwlqHevG5Hx4seEgYjybb70G7XYMIks5tLktmgaJpZM4RF2gw>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#191 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAkGz1vrf6M_nl596eiok4frB6iJjFt6ks5tLlhCgaJpZM4RF2gw>
.
|
|
NYC time :)
On Thu, Jan 18, 2018 at 5:12 AM, Markus Hauck <notifications@github.com>
wrote:
… Okay I'll try to fix the issues until Saturday. I don't know yet how much
time I'll have on Saturday, but for the records: what's your timezone? :D
I'm in CET (Frankfurt, Germany)
On Wed, Jan 17, 2018 at 9:29 PM, Carter Tazio Schonwald <
***@***.***> wrote:
> Probably?
> I / Dan / Ryan are eyeballs deep in work / oss backlog (or at least I am
> :))
>
> Hit me up this Saturday morning/ midday on freenode on one of the Haskell
> channels (#numerical-haskell may have some folks who can also help
review )
> if I’ve not looked at it by then. Or Twitter. Handles there are
> respectively Carter and cartazio.
>
> Cheers.
>
>
>
> On Wed, Jan 17, 2018 at 2:35 PM Markus Hauck ***@***.***>
> wrote:
>
> > I am willing to continue to work on this, but before I do I would like
to
> > have some feedback from the maintainers whether this is wanted at all.
😉
> >
> > —
> > You are receiving this because you are subscribed to this thread.
> > Reply to this email directly, view it on GitHub
> > <#191 (comment)>,
or
> mute
> > the thread
> > <https://github.com/notifications/unsubscribe-auth/
> AAAQwlqHevG5Hx4seEgYjybb70G7XYMIks5tLktmgaJpZM4RF2gw>
> > .
>
> >
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#191 (comment)>, or
mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AAkGz1vrf6M_
nl596eiok4frB6iJjFt6ks5tLlhCgaJpZM4RF2gw>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#191 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwrWPOaCUJHxZamahWHwUFwlzqauPks5tLxkCgaJpZM4RF2gw>
.
|
153bb8e to
90dd307
Compare
|
I kind of gave up on writing the prop for the naive version. It seems like there is quite some customizing going on in the QuickCheck tests. Some help would be great there ;) @OlivierSohn Fixed the issues you raised, thanks a lot for the in-depth reviews! |
|
possibly dumb question, and this might just be me missing a difference ... but how is takeEnd different from drop?, just a difference in in counting from front of vector vs end of vector? this seems to be a useful difference, and the key one that motivates the changes? |
|
so one possible question about this for code simplification: is there any reason to not define takeEnd in terms of drop, and dropEnd in terms of take? (one reason not to would be if the generated core was less awesome under O2 or something) |
|
also you duplicated an Orphan, https://travis-ci.org/haskell/vector/jobs/330841124#L908-L918 |
| -- TODO: test non-IVector stuff? | ||
|
|
||
| #if !MIN_VERSION_base(4,7,0) | ||
| instance Foldable ((,) a) where |
There was a problem hiding this comment.
ORPHAN, see Data.Orphan in tests
90dd307 to
7ed68e5
Compare
|
@cartazio Yes indeed, I missed those handy functions recently and thought to add them (this was in 24pullrequests btw :) ) This got a little out of hand, I thought it would be much less stuff to do, though 😉 Will check the orphans |
|
I guess my point is that if those overheads/extra calculations are optimized away under O2 level optimization and have equivalent fusion characteristics, may as well do the simpler definition in terms of preexisting high level operations. I would be surprised if the optimized core isn't essentially the same. (worth a bug report even :) ) |
I see the same error on my pull request #196, strange... is it possible to launch a build of master to see if the build is still ok? |
|
master is fine, this patch is the issue :) |
|
i restarted the PR build so we can look again |
|
Sorry but I have to abandon this as I don't come around to do it. If anyone wants to pick it up, feel free ;) |
|
I think it would bo good to consider using the names |
|
@noughtmare Would you like to create an issue with a link to this PR, so it doesn't get forgotten and someone with time on their hands can pick it up. |
I missed those functions recently and added them.
This was quite a bit of boilerplate 😞