How to use the pfun.effect.success function in pfun

To help you get started, we’ve selected a few pfun examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github suned / pfun / tests / test_effect.py View on Github external
        e = e.recover(lambda _: effect.success(''))
        with recursion_limit(100):
github suned / pfun / tests / test_effect.py View on Github external
def test_composition_law(self, f, g, value, env):
        h = compose(f, g)
        assert (
            effect.success(value).map(h).run(env) ==
            effect.success(value).map(g).map(f).run(env)
        )
github suned / pfun / tests / test_effect.py View on Github external
def test_sequence(self):
        assert effect.sequence_async([effect.success(v) for v in range(3)]
                                     ).run(None) == (0, 1, 2)
github suned / pfun / tests / test_effect.py View on Github external
def test_identity_law(self, value, env):
        assert (
            effect.success(value).map(identity).run(env) ==
            effect.success(value).run(env)
        )
github suned / pfun / tests / test_effect.py View on Github external
def test_equality(self, value, env):
        assert effect.success(value).run(env) == effect.success(value).run(env)
github suned / pfun / tests / test_effect.py View on Github external
def test_left_identity_law(self, f, value, env):
        assert (
            effect.success(value).and_then(f).run(env) == f(value).run(env)
        )
github suned / pfun / tests / strategies.py View on Github external
def effects(value_strategy=anything()):
    return builds(effect.success, value_strategy)
github suned / pfun / tests / test_effect.py View on Github external
def test_inequality(self, first, second, env):
        assume(first != second)
        assert effect.success(first).run(env) != effect.success(second
                                                                ).run(env)
github suned / pfun / tests / test_effect.py View on Github external
        assert effect.filter_m(lambda v: effect.success(v % 2 == 0),
                               range(5)).run(None) == (0, 2, 4)
github suned / pfun / pfun / sql.py View on Github external
async def _fetch(connection: asyncpg.Connection
                         ) -> Try[asyncpg.PostgresError, Results]:
            try:
                result = await connection.fetch(query, *args, timeout=timeout)
                result = List(Dict(record) for record in result)
                return success(result)
            except asyncpg.PostgresError as e:
                return error(e)