so that I can pass the cleaned up values to a function. I have a solution but it looks ugly, is there a more idiomatic way? Also welcome comments about approach. Underlying motivation is to start with unvalidated inputs and then only forward the parsed and validated values down to the domain layer which does not have side effects. I will log/handle errors in the next iteration.
Copy code
.fold(listOf<C>(), {acc, e -> (e.fold({null}, {it})).let {if (it!=null) acc + it else acc}})
j
Jannis
03/03/2020, 8:21 PM
filterMap { it.toOption() }
should also work^^
j
Jakub Pi
03/03/2020, 8:32 PM
That's great, how might I have figured this out using the Arrow documentation? Is there a recipe book? Doesn't lend itself to discoverability.
j
Jannis
03/03/2020, 8:42 PM
bit hard to find because it is part of
FunctorFilter
. We plan on creating a ide plugin and search engine similar to haskell hoogle so that you can search for type signatures. But even that won't find a signature like that. Searching for something like
filter
on the docs might have found it though. I know most things by heart so I don't usually try those things ^^
b
Bob Glamm
03/03/2020, 9:39 PM
The data classes (e.g. List, Either, etc.) have multiple associated typeclass instances which is what makes searching for operations tricky. Typeclass inheritance diagrams help (which are still in-progress on arrow-kt.io) but as far as I'm aware no canonical operator list exists for any of the Typed FP languages