I want to create an expression that can be composed of variables or constants (such as mathematical expressions) so I created a newtype to represent those expressions as strings, but when using it on functions it does not work:
newtype Expr = Expr String deriving (Show)
constant :: Int -> Expr
constant n = show n
variable :: String -> Expr
variable v = v
the error I get is that the type Expr does not match with String, and I cant use the function show even though I defined it earlier. please help!