Convert typeclasses into fun interfaces #77
Conversation
There was a problem hiding this 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 ofarrow.optics.extensions
?
} | ||
|
||
fun <A> ListExtensions.snoc(): Snoc<List<A>, A> = ListSnoc() | ||
fun <A> ListExtensions.snoc(): Snoc<List<A>, A> = listSnoc() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
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. |
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.