Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Convert typeclasses into fun interfaces #77

Merged
merged 3 commits into from Jan 7, 2021

Conversation

franciscodr
Copy link
Contributor

This pull request proposes the use of fun interfaces for defining the typeclasses to help make the code more concise and readable by using lambda expressions.

@franciscodr franciscodr requested a review from a team December 29, 2020 23:35
@raulraja raulraja requested a review from a team January 3, 2021 16:54
Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

Looks great @franciscodr, two things I'm wondering about:

  • Are the Instances objects going to be deprecated? If so, then we should also deprecate the extensions on it.

  • Should the new creation functions we defined under arrow.optics instead of arrow.optics.extensions?

}

fun <A> ListExtensions.snoc(): Snoc<List<A>, A> = ListSnoc()
fun <A> ListExtensions.snoc(): Snoc<List<A>, A> = listSnoc()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fun <A> ListExtensions.snoc(): Snoc<List<A>, A> = listSnoc()
@Deprecated("Use listSnoc() instead", @ReplaceWith("listSnoc()", "arrow.optics.extensions.listSnoc")
fun <A> ListExtensions.snoc(): Snoc<List<A>, A> = listSnoc()

Should this be defined under arrow.optics. instead of arrow.optics.extensions like we're doing in Arrow Core?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. I'll do that in a different PR

}

fun <A> ListExtensions.cons(): Cons<List<A>, A> = ListCons()
fun <A> ListExtensions.cons(): Cons<List<A>, A> = listCons()
Copy link
Member

Choose a reason for hiding this comment

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

idem

}

fun <A> ListExtensions.index(): Index<List<A>, Int, A> = ListIndex()
fun <A> ListExtensions.index(): Index<List<A>, Int, A> = listIndex()
Copy link
Member

Choose a reason for hiding this comment

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

idem

}

fun <A> ListExtensions.filterIndex(): FilterIndex<List<A>, Int, A> = ListFilterIndex()
fun <A> ListExtensions.filterIndex(): FilterIndex<List<A>, Int, A> = listFilterIndex()
Copy link
Member

Choose a reason for hiding this comment

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

idem

@@ -45,89 +44,58 @@ interface ListTraversal<A> : Traversal<List<A>, A> {
}
}

fun <A> ListExtensions.each(): Each<List<A>, A> = ListEach()
fun <A> ListExtensions.each(): Each<List<A>, A> = listEach()
Copy link
Member

Choose a reason for hiding this comment

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

idem

@franciscodr
Copy link
Contributor Author

Looks great @franciscodr, two things I'm wondering about:

  • Are the Instances objects going to be deprecated? If so, then we should also deprecate the extensions on it.
  • Should the new creation functions we defined under arrow.optics instead of arrow.optics.extensions?

Thanks for reviewing the PR @nomisRev! My answer is yes to both questions. But my idea is doing those changes in separate PRs for each data type. I'm trying to submit smaller PRs to make easier their reviews.

@franciscodr franciscodr merged commit 4419cc5 into master Jan 7, 2021
@franciscodr franciscodr deleted the paco-move-to-fun-interface branch January 7, 2021 11:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants