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

Implement unfoldrExactN & unfoldrExactNM #295

Merged
merged 1 commit into from
Jun 7, 2020

Conversation

Shimuuar
Copy link
Contributor

@Shimuuar Shimuuar commented Feb 2, 2020

Fixes #140

Copy link
Contributor

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good, but haddock needs fixing, it still describes the behavior of unfoldrN functions

Data/Vector.hs Outdated
@@ -691,6 +691,15 @@ unfoldrN :: Int -> (b -> Maybe (a, b)) -> b -> Vector a
{-# INLINE unfoldrN #-}
unfoldrN = G.unfoldrN

-- | /O(n)/ Construct a vector with at most @n@ elements by repeatedly applying
-- the generator function to a seed. The generator function yields 'Just' the
-- next element and the new seed or 'Nothing' if there are no more elements.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and other places the doc was copy pasted and needs fixing.

{-# INLINE_FUSED unfoldrExactN #-}
unfoldrExactN n f = unfoldrExactNM n (return . f)

-- | Unfold at most @n@ elements with a monadic functions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should say Unfold exactly @n@ elements ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I thought I fixed haddock... Thanks! I guess I mixed up copy-paste somewhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc is still not right :)

Should say: Unfold exactly @n@ elements with a monadic function

(note function is not plural)

@Shimuuar
Copy link
Contributor Author

Shimuuar commented Feb 3, 2020

I think I fixed haddocks

@@ -437,6 +437,11 @@ unfoldrN :: Int -> (s -> Maybe (a, s)) -> s -> Bundle v a
{-# INLINE unfoldrN #-}
unfoldrN = M.unfoldrN

-- | Unfold at most @n@ elements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:

Unfold exactly @n@ elements

Copy link
Contributor

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lehins
Copy link
Contributor

lehins commented Jun 7, 2020

I made a minor adjustment to this PR: lehins@ccc6e50

Once the CI passes it will be good to merge

@lehins lehins merged commit 01f3e2d into haskell:master Jun 7, 2020
@Shimuuar Shimuuar deleted the kh/unfoldr-exact branch June 19, 2020 18:15
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 this pull request may close these issues.

add exact size unfoldrN(M)
2 participants