arrow-kt / arrow-core

Λrrow Core is part of Λrrow, a functional companion to Kotlin's Standard Library
http://arrow-kt.io
Other
81 stars 30 forks source link

Provide Nullable alternatives to APIs that require Option #239

Closed LordRaydenMK closed 3 years ago

LordRaydenMK commented 4 years ago

In order to move Option to a separate module first we need to remove all arrow-core-data and arrow-core usages from internal and public APIs and provide equivalent APIs with nullable types.

Replaces internal Option usages with nullable types. Adds Nullable counterparts to Option APIs in typeclasses Remove Option examples from API docs Remove some deprecated methods with Option

Note: I might have missed something, if that is the case I will do another PR.

nomisRev commented 4 years ago

Looks great so far to me 🙌

LordRaydenMK commented 4 years ago

Looks like the meta annotation processor doesn't play well with nullable types:

//Foldable.kt
  /**
   * Get the first element of the foldable, or null
   */
  fun <A> Kind<F, A>.firstOrNull(): A? =
    findNullable { true }
//ListKFoldable.kt (in the build folder)

fun <A> Kind<ForListK, A>.firstOrNull(): A = arrow.core.ListK.foldable().run {
  this@firstOrNull.firstOrNull<A>() as A
}

the return type should be A? instead of A. Should I create a ticket for this? I would fix it but I have no idea where to even begin to look for it :smile:

rachelcarmena commented 4 years ago

Thanks @LordRaydenMK !! Yes, please, create the issue and I'll take a look :+1:

LordRaydenMK commented 4 years ago

Looks like it's already there: https://github.com/arrow-kt/arrow-core/issues/147

rachelcarmena commented 4 years ago

Looks like it's already there: #147

Oh, I see, thanks @LordRaydenMK I thought it could be related with other dependencies that I updated recently. So it would be necessary to upgrade KotlinPoet to make it work.

nomisRev commented 3 years ago

e: /Users/runner/work/arrow-core/arrow-core/arrow-core/src/main/kotlin/arrow/core/extensions/validated/foldable/ValidatedFoldable.kt: (337, 33): 2 type arguments expected for fun <E, A> Kind<Kind<ForValidated, E>, A>.firstOption(): Option

Oops, not sure what I did wrong in the merge 😅 I only fixed a doc with a conflict.

LordRaydenMK commented 3 years ago

e: /Users/runner/work/arrow-core/arrow-core/arrow-core/src/main/kotlin/arrow/core/extensions/validated/foldable/ValidatedFoldable.kt: (337, 33): 2 type arguments expected for fun <E, A> Kind<Kind<ForValidated, E>, A>.firstOption(): Option

Oops, not sure what I did wrong in the merge sweat_smile I only fixed a doc with a conflict.

I am happy to fix once https://github.com/arrow-kt/arrow-core/issues/147 is resolved (as it is blocking merging this).

nomisRev commented 3 years ago

@LordRaydenMK I'm not sure if you followed but we're in the process of removing @extensions which will resolve it as well. Then we can continue and merge this PR. Sorry for the long wait.

Ref: https://github.com/arrow-kt/arrow-core/pull/267

rachelcarmena commented 3 years ago

Hi fellow contributor :wave:

Arrow repositories has been reunified again into arrow so this repository is going to be archived.

Please, if you want to replay this pull request on arrow repository, follow these steps:

# Adapt your branch to be able to be merged in the new arrow repository
cd arrow-core
git-filter-repo --to-subdirectory-filter arrow-libs/core
cd ..

# Create a new branch in arrow repository and merge your content
git clone git@github.com:arrow-kt/arrow.git
cd arrow
git checkout -b <new-branch>
git remote add arrow-core ../arrow-core
git fetch arrow-core
git merge --no-edit --allow-unrelated-histories arrow-core/<your-branch>
# check and create the pull request again on arrow repository

Please, let us know if we can help you!

Thank you so much for your contributions!! :raised_hands: