def ap2(self): a = 17 b = 13 ja = Just(a) jb = Just(b) ja.product(jb).smap(_ + _).should.contain(a + b) ja.ap2(jb, _ + _).should.contain(a + b)
def product_n(self): m = Just(1).product3(Just(2), Just(3), Just(4)) m.flat_map4(lambda a, b, c, d: Just(b + d)).should.contain(6) e = Just(1).product3(Just(2), Empty(), Just(4)) e.should.be.empty
def flat_map_n(self): m = Just((1, 2, 3, 4)) m.flat_map4(lambda a, b, c, d: Just(b + d)).should.contain(6) m.flat_map5.when.called_with(lambda a: a).should.throw(TypeError)