Mickey Donaghy
10/01/2020, 1:39 AMOption
is deprecated in 0.11. What's the migration path for functions that I was calling on Option
(specifically traverse
and foldMapM
) - is there an import that will make them available on nullable types or anything like that?simon.vergauwen
10/01/2020, 8:01 AMOption#traverse
we can project new syntax in Functor
.
fun <F, A : Any, B> Kind<F, A?>.mapNullable(FA: Functor<F>, f: (A) -> B): Kind<F, B?> =
FA.run {
map { it?.let(f) }
}
and foldMapM
could be replaced by syntax on Monad
but I'm not sure what we could name it best there 😅 It'd be like flatMapNullable
but it takes a Monoid
instead of returning ?
like the mapNullable
version of traverse
.
fun <F, A : Any, B, MA, MO> Kind<F, A?>.foldMapM(ma: MA, mo: MO, f: (A) -> Kind<F, B>): Kind<F, B>
where MA : Monad<F>, MO : Monoid<B> = ma.run {
mo.run {
flatMap { a ->
a?.let(f)?.map { b ->
b.combine(mo.empty())
} ?: just(mo.empty())
}
}
}
simon.vergauwen
10/01/2020, 8:01 AMMickey Donaghy
10/01/2020, 8:08 AMMickey Donaghy
10/01/2020, 8:10 AMsimon.vergauwen
10/01/2020, 9:26 AMOption
is being moved to a separate module btw, so you can still keep using it if you want to for uniformity! We're moving it our of Arrow-Core since we felt it didn't feel like a "core" data type given ?
in the language.
Reference: https://github.com/arrow-kt/arrow-core/pull/239Mickey Donaghy
10/01/2020, 9:28 AMIO
in that case?)simon.vergauwen
10/01/2020, 9:35 AMIO
, mostly since the maintenance and/or further of IO
cannot be justified there where as it can for Option
.