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 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
Peter Aaser
@PeterAaser
(just from a cursory eyeballing)
Andrey
@404-
let me give that a shot
Gavin Bisesi
@Daenyth
what type is zipped?
I wonder if for is incorrect
Andrey
@404-
Stream[IO, (Long, Char)]
do signals have some special logic for termination/completion?
Peter Aaser
@PeterAaser
No
Gavin Bisesi
@Daenyth
I just wasn't sure of the api there
for seems right
I agree that your signals don't terminate
hold javadoc says If the source stream is empty, the resulting signal will always be initial.
Peter Aaser
@PeterAaser
They need to be NoneTerminated
Fabio Labella
@SystemFw
it's not about emptiness
Peter Aaser
@PeterAaser
Signals don't really terminate
Fabio Labella
@SystemFw
Peter is right
a Signal describes changing over time
Peter Aaser
@PeterAaser
Literally gonna frame this on my wall
Fabio Labella
@SystemFw
if you say discrete, it means emit all changes
Gavin Bisesi
@Daenyth
right, it's not about emptiness, but the javadoc there implies that the streaming from the signal will never terminate
that's what I was getting at
Andrey
@404-
i've been playing around with none terminating it, but i'm not sure which streams need to be noneTerminated
Fabio Labella
@SystemFw
when the source stops changing (because it's done), discrete waits for ever, not unlike a queue that isn't getting enqueued to anymore
Andrey
@404-
the original ones (nums and chars) or the outgoing one
Peter Aaser
@PeterAaser
@404- That's tricky
Took me a while to get the correct mental model, and I still get it wrong from time to time
Gavin Bisesi
@Daenyth
I'd say both incoming need noneTerminated and then .discrete.unNoneTerminate
Peter Aaser
@PeterAaser
Yeah, sounds about right
Gavin Bisesi
@Daenyth
I think actually .discrete.map(_.tupled).unNoneTerminate
no?
Andrey
@404-
hmm tupled doesn't quite suit the purpose because Some + None = None
Fabio Labella
@SystemFw
but that's the heart of the issue
when do you want to terminate?
Gavin Bisesi
@Daenyth
@404- that was my intent
either terminate = output terminate
Andrey
@404-
well, the change i made was a <- nums.noneTerminate.hold(None)
which is what's going to make it terminate immediately...
Fabio Labella
@SystemFw
the hold is wrong
it should be hold(0L.some)
Andrey
@404-
right
Fabio Labella
@SystemFw
then it should work
Andrey
@404-
i'd like the resulting stream of pairs to terminate only hen both input streams terminate
yes, that made it work
val nums  = Stream.range[IO](1, 10).metered(25.millis)
val chars = Stream.range[IO]('a', 'z' + 1).map(_.toChar).metered(10.millis)
val zipped = for {
  a <- nums.noneTerminate.hold(1L.some)
  b <- chars.noneTerminate.hold('\0'.some)
  c <- (a, b).tupled.map(_.tupled).discrete.unNoneTerminate
} yield c
the nested Options get tricky
Fabio Labella
@SystemFw
does it do what you want though?
val nums  = Stream.range[IO](1, 10).metered(1.second)
val chars = Stream.range[IO]('a', 'z' + 1).map(_.toChar).metered(500.millis)

val zipped = for {
    a <- nums.noneTerminate.hold(0L.some)
    b <- chars.noneTerminate.hold('0'.some)
    c <- (a, b).mapN(_ product _).discrete.unNoneTerminate
  } yield c
or do you need different semantics around termination?
Andrey
@404-
yep that's it
ah i knew there was a more elegant way! (a, b).mapN(_ product _)
Gavin Bisesi
@Daenyth
very neat :)