Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 05 2019 14:43
    @typelevel-bot banned @jdegoes
  • Jan 31 2019 21:17
    codecov-io commented #484
  • Jan 31 2019 21:08
    scala-steward opened #484
  • Jan 31 2019 18:19
    andywhite37 commented #189
  • Jan 31 2019 02:41
    kamilongus starred typelevel/cats-effect
  • Jan 30 2019 00:01
    codecov-io commented #483
  • Jan 29 2019 23:51
    deniszjukow opened #483
  • Jan 29 2019 23:37
  • Jan 29 2019 23:22
  • Jan 29 2019 20:26
    Rui-L starred typelevel/cats-effect
  • Jan 29 2019 18:01
    jdegoes commented #480
  • Jan 29 2019 17:04
    thomaav starred typelevel/cats-effect
  • Jan 28 2019 17:43
    asachdeva starred typelevel/cats-effect
  • Jan 28 2019 07:12
    alexandru commented #480
  • Jan 28 2019 05:45
    codecov-io commented #482
  • Jan 28 2019 05:35
    daron666 opened #482
  • Jan 27 2019 13:56
    codecov-io commented #481
  • Jan 27 2019 13:46
    lrodero opened #481
  • Jan 27 2019 05:47
    codecov-io commented #460
  • Jan 27 2019 05:37
    codecov-io commented #460
Fabio Labella
@SystemFw
the one thing I remember off the top of my head is the idea of adding a page for videos
monix and fs2 both have that
they aren't a replacement for docs but they help
Adam Rosien
@arosien
@gvolpe's book has a lot of related stuff https://leanpub.com/pfp-scala
Fabio Labella
@SystemFw
after that, I trust you :)
Adam Rosien
@arosien
the current docs tend to focus on the implementation details of the library itself, which is natural and sometimes necessary. but yes, adding both general principles and practical applications are good steps forward
something something 4 types of documentation
tutorials, how-to guides, technical reference and explanation
Fabio Labella
@SystemFw
yeah the only problem I have with that article is the amount of time required to do all that :)
Gavin Bisesi
@Daenyth
I think a good first step would be making sections that people can edit into
Ashkan Kh. Nazary
@ashkann
I would say a curated list of "material" is a nice way to start. A newcomer has literally books to learn before the can even make sense of the project docs
Arulselvan Madhavan
@ArulselvanMadhavan
Beginner question: How do I create ContextShift[IO] without having to mixin IOApp? I'm working on introducing cats-effect into an Akka codebase and would like to use specific execution contexts to create different ContextShift[IO]. It seems IOContextShift is there but it's part of cats.effect.internals package
Fabio Labella
@SystemFw
IO.contextShift(ec)
Arulselvan Madhavan
@ArulselvanMadhavan
Thanks @SystemFw I wish I had a working emacs setup to get suggestions on methods
Fabio Labella
@SystemFw
tell me about it :P
Mark Tomko
@mtomko
Is there a pattern for doing something like this:
  type Thingy
  def x[F[_]: Concurrent]: Resource[F, MVar[F, Thingy]] =
    for {
      sem <- Resource.liftF(Semaphore[F](1L))
      mvar <- Resource.liftF(MVar.empty[F, Thingy])
      fiber <- // construct a fiber that uses the semaphore and mvar and cancels when the resource is closed
    } yield mvar
I maybe don't need the semaphore, actually. but I do want the mvar to be updated periodically and safely, until the resource is closed.
yeah, the mvar is enough that I don't need semaphore, when I started this I wasn't using an mvar...
The fiber would be doing something like Stream.repeatEval(update(mvar)).metered(5.minutes)
Mark Tomko
@mtomko
oh, maybe it's just Resource.make(???)(_.cancel), duh
Fabio Labella
@SystemFw
@mtomko since you're using fs2 anyway, look into hold and compile.resource instead
Mark Tomko
@mtomko
okay, thanks!
Fabio Labella
@SystemFw
do you use the MVar for reading only in x? (from the user point of view)
Mark Tomko
@mtomko
no, someone else will read it.
Fabio Labella
@SystemFw
yeah that's what I mean
but will they write to it as well? or it's just the update that does that?
Mark Tomko
@mtomko
ah
Nobody else will update it
Fabio Labella
@SystemFw
yeah, pretty typical pattern
do you have an initial "default" value that you can give to Thingy? if you do, then hold will fit your use case perfectly. If you don't, you can use most of the same tools that are under hold (concurrently mostly) and then compile.resource to have a Resource
Mark Tomko
@mtomko
We don't easily have a default initial value, at least not without some side effects.
Fabio Labella
@SystemFw
actually we have holdResource as well to save some characters
Mark Tomko
@mtomko
yeah, I just noticed that.
I also realized that MVar isn't quite right, because we're not waiting for someone to take a value out.
This is really just a way to monitor some external condition and compute a value when that condition changes
Fabio Labella
@SystemFw
mm ok
Mark Tomko
@mtomko
and we want to make the computed value available (within the context of an F[_])
Fabio Labella
@SystemFw
the tools that holdResource is made of should be of help
Mark Tomko
@mtomko
great, I'm coming to the end of my day, but I'll read that code over and try to reframe things.
Thanks!
Fabio Labella
@SystemFw
you just need to figure out what is the right concurrent structure to hold that
Mark Tomko
@mtomko
oh, like Deferred (because there's no initial value) and Ref
Fabio Labella
@SystemFw
yeah, MVar might actually work here, and it's a simple enough case that it should be ok to use
and if it does, you can literally copy the definition of holdResource replacing SignallingRef with MVar
Mark Tomko
@mtomko
well, I think I was wrong about MVar. I must have confused it with Ref. I don't want a 1-element queue, because there's no guarantee that anyone will take - so I don't want to block on put if it's full.
Fabio Labella
@SystemFw
yeah, you could do it with a proper MVar update, which we don't have (because it's tough to use in most other cases which aren't this)
but basically if you wanted to use MVar for this
your update should take and then put, whereas your read side should read
Mark Tomko
@mtomko
yeah, I was debating that, too. Is that better than using Ref?