How to use the pfun.writer.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_writer.py View on Github external
def test_filter_m(self):
        assert writer.filter_m(lambda v: writer.value(v % 2 == 0),
                               range(3)) == writer.value((0, 2))
github suned / pfun / tests / test_writer.py View on Github external
def test_map_m(self):
        assert writer.map_m(writer.value, range(3)) == writer.value((0, 1, 2))
github suned / pfun / tests / test_writer.py View on Github external
def test_composition_law(self, f, g, value):
        h = compose(f, g)
        assert writer.value(value).map(h) == writer.value(value).map(g).map(f)
github suned / pfun / tests / test_writer.py View on Github external
def test_inequality(self, first, second, monoid):
        assume(first != second)
        assert writer.value(first, monoid) != writer.value(second, monoid)
github suned / pfun / tests / test_writer.py View on Github external
def test_right_identity_law(self, value, monoid):
        assert (
            writer.value(value,
                         monoid).and_then(writer.value
                                          ) == writer.value(value, monoid)
        )
github suned / pfun / tests / test_writer.py View on Github external
def test_identity_law(self, value):
        assert writer.value(value).map(identity) == writer.value(value)
github suned / pfun / tests / test_writer.py View on Github external
def test_sequence(self):
        assert writer.sequence([writer.value(v)
                                for v in range(3)]) == writer.value((0, 1, 2))
github suned / pfun / tests / test_writer.py View on Github external
def test_stack_safety():
            for _ in range(500):
                yield writer.value(1)
            return None