Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Fabio Labella
@SystemFw
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[_]"
SemanticBeeng
@SemanticBeeng
Yes, I know. That was a hack to confirm at least the root type. Did not mean it
Fabio Labella
@SystemFw
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
SemanticBeeng
@SemanticBeeng
yes
Fabio Labella
@SystemFw
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
SemanticBeeng
@SemanticBeeng
Oki, thanks. Will mull on this and on the ... crack between Nested and EitherT. Examples somewhere?
Fabio Labella
@SystemFw

Haves:

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

Wants:

  • 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
SemanticBeeng
@SemanticBeeng
Oki, yes, nice. Will do. Instead of papering over the final type. I understand.
Fabio Labella
@SystemFw
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

exactly

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
SemanticBeeng
@SemanticBeeng
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
@SystemFw
I don't
what you can do is delete my code
and try deriving it again from scratch
trying to not use memory
SemanticBeeng
@SemanticBeeng
yes, oki. thanks. will do.
Sergey Torgashov
@satorg
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
@xingyif
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
Thanks
Raas Ahsan
@RaasAhsan
@satorg It seems like that was a bug. If you check upstream, it has been corrected to execute sequentially https://github.com/monix/monix/blob/master/monix-eval/shared/src/main/scala/monix/eval/Task.scala#L3093
won’t be available in 2.x series though probably
Sergey Torgashov
@satorg
@RaasAhsan oh, indeed, it was fixed on Apr 25. Thanks for pointing it out.
Alexandru Nedelcu
@alexandru
@satorg @RaasAhsan If any of you are interested in patching the 2.x series, do a PR for this branch: https://github.com/monix/monix/tree/series/2.x — and I'll publish a patch release afterwards.
sherwinschiu
@sherwinschiu
Hi, I'm trying to setup an app that will consume a Kafka stream and produce to a Kafka stream with some processing in the middle which is currently built using Tasks. What's the recommended way to set this up? I'm currently trying to use monix-kafka's KafkaConsumerObservable and in the process of building out an Observer which I believe means eventually I need convert the ConsumerRecord into my data type and kick off my processing within onNext(). Does that mean I need to run the Task within onNext()? Is consumeWith a better option? And would that mean I need to handle polling?
Raas Ahsan
@RaasAhsan
@alexandru Sure, might as well for fun :)