Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_inequality(self, first, second):
assume(first != second)
assert Done(first) != Done(second)
def test_sequence(self):
assert sequence([Done(v) for v in range(3)]) == Done((0, 1, 2))
assert filter_m(lambda v: Done(v % 2 == 0), range(3)) == Done((0, 2))
def test_composition_law(self, f, g, value):
h = compose(f, g)
assert Done(value).map(g).map(f) == Done(value).map(h)
def test_map_m(self):
assert map_m(Done, range(3)) == Done((0, 1, 2))
return self.and_then(lambda v: Done(f(v)))
return More(Get(k, lambda v: Done(v)))
def delete(k: str) -> KVStoreFree[None]:
return More(Delete(k, Done(None)))
def put(k: str, v: str) -> KVStoreFree[None]:
return More(Put(k, v, Done(None)))
:example:
>>> from typing import Any
>>> @with_effect
... def f() -> Frees[int, int, Any, Any]:
... a = yield Done(2)
... b = yield Done(2)
... return a + b
>>> f()
Done(4)
:param f: generator function to decorate
:return: `f` decorated such that generated :class:`Free` \
will be chained together with `and_then`
"""
return with_effect_(Done, f) # type: ignore