reik.schatz
03/05/2019, 2:37 PMfun foo(): Try<Unit> {
return Try {
1 // doesn't compile
}
}
Bob Glamm
03/05/2019, 2:46 PMTry { 1 }.map { Unit }
?Bob Glamm
03/05/2019, 2:47 PM.fold(failure, success)
would be more useful in generalreik.schatz
03/05/2019, 2:52 PMreik.schatz
03/05/2019, 2:53 PMFuture.value("foo").unit
reik.schatz
03/05/2019, 2:53 PMreik.schatz
03/05/2019, 2:53 PMTry
in arrow but map
will do\reik.schatz
03/05/2019, 2:53 PMBob Glamm
03/05/2019, 3:00 PMTry { 1 }.unit()
worksBob Glamm
03/05/2019, 3:01 PMBob Glamm
03/05/2019, 3:02 PMraulraja
03/05/2019, 3:36 PMimport arrow.core.*
import arrow.core.extensions.`try`.functor.*
Try { "Hello World" }.unit()
//Success(value=kotlin.Unit)
raulraja
03/05/2019, 3:36 PMraulraja
03/05/2019, 3:37 PMunit
is right biased. If you want to return Unit inside Try
when your Try
is a failure you can use handleError { Unit }
reik.schatz
03/06/2019, 9:55 AMreik.schatz
03/06/2019, 9:56 AMreik.schatz
03/06/2019, 1:30 PMio.arrow-kt:arrow-typeclasses
reik.schatz
03/06/2019, 1:30 PMraulraja
03/06/2019, 2:29 PMFunctor
is in arrow-typeclasses
but the Functor extensions for a given data type are in the extensions module. In this case arrow-core-extensions
which you may have to include in your build file.reik.schatz
03/06/2019, 6:41 PM