FP Laboratory 9

From Marek Běhálek Wiki
Revision as of 12:09, 18 September 2019 by Beh01 (talk | contribs) (Created page with "== User defined data types and type classes == Consider following representation of expressions <syntaxhighlight lang="Haskell"> data Expr = Num Int | Add Expr Exp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.