https://kotlinlang.org logo
#arrow-contributors
Title
# arrow-contributors
a

addamsson

07/14/2019, 4:01 PM
I'm looking at the source code of Arrow and I've noted that there are interfaces like
Functor
which are very well documented but there are things like
Profunctor
which have literally no docs. The functions are also a bit problematic because their kdocs are mostly hard to understand or non-existent. Do you plan on improving this? It would be useful for contributors who didn't come from a Scala background.
For example I have no idea what
Applicative
can be used for and what
unit
means in it without looking at the code.
It would be tremendously useful to include not only docs, but real life examples for the application of these things.
s

simon.vergauwen

07/14/2019, 4:06 PM
Yes, we have this planned and we've worked very hard on a solution to compile and test the snippets in the kdoc and host them our website as runnable snippets in the documentation.
a

addamsson

07/14/2019, 4:07 PM
I think I can help, although I have no formal FP background
s

simon.vergauwen

07/14/2019, 4:07 PM
Our focus currently lies with Kotlin MPP and stabilizing towards Arrow 1.0. We'd love contributions to the documentation and we'd love to help anyone who is interested in doing so.
That'd be awesome!
a

addamsson

07/14/2019, 4:08 PM
I've been using Arrow since its inception but I find some of its APIs unintuitive
I understand that in most of the cases it is straightforward for someone who comes from a Scala background, but for someone who worked with Java / Clojure previously it is very unintuitive
s

simon.vergauwen

07/14/2019, 4:09 PM
All feedback is welcome! There is some low hanging fruit that we're aware off and stream lining the apis is on the roadmap
Any concrete examples?
a

addamsson

07/14/2019, 4:11 PM
For example there is
Eq
It causes a mental pagefault to interpret it
If I read the kdocs I can see that it is there to check equality
good
but now I see
eqv
and
neqv
which is also not too hard to interpret
but this mental overhead adds up and I end up spending a lot of time interpreting code instead of reading it
I think using plain English would be better
something like
foo.isEquivalentTo(bar)
I also don't see the point of not using
equals(other: Any?): Boolean
that would give operator overloading for
==
and
!=
I think that these things are no brainers for those who have the context (the contributors of the project)
but the users of arrow are hindered by it
I think that by providing readable APIs would make Arrow's adoptation skyrocket
complete with real life examples for things like
Applicative
I read 3 different definitions for what an
Applicative
is and I didn't understand why it was useful until I saw the
Validation
class in VAVR
s

simon.vergauwen

07/14/2019, 4:16 PM
The point of
Eq
is that you can compose it in nested shapes and it type checks.
Understanding why defining logic by behavior instead of type makes more sense if you approach it the other way around imo.
Starting from the more powerful use cases like writing abstract validation logic and running it accumulating
Validated
vs short circuit
Either
Or writing abstract concurrenct code and running it with RxJava, Reactor and Flow.
But I'm having a hard time writing this down in an easy to understand way 😅 like a lot in the FP world I think
a

addamsson

07/14/2019, 4:21 PM
I get the behavior vs type argument
and I agree with that
my point was that I think it can be made more approachable
s

simon.vergauwen

07/14/2019, 4:21 PM
The difference between
equals
and
Eq
is essentially inheritance vs composition. So if you ask why not
equals
vs
Eq
you could also ask inheritance vs composition
a

addamsson

07/14/2019, 4:21 PM
with names which don't require much interpretation
s

simon.vergauwen

07/14/2019, 4:21 PM
There is definitely room for improvement!
I'm too used to this naming I don't see it anymore
a

addamsson

07/14/2019, 4:22 PM
I see
that's why I'm trying to be the fresh set of eyes with no domain knowledge whatsoever 😄
s

simon.vergauwen

07/14/2019, 4:22 PM
Yes, It would be great if you could keep track of this in a ticket.
a

addamsson

07/14/2019, 4:23 PM
hmm
good idea
this is not about
Eq
but the whole API
s

simon.vergauwen

07/14/2019, 4:24 PM
Yep, all feedback is great. Especially if we can improve more before 1.0
a

addamsson

07/14/2019, 4:29 PM
Do you agree with the overall sentiment that Arrow is a bit of an oddball for those who are used to how the Kotlin stdlib works and the readability of the API can be improved?
s

simon.vergauwen

07/14/2019, 4:32 PM
Well, I think the Kotlin std is the oddball. I don't expect
setOf(1, 2, 3).map
to return List.
I'm not on my computer atm but there are cases like that.
We're trying to improve the API without changing the signatures if that makes sense
I've done some investigating on Optics and stuff like named lambda params can also drastically improve the API imo. In addition with good kdocs I think we'd improve things a lot.
Also simpler apis with the result of keep-87 will drastically improve things removing the need of enabling syntax with
run
a

addamsson

07/14/2019, 4:38 PM
you have a point
what I meant is that the names could be improved
to be intuitive for those who are not yet familiar with FP
i'm just trying to get on the same page as you
s

simon.vergauwen

07/14/2019, 4:42 PM
Yes, we’re on the same page. I just wanted to clarify to avoid confusion
a

addamsson

07/14/2019, 4:52 PM
got it
you mean that the stdlib is oddball from a correctness perspective: it is weird that `List`s are returned for example
s

simon.vergauwen

07/14/2019, 4:53 PM
Exactly, but besides that we do have the freedom to change things around to make them more user friendly.
a

addamsson

07/14/2019, 4:53 PM
my argument is that Arrow is an oddball from a readability / pragmatic programmer standpoint: I don't really care in most of the cases that a
List
is returned but I want my code to be readable so when the next guy comes around to maintain my code and they don't know Arrow they at least have a chance to understand what i've written by just looking at it
s

simon.vergauwen

07/14/2019, 4:55 PM
Yes absolutely. Do you feel like this is the case with Vavr? From my Java work experience of the passed 4 years I’ve experienced a lot of pushback for things like Vavr in Java but that might’ve been region specific.
And if so do you feel this is because of the laxer APIs? Or is that irrelevant.
a

addamsson

07/14/2019, 5:05 PM
I haven't used it for a long enough time to be able to tell
but I've had this experience with Arrow
If you check the Issues (and even the issue about keep 87) you can see that people are asking for things like using
Composable
instead of
Monoid
I dont' agree with them because you can look up what a
Monoid
is and is is unambiguous
but the names of functions are kinda arbitrary
for example to construct a
Functor
I've seen things like
pure
,
of
,
just
if would be nice to have something readable which is familiar for Java devs as well
I like
of
because it is part of Effective Java and most folks understand it by looking at it
s

simon.vergauwen

07/14/2019, 5:07 PM
Yes, we had
pure
because originally we thought that since Arrow is build for FPers it should be immediately clear to anyone with FP experience.
We've moved away from that train of thought. In this case we choose for
just
because it's well know from RxJava and Reactor.
Having a lot of aliases is something we wanted to avoid since having multiple ways of doing is probably a bigger drawback.
I find naming extremely difficult and especially in Arrow because we'd like to take in account multiple audiences
a

addamsson

07/14/2019, 5:14 PM
I see
I agree with the alias problem
There is one important question though
what is the purpose of Arrow itself?
are you writing it for Scala/Haskell expats
are are you writing it for the general populace?
for the pragmatic everyday programmer?
s

simon.vergauwen

07/14/2019, 6:04 PM
The purpose of Arrow is for everyone to be able to do pure FP in Kotlin. The important part here is that we want to stay pure in all APIs, because that's what we feel brings the most benefit and thus makes the most sense.
We're not writing it for the occasional Scala / Haskell guy. We expect most developers (already) heavily invested in FP in those languages will probably not switch.
Ideally it should be able to suit everyone's needs depending on your needs you'd import more or less modules.
a

addamsson

07/14/2019, 6:15 PM
This is great
but in this case there has to be some reconciliation
to make Arrow approachable for PEP™s (Pragmatic Everyday Programmer)
For example right now if I want a
ListK
(which I figured out I'll need if I want to tamper with the list) with some elements the familiar syntax from the stdlib would be
listKOf(1, 2, 3)
but instead I need to do this:
listOf(1, 2, 3).k()
and if I look at the code I see this:
Copy code
fun <A> List<A>.k(): ListK<A> = ListK(this)
I can see that this creates a
ListK
but I have no idea what the
k
means
looking at the code of
ListK
it says it is a wrapper but I see no explanation of the
K
. Is it because it is a kind? It has a
@higherkind
annotation. But then why the docs says it is just a wrapper? Why not
ListW
then? or
ListWrapper
. And I still can't remove an element form
ListK
because there is no such operation
With VAVR for example it is just
List.of(1, 2, 3).remove(1)
and I get all the operations I need. It is approachable and intuitive
So if we want to add persistent data structures to Arrow there has to be a
remove
operation and a
persistentListOf(1, 2, 3)
function
otherwise users will just stare at the code complition and wonder how it works
s

simon.vergauwen

07/14/2019, 7:11 PM
Good point about
listKOf
vs
listOf().k()
!
We already have a working compiler plugin that adds HKTs*
a

addamsson

07/14/2019, 7:12 PM
I give you a counter example:
Copy code
Try.invoke { require(1 == 2) }.map {
        println("Sorry, I won't be printed :(")
    }
this is pretty intuitive
i've never used Arrrow's
Try
but just using code completion i was able to do this in 5 seconds
2 Views