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

Add more Fold1 instances #215

Merged
merged 5 commits into from
Dec 20, 2024
Merged

Conversation

Topsii
Copy link
Collaborator

@Topsii Topsii commented Nov 6, 2024

I omitted Costrong and ArrowLoop instances for Fold1. Fold already has a Costrong instance, but similar to the Monad instances mentioned in #214 (comment) I wonder whether it is safer to omit them to ensure Fold1s are streaming constant memory.

instance Costrong Fold1 where
    unfirst p = fmap f nonEmpty
      where
        f as = b
          where
            (b, d) = Control.Foldl.NonEmpty.fold1 p $ do
              a <- as
              pure (a, d)

instance ArrowLoop Fold1 where
    loop = unfirst

I also added nest for Fold1 and distinguished between both and both1 in the doctests.

@Gabriella439 Gabriella439 merged commit ccc7f42 into Gabriella439:main Dec 20, 2024
5 checks passed
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.

2 participants