How to use the pfun.reader.value 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_reader.py View on Github external
def test_inequality(self, first, second, context):
        assume(first != second)
        assert reader.value(first)(context) != reader.value(second)(context)
github suned / pfun / tests / test_reader.py View on Github external
def f():
            a = yield reader.value(2)
            b = yield reader.value(2)
            return a + b
github suned / pfun / tests / test_reader.py View on Github external
def test_identity_law(self, value, context):
        assert (
            reader.value(value).map(identity)(context) == reader.value(value)
            (context)
        )
github suned / pfun / tests / test_reader.py View on Github external
def test_right_identity_law(self, value, context):
        assert (
            reader.value(value).and_then(
                reader.value
            ).run(context) == reader.value(value).run(context)
        )
github suned / pfun / tests / test_reader.py View on Github external
        assert reader.filter_m(lambda v: reader.value(v % 2 == 0),
                               range(3)).run(None) == (0, 2)
github suned / pfun / tests / test_reader.py View on Github external
def test_composition_law(self, f, g, value, context):
        h = compose(f, g)
        assert (
            reader.value(value).map(h)(context) ==
            reader.value(value).map(g).map(f)(context)
        )
github suned / pfun / tests / test_reader.py View on Github external
def test_equality(self, value, context):
        assert reader.value(value).run(context) == reader.value(value
                                                                ).run(context)
github suned / pfun / examples / transaction_reader.py View on Github external
def get_user(user_id: int) -> DBAction[User]:
    return value(User(user_id, 'pa$$word'))
github suned / pfun / examples / transaction_reader.py View on Github external
def update_password(user: User, t: Transaction) -> DBAction[bool]:
        user = user.clone(password=new_password)
        t.add(user)
        return value(True)