Runnable_snippets_declared_in_code.kt
# arrow-contributors
r
Runnable_snippets_declared_in_code.kt
s
@raulraja this way the actual result is never in the kdocs, right?
Aren’t we better of writing samples like the following then.
Option.just(1).map { it + 1 } == Some(2)
. Something in test form.
r
If they are runnable the result doesn't show until you play
s
I meant in the Kdocs, not the arrow docs.
r
I see
You mean in the actual source?
s
Ye
r
Ank should print out the resulting value in the rendered doc but if you want the result when people are reading the sources then yeah
s
We could do something like
fun A.shouldEqual(other: A): Unit
that prints the result in runnable snippet but it showcases the result also in the actual code.
Just thinking out loud because a snippet like the following might not tell the user a lot (enough).
Copy code
fun main(args: Array<String>) {
  listOf(1, 2, 3)
    .map { async { getUserById(it) } }
    .sequence(DeferredK.applicative())
}
Compared to
Copy code
fun main(args: Array<String>) {
  listOf(1, 2, 3)
    .map { async { getUserById(it) } }
    .sequence(DeferredK.applicative()) shouldEqual
       async { listOf(User(1), User(2), User(3)) }
}
No need to jump to website and run snippet to clarify.
r
yes, but as a user I still want to go and modify those values
and see how the expression behaves with different values or code
if that comparison also uses
println
for the resulting value to get the best of both worlds then yeah
s
Ye that’s what I’d propose
r
👍 sounds great to me
sorry I read it backwards
yeah we were in agreement many msgs ago 😛
s
😄