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

Implement Seq folds as coerced FingerTree folds #1076

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meooow25
Copy link
Contributor

  • foldr1 and foldl1 are now implemented as coercions.
  • Other folds were implemented using coercions in a complicated manner, which is now simplified. GHC is smart enough to compile these to the same Core, so there is no change in runtime behavior.

* foldr1 and foldl1 are now implemented as coercions.
* Other folds were implemented using coercions in a complicated manner,
  which is now simplified. GHC is smart enough to compile these to the
  same Core, so there is no change in runtime behavior.
foldMap f = foldMap (f .# getElem) .# getSeq
foldr f z = foldr (f .# getElem) z .# getSeq
foldl f z = foldl (f .^# getElem) z .# getSeq
#ifdef __GLASGOW_HASKELL__
Copy link
Contributor

Choose a reason for hiding this comment

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

We need foldMap for other implementations too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? We have foldMap implementations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Am I missing something? It looks like you just hid it behind an ifdef.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you mean Haskell implementations, I misunderstood. Those definitions are in the #else part of this #ifdef.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it seem fine, @treeowl?

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