示例#1
0
 def flat_map_delay_2(self) -> None:
     v = 13
     w = 29
     x = 17
     f = _ + w
     g = _ + x
     t = IO.delay(f, v).flat_map(lambda a: IO.delay(g, a))
     t.attempt.should.contain(v + w + x)
示例#2
0
 def flat_map_delay(self) -> None:
     v = 13
     w = 29
     x = 17
     f = _ + x
     t = IO.delay(f, v).flat_map(L(IO.now)(_ + w))
     t.attempt.should.contain(v + w + x)
示例#3
0
def set_env(name: str, value: Any) -> IO[None]:
    return IO.delay(env.set, name, str(value))
示例#4
0
 def and_then(self) -> None:
     v = 7
     f = lambda: v
     t = IO.now(1).and_then(IO.delay(f))
     t.attempt.should.contain(v)
示例#5
0
 def sequence(self) -> None:
     f = lambda: 3
     t = List(IO.now(1), IO.now(2), IO.delay(f)).sequence(IO)
     t.attempt.should.equal(Right(List(1, 2, 3)))
示例#6
0
 def delay(self) -> None:
     v = 13
     w = 29
     f = _ + v
     t = IO.delay(f, w)
     t.run().should.equal(v + w)