Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 24 2020 23:19
    dsilvasc synchronize #66
  • Oct 31 2020 22:35

    fwbrasil on master

    fix an typo in a type parameter Merge pull request #59 from joh… (compare)

  • Oct 31 2020 22:35
    fwbrasil closed #59
  • Oct 26 2020 22:55
    dsilvasc commented #44
  • Oct 26 2020 22:54
    dsilvasc opened #66
  • Oct 19 2020 21:08
    scala-steward closed #60
  • Oct 19 2020 21:08
    scala-steward closed #64
  • Oct 19 2020 21:08
    scala-steward opened #65
  • Oct 05 2020 01:58
    scala-steward opened #64
  • Sep 09 2020 11:04
    scala-steward opened #63
  • Jul 27 2020 16:07
    scala-steward opened #62
  • Jul 25 2020 15:39
    fwbrasil closed #61
  • Jul 25 2020 15:39
    fwbrasil commented #61
  • Jun 29 2020 05:21
    retronym edited #61
  • Jun 29 2020 05:13
    retronym opened #61
  • Jun 28 2020 00:02
    scala-steward opened #60
  • Jun 26 2020 19:46
    johnynek opened #59
  • Jun 26 2020 17:47
    fwbrasil closed #32
  • Jun 26 2020 17:47
    fwbrasil closed #31
  • Jun 26 2020 17:47
    fwbrasil closed #30
Flavio W. Brasil
@fwbrasil
test
aappddeevv
@aappddeevv
Is there monadless for fs2 that covers Task?
Flavio W. Brasil
@fwbrasil
@aappddeevv there isn’t a built-in one yet, but it should be simple to create
aappddeevv
@aappddeevv
Alright...I also opened an Issue.
Flavio W. Brasil
@fwbrasil
:+1:
aappddeevv
@aappddeevv
I'm looking at both the cats and the Stdlib Future to pattern off of, but it looks like with Future, you need the ability to add a callback after its run, but for cats Applicative, it implement a set of very different methods in its Monadless[M]. Why the difference?
Fs2 is already a monad.
Fs2 task that is.
aappddeevv
@aappddeevv
It looks like the "callback" aspect is key to the API here.
Flavio W. Brasil
@fwbrasil
the future one implements more methods because it supports try/catch/finally
aappddeevv
@aappddeevv
I have a collect, rescue, map, flatMap and apply.
I'm not sure that ensure will work. Can I use the default ensure in Monadles[M]?
Flavio W. Brasil
@fwbrasil
I see. ensure is used to translate a finally clause. It should execute the function regardless of the result (failure/success) and not change the result
maybe it doesn’t make sense for fs2? it’s basically for side effects
aappddeevv
@aappddeevv
I'm not an expert on fs2 Task, but you cannot register completion callbacks like Future. You run it, and you either deal with an exception or get an Either and you have to deal with it then.
Does not having ensure mean that monadless will not work?
Flavio W. Brasil
@fwbrasil
no
it means that finally won’t work
aappddeevv
@aappddeevv
K.
aappddeevv
@aappddeevv
It seems to work. I do not need finally at the moment so the lack of an ensure is not a problem.
Flavio W. Brasil
@fwbrasil
@aappddeevv are you planning to prepare a PR?
aappddeevv
@aappddeevv
not yet, since I'm not sure its well test. Here's the code:
port io.monadless._
import fs2._
import scala.concurrent._
import scala.concurrent.ExecutionContext
import language.higherKinds

trait MonadlessTask extends Monadless[Task] {
  def collect[T](list: List[Task[T]]): Task[List[T]] =
    Task.traverse(list)(identity).map(_.toList) //Future.sequence(list)
  def rescue[T](m: Task[T])(pf: PartialFunction[Throwable, Task[T]]): Task[T] =
    m.handleWith(pf) //m.recoverWith(pf)

  /*
  def ensure[T](m: Task[T])(f: => Unit): Task[T] = {
    m.onComplete(_ => f)
    m
  }
   */
}
object MonadlessTask extends MonadlessTask
aappddeevv
@aappddeevv
this appears to be working pretty good at least on scalajs platform.
Flavio W. Brasil
@fwbrasil
cool, I’d love to see a PR for it ;)
aappddeevv
@aappddeevv
they are separating out fs2 Task to cats.effects.IO...I'll put together the IO version and get a PR in.
Flavio W. Brasil
@fwbrasil
@aappddeevv great!
Felix Dietze
@fdietze
Hi, great project! While experimenting I found, that side-effecting functions inside a lift-block are not executed. Is this by design?
Flavio W. Brasil
@fwbrasil
@fdietze could you provide an example?
Felix Dietze
@fdietze
var x = 0; lift { x = 1; unlift(a) }
While writing this, I realize that this is probably a problem on my side... ;)
I have to investigate further
Flavio W. Brasil
@fwbrasil
:+1:
Felix Dietze
@fdietze

Ok, these two do not behave in the same way:

val b = Rx.MonadlessRx.map(a){a => changes += "b"; a + 1}
val b = lift {changes += "b"; unlift(a) + 1}

How exactly is the lift-version transformed?

aappddeevv
@aappddeevv
I just posted a typecheck error when using scala-js. Can someone take a look? monadless/monadless#5
Flavio W. Brasil
@fwbrasil
@aappddeevv I’ll take a look