def test_maybe_interface(self): maybe = Maybe() FunctorLaws.validate(Maybe) ApplicativeLaws.validate(Maybe) MonadLaws.validate(Maybe) self.assertEquals(Maybe.unit(1), Something(1)) self.assertRaises(NotImplementedError, lambda: maybe.get()) self.assertRaises(NotImplementedError, lambda: maybe.get_or_else(None))
def test_either_interface(self): either = Either() FunctorLaws.validate(Either) ApplicativeLaws.validate(Either) MonadLaws.validate(Either) self.assertEqual(Either.unit(2), Success(2)) self.assertRaises(NotImplementedError, lambda: either.is_error()) self.assertRaises(NotImplementedError, lambda: either.left()) self.assertRaises(NotImplementedError, lambda: either.right())
def test_list_interface(self): FunctorLaws.validate(List) ApplicativeLaws.validate(List) MonadLaws.validate(List)