I have 2 classes:
class (IsColor (ColorType a)) => ColorList a where
type ColorType a :: *
foreground :: a -> (ColorType a)
background :: a -> (ColorType a)
class (ColorList (ThemeColorList a)) => Theme a where
type ThemeColorList a :: *
renderTheme :: a -> b
I have function dosomething with type signature:
dosomething :: (IsColor a) => a -> Int
I define instance of Theme class for data type SimpleTheme:
data SimpleTheme a = SimpleTheme a
instance (ColorList a) => Theme (SimpleTheme a) where
type ThemeColorList (SimpleTheme a) = a
renderTheme theme = dosomething $ background theme
If in renderTheme I do something with background or foreground, I get compilation error:
Could not deduce (IsColor (ColorType (SimpleTheme a)))
arising from a use of ‘dosomething’
from the context (ColorList (ThemeColorList (SimpleTheme a)),
ColorList a)
bound by the instance declaration at
How to solve problem?
renderThemeseems too general (for allb, really?)