def test_functor_law_distributive(functor): # fmap (g . f) = fmap g . fmap f f1 = lambda a: [a] f2 = str def composed(a): return f1(f2(a)) assert tc.fmap(functor, composed) == tc.fmap(tc.fmap(functor, f2), f1)
def test_functor_law_distributive(f): # fmap (g . f) = fmap g . fmap f _, functor, funcs = f f1 = funcs[0] f2 = funcs[1] def composed(a): return f1(f2(a)) assert tc.fmap(functor, composed) == tc.fmap(tc.fmap(functor, f2), f1)
def test_functor_law_identity(data): # fmap id = id def identity(a): return a assert tc.fmap(data, identity) == identity(data)