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

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 :)
Raas Ahsan
@RaasAhsan
actually, won’t be necessary i think, seems like the incorrect definition of map2 was introduced after 2.x
Piotr Gawryś
@Avasil
@sherwinschiu maybe I'm missing some details but it sounds like you could just mapTask on KafkaConsumerObservable to do your processing and consumeWith KafkaProducerSink at the end
sherwinschiu
@sherwinschiu
Thanks @Avasil - what takes care of the polling?
SemanticBeeng
@SemanticBeeng
@yanana did you get anywhere with this https://gitter.im/monix/monix?at=58eb038008c00c092a65d6b7 , please ? Tasks that are not yet attached to execution contexts should be serializable out of the box, no?
Alexandru Nedelcu
@alexandru
@SemanticBeeng Task implements Serializable, but it depends on what you captured with it, as Task is basically a function.
Guess you should try it and see if it breaks or not 🙂 serialization in Java is unfortunately a dark art of sorts. I avoid it as much as possible, but guessing with Spark it is inevitable.
SemanticBeeng
@SemanticBeeng
Yes, spark does what it does. But it is quite useful to combine with monix, intuition suggests, because we can mix more complex functional business logic and go beyond the spark way of thinking.
Piotr Gawryś
@Avasil
@sherwinschiu polling is done internally
James Phillips
@jdrphillips
Is there a way to create an Observable that waits for input? I imagine if you're streaming an Observable from a file and there's a delay on disk IO, it will patiently wait before getting the next bits and processing them. Is there a way to get the same behaviour waiting for input from my program?
So anything subscribed to the observable will do nothing until an element is fed to it
Oleg Pyzhcov
@oleg-py
That's the default behavior. You might want to look into ConcurrentSubject to feed elements in imperative fashion
James Phillips
@jdrphillips
Thank you. I've been reading the Observable API and it didn't seem to do what I wanted there. I'll read about concurrent subjects
Ryan Zeigler
@rzeigler
is there any difference between gather and parSequence or is one just the cats.Parallel name for the operatino?
Piotr Gawryś
@Avasil
@rzeigler gather is optimized version just for Task and not every Traverse
I'd recommend using Task versions whenever possible, there are also for traverse, parTraverse and normal sequence + unordered variants
Ryan Zeigler
@rzeigler
is there a Task.parTraverse or is that just map(f).gather?