https://kotlinlang.org logo
#functional
Title
# functional
g

gregd

02/26/2018, 7:23 PM
Hi 🙂 Another FP newbie here 😉 And one thing bothers me: what type/container should I use to represent a single value that’s neither optional nor can fail in any way, but I still want to
map
over it? I know I could use Kotlin’s
let
, but maybe there’s a proper FP way of doing this?
a

Alisson Morais

02/26/2018, 7:38 PM
Edited: Ohhh, I misunderstood your question and Raul already answered you Original: I'm far from being an expert, but if you use Arrow lib, you can try something like
Copy code
val potentialNumber: Try<Option<Int>> = Try { Some(1) }
potentialNumber.map { maybeNumber ->
maybeNumber.map { "My number is $it" }
}
For more details, follow: https://arrow-kt.io Hope that helps 🙂
5 Views