Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
Same result but somehow obtain the desired Task from the pieces my code creates. Those Task.Map or Task.Suspend
Fabio Labella

Those Task.Map or Task.Suspend

No, those are bugs

those classes are internals of Task
Ah. Was right to ask.
Fabio Labella
it's like saying that you want to work with types of Some and None
you want to work with Option
same thing
(there are select cases in which you want to work with Some and None as types, but that's off topic)
another thing
if you have Task[_] as a return type
98% of the time you're papering over some error somewhere else
now, things that help
first of all, "find the F[_]"
Yes, I know. That was a hack to confirm at least the root type. Did not mean it
Fabio Labella
in your code F[_] = Task[Either[DataLakeRepositoryError, ?]]
this already helps you, because for example in another examples your Either could have different error types, so you know that you need some transformations to get to the same F
Fabio Labella
once you know what your F is, you can decompose the problem:
  • how do I get from my type to a single F? (EitherT.apply)
  • how do I solve the problem in terms of F?
  • how do I get to my type from F? (_.value)
the ability to decompose problems is a selling point for FP. My experience training people tells me that it's uncommon to think that way, since with imperative programming decomposition is often not possible
now, for the second bullet point
you need to write down what you have, and what you want
when you start out, actually write those down
Oki, thanks. Will mull on this and on the ... crack between Nested and EitherT. Examples somewhere?
Fabio Labella


  • F[List[Client]]]
  • Client => String (id)
  • String => F[List[(DataSpecification, DataSetRef)]]]


  • F[List[DataSetRef]]
from there, I suggest to work backwards
i.e start from the result, and see what you need to get there
e.g the last step is from F[List[(DataSpec, DataSetRef]] to F[List[DataSetRef]]
that's map(_.map(_._2))
now, how do you get to F[List[(DataSpec, DataSetRef]]
and so on
Oki, yes, nice. Will do. Instead of papering over the final type. I understand.
Fabio Labella
until you get to a solution, after which you can apply some transformations
for example, you might get to map(...).sequence.flatMap(_.flatten)
map(...).sequence is traverse
traverse(...).flatMap(_.flatten) is flatTraverse
and there you go
it takes some time to learn but after a while you'll do it all in your head instantaneously :)

Instead of papering over the final type


what I've noticed is that people stare at the solution, concentrating as much as they can, waiting for illumination
because when you can't decompose the problem, that's all you can do
but in pure FP, often, you can decompose the problem
so one of the most things to learn (and teach) is how to do that
Oki, Many thanks. The only way that would top this is code pointers to see more at this level. If you have some handy. I learn best from complex.
Fabio Labella
I don't
what you can do is delete my code
and try deriving it again from scratch
trying to not use memory
yes, oki. thanks. will do.
Sergey Torgashov
Hi there. Could someone explain me, please, what is the difference between Task.map2 and Task.parMap2. The documentation states that the former is sequential, although the latter is parallel. But it seems, that the implementation of these two are the same except a subtle difference: Task.parMap2 just calls Task.mapBoth directly, although Task.map2 calls non-static (but final anyway) Task.zipMap first, which, in turn, calls that Task.mapBoth. So, in my understanding, they both should behave in the same way. What does make one of them sequential and the other one parallel?
Yifan Xing
Hi @/all, I am creating a GH repo that explains how to organize a scalabridge workshop (so that many people can do so in different parts of the world). Scalabridge is a workshop that teaches underrepresented students the basics of programming in Scala using Creative Scala tutorial. It is a great way to grow the community. I am organizing a list of mentors (based on location) who are interested in helping out, so that a new organizer has mentors to reach out to when organizing a workshop. If you're interested in helping out as a scalabridge mentor, please create a PR and put your info in this file: https://github.com/xingyif/scalabridge/blob/master/organize-a-workshop/invite-mentors.md#interested--mentors