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

Getting some results #38

Open
treeowl opened this issue Jul 30, 2021 · 5 comments
Open

Getting some results #38

treeowl opened this issue Jul 30, 2021 · 5 comments
Labels
enhancement New feature or request low priority

Comments

@treeowl
Copy link
Collaborator

treeowl commented Jul 30, 2021

When you want more than one result, but not all of them, things can be a tad awkward. First off, there's no native function to do that! An obvious one might be

splitUpTo :: Int -> SeqT m a -> m ([a], m a)

to get up to n results in a list. Another might get fancier with length-indexed vectors

data Vec n a where
  Nil :: Vec Z a
  Cons :: a -> Vec n a -> Vec (S n) a

splitExact :: SNat n -> SeqT m a -> m (Maybe (Vec n a, m a))

Stuff like that.

@dagit
Copy link
Owner

dagit commented Jul 30, 2021

Actually, this should probably be added to PR #28 LogicT has a observeManyT if I recall correctly. Would that do what you want?

@dagit
Copy link
Owner

dagit commented Jul 30, 2021

I should add, it's not a big deal with our monad to write this yourself, but in LogicT the Identity version can avoid msplit which gives them a big performance boost.

@treeowl
Copy link
Collaborator Author

treeowl commented Jul 30, 2021

Yes, we should have that, but I want splitAt, not just take. Ideally, I think, one version that produces its result in m and one that does so in SeqT m, much as we have both toView and msplit.

@treeowl
Copy link
Collaborator Author

treeowl commented Jul 30, 2021

Sure, it's just a convenience.

@treeowl treeowl added enhancement New feature or request low priority labels Jul 30, 2021
@dagit
Copy link
Owner

dagit commented Jul 30, 2021

Ah, I see. So this is analogous to Data.List.splitAt where you get the tail. Yeah, think that's a good API addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority
Projects
None yet
Development

No branches or pull requests

2 participants