Follow

Having some troubles with stuff related to Future[Option[T]] today. I know there is a good solution for what I'm trying to do here...

codeshare.io/adgkdg

Help me Obi-Wan Kenobi

@ckipp Future are not fitting for your request. (In fact, Future are never a good fit for anything). If you want keep your future, you have to instanciate your future in the comprehension. But you can use Task (or IO) instead of Future.

@xvw 😕 I don't have a lot of choice on the Future here as work has it implemented this way. Each of those checks are actually db queries. Which return a Future[Row], and then those Rows are just being mapped to [T] in my example.

@ckipp Sorry for that :/

(Do you know about Cats ? Or ZIO ? If your start a new project in Scala, it could be a nice starter)

@xvw Yea, I'm aware of them, but this is in a codebase where they don't want to introduce those dependencies.

@ckipp Yes, i've understand ;) (it why I said "sorry for that" :P)

@xvw o, also, can you give me a quick explanation of what you mean when you say "Futures are never a good fit for anything". I'm assuming you mean that language agnostic right?

@ckipp Nop, im speaking about Scala's future. I'm not a Scala expert but a real expert says to me that :

- Not monadic (because, Future start at the instantiation point)
- Future does not handle typeclasse for Sequence, it is hardcoded
- Future relay on exception.

@xvw ahhh gotcha. And excuse my ignorance here, but that first point, one of the huge downfalls of that is that it's not composable correct?

@ckipp Yes, exactly. (In fact, Monad does not compose well ... but it is a common idiom in functional programming... so it is sad to not following this eprouved interface :'( )

Sign in to participate in the conversation
Merveilles

Merveilles is a community project aimed at the establishment of new ways of speaking, seeing and organizing information — A culture that seeks augmentation through the arts of engineering and design. A warm welcome to any like-minded people who feel these ideals resonate with them.