FP Laboratory 9

From Marek Běhálek Wiki
Revision as of 12:10, 18 September 2019 by Beh01 (talk | contribs)
Jump to navigation Jump to search

User defined data types and type classes

Consider following representation of expressions

data Expr = Num Int
          | Add Expr Expr
          | Sub Expr Expr
          | Mul Expr Expr
          | Div Expr Expr
          | Var Char
	  deriving (Eq)
  • Create function eval that evaluates expresions.
  • Create function showExpr that shows expression as a String.
  • Extend class Show to be usable with our expressions.
  • Create function derivation representing symbolic derivation of a given expression.