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

Add Semigroupal type class #1280

Merged
merged 37 commits into from Mar 2, 2019
Merged

Conversation

juliankotrba
Copy link
Contributor

@juliankotrba juliankotrba commented Feb 3, 2019

  • Interface definition
  • Laws
  • Instances
    • Option
    • ListK
    • SequenceK
    • SetK
  • Tests
  • Documentation

closes #882 #951

@juliankotrba juliankotrba changed the title Add Semigroupal type class [WIP] Add Semigroupal type class Feb 3, 2019
@pakoito
Copy link
Member

pakoito commented Feb 4, 2019

closes nothing, do we need issues for PR's like this one?

Open one so we can keep track, yeah.

@juliankotrba juliankotrba changed the title [WIP] Add Semigroupal type class Add Semigroupal type class Feb 25, 2019
@pakoito
Copy link
Member

pakoito commented Feb 25, 2019

@juliankotrba ready to review?

@juliankotrba
Copy link
Contributor Author

@juliankotrba ready to review?

Yes, please.

)

private fun <F, A, B, C> Semigroupal<F>.semigroupalAssociative(af: Kind<F, A>, bf: Kind<F, B>, cf: Kind<F, C>, bijection: (Kind<F, Tuple2<Tuple2<A, B>, C>>) -> (Kind<F, Tuple2<A, Tuple2<B, C>>>), EQ: Eq<Kind<F, Tuple2<A, Tuple2<B, C>>>>): Unit =
af.product(bf.product(cf)).shouldBeEq(bijection(af.product(bf).product(cf)), EQ)
Copy link
Member

Choose a reason for hiding this comment

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

We should prefer forAll and eqUnderTheLaw rather than this.

Copy link
Member

@pakoito pakoito left a comment

Choose a reason for hiding this comment

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

The tests need to be more like the ones for Monoid y Semigroup, where a constructor is passed.

@juliankotrba
Copy link
Contributor Author

Thanks for the review @pakoito, I will try to fix everything until next week 😊

@pakoito
Copy link
Member

pakoito commented Mar 1, 2019

Master is broken and it's my fault. I'll fix it tonight

@pakoito
Copy link
Member

pakoito commented Mar 1, 2019

ready to merge when you think it is!

@pakoito
Copy link
Member

pakoito commented Mar 1, 2019

It's silly but there's one detekt error:

UnusedImports - [Law.kt] at /home/travis/build/arrow-kt/arrow/modules/core/arrow-test/src/main/kotlin/arrow/test/laws/Law.kt:13:1

this.should {
io.kotlintest.Result(eqv(b), "Expected: $this but found: $b", "$this and $b should be equal")
}
this.should(object: Matcher<Eq<A>> {
Copy link
Member

Choose a reason for hiding this comment

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

revert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Imho the method now does what it was originally intended for. We could discuss it with the author and then put it in its own PR, make the change here or revert it.

Copy link
Member

Choose a reason for hiding this comment

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

The value in override fun test(value: Eq<A>): Result { is never used, so there's something there that doesn't add up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah right, thats not that clean. Additional changes should then be made in new PR. I will revert for now and keep this thing in mind.

Copy link
Member

Choose a reason for hiding this comment

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

All clear now, merging!

@pakoito pakoito merged commit cb83539 into arrow-kt:master Mar 2, 2019
@pakoito
Copy link
Member

pakoito commented Mar 2, 2019

Thank you @juliankotrba for all the good work, and thanks for being receptive of the code review :D

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.

Add Semigroupal typeclass
3 participants