def test_writer_monad_law_associativity(self):
        # (m >>= f) >>= g is just like doing m >>= (\x -> f x >>= g)
        add1000 = "Added 1000 to %s"
        mul100 = "Multiplied %s by 100"
        a = Writer.unit(42).bind(
            lambda x: Writer(x+1000, add1000 % x)).bind(
            lambda y: Writer(y*100, mul100 % y))
        b = Writer.unit(42).bind(
            lambda x: Writer(x+1000, add1000 % x).bind(
                lambda y: Writer(y*100, mul100 % y)
            ))
        self.assertEqual(a, b)
dataset/ETHPy150Open dbrattli/OSlash/tests/test_writer.py/TestWriterMonad.test_writer_monad_law_associativity/original