Challenge 3: A Missing Eq Constraint, Caught at Compile Time — Possible Solution ==================================================================== Broken attempt — Main.hs: bothSame :: a -> a -> Bool -- missing the Eq a => constraint bothSame x y = x == y Representative compile error: Main.hs:2:15: error: No instance for (Eq a) arising from a use of '==' Possible fix: add (Eq a) to the context of the type signature for: bothSame :: forall a. a -> a -> Bool Fixed — Main.hs: bothSame :: Eq a => a -> a -> Bool bothSame x y = x == y main :: IO () main = print (bothSame 5 5) Output: True Explanation: The original signature `a -> a -> Bool` promises bothSame works for EVERY possible type a, with no restriction at all -- but the function body uses ==, which only exists for types that have an Eq instance. GHC catches this contradiction directly: it can't prove == is legal for an unconstrained, fully generic a, since some type without an Eq instance could theoretically be substituted in. Adding `Eq a =>` to the signature narrows the promise to only types that DO support ==, which resolves the contradiction and lets the body type-check correctly. WHY THIS WORKS AS AN ANSWER ------------------------------ This reproduces the exact "No instance for (Eq a)" compile error the chapter's warn-box describes for a missing constraint, and the fix -- adding Eq a => -- resolves it precisely because it narrows the function's promise to match what its own body actually requires.