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

Implementation of seqBifoldable #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rcannon
Copy link

@rcannon rcannon commented Apr 11, 2022

This is based off issue #26 although I did not remove seqMap. I can do this if desired. I also did not specify versions for the added bifunctor package dependency in parallel.cabal. I was not sure what versions should be specified as it seems the newer ones introduce additional dependencies. Please let me know how I should proceed, and I will make the necessary adjustments.

Also note that the first commit has a typo. I meant Bifoldable in all instances, not Bifunctor.

@rcannon
Copy link
Author

rcannon commented Jun 24, 2022

This PR partially fixes #26, but I don't remove seqMap. I can do that if necessary. Also, I don't know why the CI is not running.

Copy link
Collaborator

@konsumlamm konsumlamm left a comment

Choose a reason for hiding this comment

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

This should also add tests, given that the proposed code doesn't work. However, for that, we should first make a cabal test suite (#38), which I'll hopefully get to soon.

I'd be fine with deprecating seqMap and removing it later, with a deprecation period.

-- | Evaluate the elements of a bifoldable data structure according to
-- the given strategy
seqBifoldable :: Bifoldable p => Strategy a -> Strategy b -> Strategy (p a b)
seqBifoldable = bifoldMap
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't work, the Monoid () instance doesn't force anything.

This should work:

Suggested change
seqBifoldable = bifoldMap
seqBifoldable strat1 strat2 = bifoldr (\x acc -> strat1 x `seq` acc) (\y acc -> strat2 y `seq` acc) ()

@@ -44,6 +44,7 @@ library
build-depends:
array >= 0.3 && < 0.6,
base >= 4.3 && < 4.17,
bifunctor ,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should have a bound and only be used for GHC < 8.2 (since Bifoldable is included in base since GHC 8.2 / base-4.10). The most liberal bounds should be fine, since we only use bifoldr (at least in my suggestion).

Suggested change
bifunctor ,
bifunctors >= 0.1 && < 5.7,

bifunctor is a deprecated package that doesn't even export the stuff we're using.

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