Skip to content

Conversation

@7h3kk1d
Copy link
Member

Addressing #127

  • Semigroup::foldRight had parameters flipped
  • Monoid::foldRight was accumulating the accumulator from the left. This has been fixed but the identity is now used as a starting accumulator. Otherwise, the evaluation order is unchanged.
  • Changed ExplainFold parameter name since the accumulator can be in either position

Sidenote
Monoid::foldMap seems to be where short-circuiting is currently implemented. Something that was going to be addressed in the incomplete https://github.com/palatable/lambda/pull/122/files. For obvious reasons, it doesn't seem to address semigroups that should short-circuit. In addition, it has some odd behavior for Monoid::foldRight. For example the function application will now match Semigroup::foldRight, but and().foldRight(true, repeat(false)).value() does not short circuit with the current implementation of Monoid::foldRight. I'm tempted to remove foldLeft/foldRight from Monoid and add a lazilyApply to Semigroup that would allow for users to override for short-circuiting behavior.

- Semigroup::foldRight had parameters flipped - Monoid::foldRight was accumulating the accumulator from the left. This has been fixed but the identity is now being used as a starting accumulator. Otherwise, the evaluation order is unchanged. - Changed ExplainFold parameter name since accumulator can be in either position
@7h3kk1d7h3kk1d requested a review from jnapeApril 23, 2023 14:24
@7h3kk1d7h3kk1d merged commit d360ae8 into palatable:masterMay 1, 2023
Sign up for freeto 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

@7h3kk1d@jnape