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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Semigroup, Semiring and Monoid docs #2323

Merged
merged 9 commits into from Mar 27, 2021
Merged

Conversation

aballano
Copy link
Member

Make Semigroup's maybeCombine to use nullables instead of Option

From #2313 to the right branch 馃槄 cc @rachelcarmena

Make Semigroup's maybeCombine to use nullables instead of Option
@aballano
Copy link
Member Author

Not sure exactly what's the problem:

error: unresolved reference: list
import arrow.core.list
                  ^
error: unresolved reference: list
Semigroup.list<Int>().run {

It works for numbers tho, and list is available in master, any thoughts?

@aballano aballano requested a review from a team March 15, 2021 10:56
@@ -11,7 +9,8 @@ interface Semigroup<A> {
operator fun A.plus(b: A): A =
this.combine(b)

fun A.maybeCombine(b: A?): A = Option.fromNullable(b).fold({ this }, { combine(it) })
fun A.maybeCombine(b: A?): A =
b?.let { combine(it) } ?: this
Copy link
Member

Choose a reason for hiding this comment

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

馃憣

arrow-site/docs/docs/arrow/typeclasses/monoid/README.md Outdated Show resolved Hide resolved
@rachelcarmena
Copy link
Member

Not sure exactly what's the problem:

error: unresolved reference: list
import arrow.core.list
                  ^
error: unresolved reference: list
Semigroup.list<Int>().run {

It works for numbers tho, and list is available in master, any thoughts?

@aballano , some clues 馃檶

Look at the content of the arrow-core-data.jar file:

arrow/core/ListMonoid.class
...
arrow/core/IntSemigroup.class
arrow/core/IntMonoid.class
...
arrow/core/OptionSemigroup.class
arrow/core/OptionMonoid.class

There isn't arrow/core/ListSemigroup.class (just arrow/core/NonEmptyListSemigroup.class).

Maybe the reason is the implementation of list for Semigroup:

fun <A> Semigroup.Companion.list(): Semigroup<List<A>> =
  Monoid.list()

fun <A> Monoid.Companion.list(): Monoid<List<A>> =
  ListMonoid as Monoid<List<A>>

It calls list for Monoid.

However, the implementation for Int and Option is different:

@danimontoya
Copy link
Contributor

danimontoya commented Mar 25, 2021

It was only missing removing some of the imports that are not needed anymore.. because some extensions are now part of the companion object itself.. this should fix it:
#2339

Copy link
Contributor

@danimontoya danimontoya left a comment

Choose a reason for hiding this comment

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

馃檶

* Move list extensions into companion object

* Remove some imports not needed anymore

* Minor change

* Remove some more imports
@rachelcarmena
Copy link
Member

馃憦

@aballano aballano merged commit cc7e0b0 into master Mar 27, 2021
@aballano aballano deleted the ab/update-typeclasses-docs branch March 27, 2021 11:01
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.

None yet

5 participants