fs2
fs2 copied to clipboard
Inserting a map stops propagation of IOLocal
Originally reported by @kamilkloch , I've done some minimisation. Reproduced in fs2 3.4.0, it seemed to work correctly on 3.0.2 (which I happened to have at hand). @Jasper-M points to https://github.com/typelevel/fs2/pull/2572 as the probable change.
def no =
IOLocal(false).flatMap { local =>
Stream
.eval(local.set(true))
.evalMap(_ => local.get)
.map(x => x)
.compile
.toVector
}
.unsafeRunSync() // Vector(false)
def yes =
IOLocal(false).flatMap { local =>
Stream
.eval(local.set(true))
.evalMap(_ => local.get)
.compile
.toVector
}
.unsafeRunSync() // Vector(true)
def yes2 =
IOLocal(false).flatMap { local =>
Stream
.eval(local.set(true) >> local.get)
.compile
.toVector
}
.unsafeRunSync() // Vector(true)
def yes3 =
IOLocal(false).flatMap { local =>
(Stream.exec(local.set(true)) ++ Stream.eval(local.get))
.compile
.toVector
}
.unsafeRunSync() // Vector(true)
def no2 =
IOLocal(false).flatMap { local =>
(Stream.exec(local.set(true)) ++ Stream.eval(local.get))
.map(x => x)
.compile
.toVector
}
.unsafeRunSync() // Vector(false)
Linking to:
- https://github.com/typelevel/fs2/issues/2842