Skip to content

Foldable1 instance #27

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

Merged
merged 1 commit into from
Feb 25, 2018
Merged

Foldable1 instance #27

merged 1 commit into from
Feb 25, 2018

Conversation

matthewleon
Copy link
Contributor

convert fold1 and foldMap1 to instance methods

Solves #26

@garyb
Copy link
Member

garyb commented Jan 27, 2018

I think this is a breaking change unfortunately, so will have to wait a little bit (as it imposes Foldable1 on f rather than Foldable).

@matthewleon
Copy link
Contributor Author

I've amended the PR to be non-breaking, by simply reusing the previous implementations. It's nicer to have the looser constraint anyway, no?

@@ -117,3 +109,7 @@ instance traversableWithIndexNonEmpty
=> TraversableWithIndex (Maybe i) (NonEmpty f) where
traverseWithIndex f (a :| fa) =
NonEmpty <$> f Nothing a <*> traverseWithIndex (f <<< Just) fa

instance foldable1NonEmpty :: Foldable f => SF.Foldable1 (NonEmpty f) where
Copy link
Member

Choose a reason for hiding this comment

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

SF?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

San Francisco?

I was thinking _S_emigroup._F_oldable. But yeah, it's crappy. I changed it to F1.

@hdgarrood
Copy link
Contributor

Looks good, but this is still potentially breaking if you were relying on the monomorphic signatures for type inference.

@matthewleon
Copy link
Contributor Author

Looks good, but this is still potentially breaking if you were relying on the monomorphic signatures for type inference.

Good point. Perhaps the right solution is to export monomorphic versions of the instance functions?

@hdgarrood
Copy link
Contributor

That sounds good to me.

@matthewleon
Copy link
Contributor Author

Done. This is now non-breaking. Ready for review.

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.

4 participants