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

unstreamIntoM improvements #103

Open
lehins opened this issue Jul 7, 2020 · 0 comments
Open

unstreamIntoM improvements #103

lehins opened this issue Jul 7, 2020 · 0 comments

Comments

@lehins
Copy link
Owner

lehins commented Jul 7, 2020

unstreamIntoM ::
(Mutable r Ix1 a, PrimMonad m)
=> MArray (PrimState m) r Ix1 a
-> Size
-> S.Stream Id a
-> m (MArray (PrimState m) r Ix1 a)
unstreamIntoM marr sz str =
case sz of
Exact _ -> marr <$ unstreamMaxM marr str
Max _ -> unsafeLinearShrink marr . SafeSz =<< unstreamMaxM marr str
Unknown -> unstreamUnknownM marr str
{-# INLINE unstreamIntoM #-}

Either improve unstreamIntoM or add a separate function that can also:

  • return the number of elements that have been loaded
  • grow the array with Max and Exact sizes as well, if the mutable target doesn't have enough
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

No branches or pull requests

1 participant