Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 20 01:04
    scala-steward closed #125
  • May 20 01:04
    scala-steward commented #125
  • May 20 01:04
    scala-steward opened #142
  • Feb 18 23:13
    scala-steward closed #139
  • Feb 18 23:13
    scala-steward commented #139
  • Feb 18 23:13
    scala-steward opened #141
  • Feb 17 21:06
    scala-steward opened #140
  • Feb 09 21:12
    scala-steward closed #122
  • Feb 09 21:12
    scala-steward commented #122
  • Feb 09 21:12
    scala-steward opened #139
  • Feb 01 05:16
    scala-steward closed #135
  • Feb 01 05:16
    scala-steward commented #135
  • Feb 01 05:16
    scala-steward opened #138
  • Jan 13 05:17
    scala-steward closed #128
  • Jan 13 05:17
    scala-steward commented #128
  • Jan 13 05:17
    scala-steward opened #137
  • Jan 11 17:15
    scala-steward closed #129
  • Jan 11 17:15
    scala-steward commented #129
  • Jan 11 17:15
    scala-steward opened #136
  • Dec 29 2021 11:19
    scala-steward closed #134
Gabriel Volpe
@gvolpe
Hi @etorreborre I saw there's an fs2 package with some functions to integrate with origami's Fold. I came up with an alternative way to write scanEval, would you take a PR? I haven't bechmarked it but rather focused on a pure functional implementation on top of Ref which is quite optimized
def scanEval[F[_]: Sync, S, A](p: Stream[F, A])(start: F[S])(f: (S, A) => F[S]): Stream[F, S] = {

  def zipper(ref: Ref[F, S]): Stream[F, S] =
    p.zip(Stream.eval(ref.get).repeat).evalMap { case (a, s) =>
      for {
        ns <- f(s, a)
        _  <- ref.set(ns)
      } yield ns
    }

  for {
    st  <- Stream.eval(start)
    ref <- Stream.eval(Ref.of[F, S](st))
    rs  <- zipper(ref)
  } yield rs
}
Eric Torreborre
@etorreborre
yes go for it
Gabriel Volpe
@gvolpe
Great, thank you! Folds are awesome :heart:
Eric Torreborre
@etorreborre
yep I love them too :-)
Gabriel Volpe
@gvolpe
Here -> #8 , will read any comments tomorrow :smile:
Sanjeev Singh
@Sanji515
Hello I'm new here. How to start
Please guide me.
Eric Torreborre
@etorreborre
@Sanji515 my first question is “what’s your use case?”. You generally use origami when you have a “stream” of data (with fs2 stream for example) and if you want to “collect/aggregate/sink” this data. This can be done by creating “folds” which have the nice property of being composable so that 2 “folds” can be stitched together to form a larger “fold” operating on your stream. So if you have a small example of a stream you want to process we could start from there