[Haskell-cafe] Name My Functor Classes
Ashley Yakeley
ashley at semantic.org
Mon Feb 7 21:54:50 EST 2005
These classes seem like they might correspond to concepts in category
theory:
class Functor f where
fmap :: (a -> b) -> f a -> f b
-- must satisfy:
-- fmap id = id
-- fmap (p . q) = (fmap p) . (fmap q)
class (Functor f) => C1 f where
f1 :: f (a -> b) -> f a -> f b
class (C1 f) => C2 f where
return :: a -> f a
-- must satisfy:
-- fmap = f1 . return
class (C2 f) => Monad f where
(>>=) :: f a -> (a -> f b) -> f b
-- must satisfy:
-- fmap ab fa = fa >>= (return . ab)
-- f1 fab fa = fab >>= (\ab -> fmap ab fa)
-- (return a) >>= p = p a
-- (fa >>= p) >>= q = fa >>= (\a -> p a >>= q)
What are good names for C1, C2 and f1?
--
Ashley Yakeley, Seattle WA
More information about the Haskell-Cafe
mailing list