I am trying to implement the data type LExpr as an instance of show.
data LExpr = Var String
| App LExpr LExpr
| Lam String LExpr
This is my code:
instance Show LExpr where
showsPrec d (Var str) = showString' str
showsPrec d (App e1 e2) = showParen (d>=6) $ showsPrec 6 e1 . showString " " . showsPrec 5 e2
showsPrec d (Lam str e) = showParen (d>=5) $ showString ("\\"++str++" -> ") . showsPrec 5 e
I am looking for some advice on how to further improve my code.