Linking/Combining Type Classes in Haskell
Posted
by thegravian
on Stack Overflow
See other posts from Stack Overflow
or by thegravian
Published on 2010-05-20T19:52:36Z
Indexed on
2010/05/20
20:10 UTC
Read the original article
Hit count: 190
Say I have two type classes defined as follows that are identical in function but different in names:
class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
return :: a -> m a
class PhantomMonad p where
pbind :: p a -> (a -> p b) -> p b
preturn :: a -> p b
Is there a way to tie these two classes together so something that is an instance of PhantomMonad will automatically be an instance of Monad, or will instances for each class have to be explicitly written? Any insight would be most appreciated, thanks!
© Stack Overflow or respective owner