Hi,
In the example below does the concept of inheritance only apply to classes and not instances?
By inheritance I mean that a method in a sub-class can use a method from the super-class but not vice versa.
Would the inclusion of instance contexts such as 'instance (Eq a, Show b) => MyClass a b' apply such inheritance semantics between LHS => RHS of instances?
My current misunderstandings are in the comments.
Thanks,
Pat
-- Any instance of SUPER must define the super method. The super method definition may use any function in scope on the RHS of equations.
-- If the default method is defined in the class it may use any method in scope except those from the sub-class
class SUPER a where
 super :: a -> a
-- Any instance of SUB must define sub. The sub method definition may use super or any function in scope on the RHS of equations
class SUPER a => SUB a where
  sub :: a -> a

-- This instance defines super and can use sub because sub it is defined and is in scope
instance SUPER Int  where
 super n  = 1 + (sub n)
 
-- This instance defines sub
instance SUB Int  where
 sub n = 6 +  n
 
-- The Char instances differs from the Int instances in that the SUB uses super.
instance SUPER Char where
 super n  = 's'
 
-- The use of super here because it is defined and is in scope.
instance SUB Char where
 sub n = super n