def test_nothing_functor_law2(self): # fmap (f . g) x = fmap f (fmap g x) def f(x): return x + 10 def g(x): return x * 10 x = Nothing() self.assertEquals(x.map(compose(f, g)), x.map(g).map(f))
def test_nothing_functor_law2(self): # fmap (f . g) x = fmap f (fmap g x) def f(x): return x+10 def g(x): return x*10 x = Nothing() self.assertEquals( x.map(compose(f, g)), x.map(g).map(f) )
def test_nothing_functor_map(self): f = lambda x: x+2 x = Nothing() self.assertEquals( x.map(f), x )
def test_nothing_functor_map(self): f = lambda x: x + 2 x = Nothing() self.assertEqual( x.map(f), x )
def test_nothing_applicative_law_functor(self): # pure f <*> x = fmap f x x = Nothing() f = lambda x: x * 42 self.assertEquals( pure(f).apply(x), x.map(f) )
def test_nothing_applicative_law_functor(self): # pure f <*> x = fmap f x x = Nothing() f = lambda x: x * 42 self.assertEqual( pure(f).apply(x), x.map(f) )