Skip to content

Foldable1 instance#27

Merged
garyb merged 1 commit into
purescript:masterfrom
matthewleon:Foldable1
Feb 25, 2018
Merged

Foldable1 instance#27
garyb merged 1 commit into
purescript:masterfrom
matthewleon:Foldable1

Conversation

@matthewleon
Copy link
Copy Markdown
Contributor

convert fold1 and foldMap1 to instance methods

Solves #26

@garyb
Copy link
Copy Markdown
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
Copy Markdown
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?

Comment thread src/Data/NonEmpty.purs Outdated
traverseWithIndex f (a :| fa) =
NonEmpty <$> f Nothing a <*> traverseWithIndex (f <<< Just) fa

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

Choose a reason for hiding this comment

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

SF?

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

@matthewleon
Copy link
Copy Markdown
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
Copy Markdown
Contributor

That sounds good to me.

@matthewleon
Copy link
Copy Markdown
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