Challenge 1: A Shape Typeclass With a Default describe — Possible Solution ==================================================================== Main.hs: class Shape a where area :: a -> Double perimeter :: a -> Double describe :: a -> String describe s = "Area: " ++ show (area s) ++ ", Perimeter: " ++ show (perimeter s) data Circle = Circle Double data Square = Square Double instance Shape Circle where area (Circle r) = pi * r * r perimeter (Circle r) = 2 * pi * r instance Shape Square where area (Square s) = s * s perimeter (Square s) = 4 * s main :: IO () main = do putStrLn (describe (Circle 3)) putStrLn (describe (Square 4)) Output: Area: 28.274333882308138, Perimeter: 18.84955592153876 Area: 16.0, Perimeter: 16.0 Explanation: Neither Circle's nor Square's instance overrides describe -- both only supply area and perimeter, the two methods with no default body. describe is inherited automatically from Shape's own default implementation, which itself calls area and perimeter through whichever instance is actually in play for each type -- exactly the default-method inheritance the chapter introduces. WHY THIS WORKS AS AN ANSWER ------------------------------ This defines a real multi-method typeclass with a default method and two genuine instances, demonstrating the default method being inherited and used correctly without either instance overriding it.