prettyPrint :: Val -> Text
prettyPrint = go False
    where
        go :: Bool -> Val -> Text
        go underApp (Lam var body) = ppParens underApp (var <> " -> " <> go False body)
        go _ (Var name) = name
        go underApp (App func arg) = ppParens underApp (go True func <> " " <> go True arg)

        ppParens :: Bool -> Text -> Text
        ppParens wanted inner = if wanted then "(" <> inner <> ")" else inner
prettyPrint :: Val -> Text
prettyPrint = go False
    where
        go :: Bool -> Val -> Text
        go underApp (Lam var body) = ppParens underApp (var <> " -> " <> go False body)
        go _ (Var name) = name
        go underApp (App func arg) = ppParens underApp (go True func <> " " <> go True arg)

        ppParens :: Bool -> Text -> Text
        ppParens wanted inner = if wanted then "(" <> inner <> ")" else inner
prettyPrint = go False
    where
        go :: Bool -> Val -> Text
        go underApp (Lam var body) = ppParens underApp (var <> " -> " <> go False body)
        go _ (Var name) = name
        go underApp (App func arg) = ppParens underApp (go True func <> " " <> go True arg)

        ppParens :: Bool -> Text -> Text
        ppParens wanted inner = if wanted then "(" <> inner <> ")" else inner