If you have an opinion and agree we could propose ...
# arrow
r
If you have an opinion and agree we could propose comprehensions for Kotlin and get rid of bind in in Arrow
👏 4
r
What would the underlying mechanic for the comprehension be? Would the type need to implement some interface containing flatMap?
r
No, it can be instrospected from the members or extensions of a type
Same as for in does today
You don't need to implement Iterable, just prove by shape
This section explains how types are inspected structurally to conform to what Kotlin understand is Iterable which is unrelated to the Java interface Iterable in terms of type equality
r
Ok so the compiler would be smart enough to find the appropriate
F<A> -> F<B>
mapping and apply it? 🤔
r
That is what async await is
It's just syntax sugar over flatmap
If the data type is explicit about providing the flatmap operator then it would work in for in
r
Got it. Seems like a timely pitch with the introduction of
Flow
in coroutines. I’d imagine aligning this proposal with their long-term API objectives for coroutines would be key.
r
It would. I just hope people have an opinion and is not ignored since otherwise we are aiming at having specialized idioms for all effects people care to track in the future. This time was ignoring failure but it's always just flatmap
💯 3
m
would you also propose if guards? I find them super useful
r
I believe to support if guards without exceptions a datatype needs to provide an empty identity value or a filter function. For example we would need to know at the type level List has emptyList or rely on filter
That's fine, this could be a feature that is only active in data types with flatmap that also structurally provide filter.
I invite you to collaborate with me in the draft once we get community feedback and see what that would look like
p
I've found myself writing that
}
ladder more times than I would like to admit, I think this is an awesome solution and would for sure push for it, is there a more relevant place where I can express my support? (I guess this is a zombie thread but I've been on holidays 😅 )
r
I’m currently focusing on finishing the meta support for compiler plugins but I will work on a KEEP after that during september, I’ll post links in the relevant channels and anyone can join