Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 01 2021 10:11
    @SystemFw banned @Hudsone_gitlab
  • Jan 31 2019 04:19
    404- forked
    404-/fs2
  • Jan 31 2019 03:01
    SethTisue commented #1232
  • Jan 30 2019 17:22
  • Jan 30 2019 13:45
  • Jan 30 2019 10:48
    pchlupacek commented #1406
  • Jan 30 2019 10:47
    pchlupacek commented #1406
  • Jan 30 2019 10:39
    pchlupacek commented #1407
  • Jan 30 2019 09:58
    lJoublanc commented #870
  • Jan 30 2019 09:42
    vladimir-popov commented #1407
  • Jan 30 2019 08:10
    vladimir-popov closed #1407
  • Jan 30 2019 08:10
    vladimir-popov commented #1407
  • Jan 29 2019 19:20
    SystemFw commented #1407
  • Jan 29 2019 19:20
    SystemFw commented #1407
  • Jan 29 2019 18:57
    SystemFw commented #1406
  • Jan 29 2019 17:47
    pchlupacek commented #1406
  • Jan 29 2019 17:42
    pchlupacek commented #1406
  • Jan 29 2019 17:39
    pchlupacek commented #1407
  • Jan 29 2019 17:39
    vladimir-popov edited #1407
  • Jan 29 2019 17:38
    vladimir-popov commented #1406
Gavin Bisesi
@Daenyth
a bit of a mind bend at first but I also am used to python's lazy iterables a fair bit so it's not so alien
Fabio Labella
@SystemFw
and every pull based streaming library, even those with complex implementations like fs2, can roughly be understood like advanced iterators
Peter Aaser
@PeterAaser
totally gonna use that for my next analogy-fest
Fabio Labella
@SystemFw
where you basically need to tell it "give me the next one" to make things happen
Daenyth @Daenyth nods
Fabio Labella
@SystemFw
so let's look at what Pull can do
Pull[F[_], O, R] has 3 params
F[_] effect
O values emitted
R value returned
Gavin Bisesi
@Daenyth
O is related to the stream contents type param?
R is different though - stream doesn't have that
Fabio Labella
@SystemFw
so Pull is a computation that describes emitting 0...n values, while evaluating effects in F, and complete with a value of type R
@Daenyth yes, I'll get to why those are different (and why fs2 splits Stream and Pull, one of its best decisions)
Gavin Bisesi
@Daenyth
Would a Stream be like a pull of R=()?
Fabio Labella
@SystemFw
exactly!
Gavin Bisesi
@Daenyth
:bulb:
Fabio Labella
@SystemFw
so, forgetting about Stream for a second
most people understand F and O in Pull very easily
but R is more confusing
what is that for?
Gavin Bisesi
@Daenyth
I'm also wondering about how it relates to transforming the Stream of IO for example into an IO of the final result
and where R fits into that if pull generalizes stream
Fabio Labella
@SystemFw
no, that's a different concept (although I see why they might look related)
Gavin Bisesi
@Daenyth
:+1:
go on
Peter Aaser
@PeterAaser
btw, from the codebase:
* `Pull` forms a monad in `R` with `pure` and `flatMap`:
Fabio Labella
@SystemFw
so, a Pull can emit some elements and then terminate with a result
Gavin Bisesi
@Daenyth
ok
Fabio Labella
@SystemFw
that result can be used to mean "the rest"
so imagine a function with an accumulator for Lists
you do some stuff, then recur with the rest of the list
and in the end return the final List
and indeed that was the attempt by OP
however is a bit different when streaming
you don't want to build up the whole result
as soon as something needs emission you want to describe the action of emitting it
but you still want the property of "the rest of the stuff", to be able to write recursive functions
Gavin Bisesi
@Daenyth
mhm
Fabio Labella
@SystemFw
does it make sense? if not, what's confusing about it?
Peter Aaser
@PeterAaser
and no sooner
Fabio Labella
@SystemFw
(I'm not done, but it's a good checkpoint)
Justin Heyes-Jones
@justinhj
is the result type R always the 'tail' of the stream that the pull is not interested in?
Gavin Bisesi
@Daenyth
I'm not 100% there
but I think it might be good to keep going - once I get to a concrete example I think things will click a bit
Fabio Labella
@SystemFw
@justinhj in most examples, yes
right
so, let's see how to translate these concepts to code
small simplification, I'm going to ignore Segment for now, and talk about uncons1/output1 and not about uncons/output