All well and good when the shared superclass is Functor
. But is the below program valid, and if so, what does it print? If it is invalid due to overlapping instances, is there going to be a special case that recognizes Functor
-derived classes like Monad
and Traversable
as not conflicting?
class Alpha a where
alpha :: a -> String
class Bravo a where
bravo :: a -> a -> String
implication instance Bravo a => Alpha a where
alpha a = bravo a a
class Charlie a where
charlie :: [a] -> String
implication instance Charlie a => Alpha a where
alpha a = charlie [a]
data Foo = Foo
instance Bravo Foo where
bravo _ _ = "bravo"
instance Charlie Foo where
charlie _ = "charlie"
-- What does this print?
main :: IO ()
main = putStrLn $ alpha Foo