Effective Haskell: no `Show expr` arising from print

Hi @RebeccaSkinner,

In for example the Calculator segment of chapter 4, if I run the examples in GHCI this error is returned:

    λ: Add (Lit 5) (Lit 4)

    <interactive>:159:1: error:
        • No instance for (Show Expr) arising from a use of ‘print’
        • In a stmt of an interactive GHCi command: print it

I understand what it means but personally I am not sure how to make all examples go past this. It seems by your examples in the book also that you don’t have this issue?

Thanks for catching this! I’ll take a look and push a fix in the next update!

In the mean time, you can work around this bug by adding deriving Show after your definition of Expr. For example:

data Expr = Lit Int
    | Sub Expr Expr
    | Add Expr Expr
    | Mul Expr Expr
    | Div Expr Expr
    deriving Show