Split code into modules

Also did some work on laws
This commit is contained in:
Pranshu Sharma 2025-05-21 16:29:43 +10:00
parent 953c0d2298
commit 5113241a63
4 changed files with 88 additions and 43 deletions

22
Calculator.hs Normal file
View file

@ -0,0 +1,22 @@
module Calculator where
import Utils
import Expr
import Parser
data Law = Law LawName Equation
deriving Show
type LawName = String
type Equation = (Expr,Expr)
law :: Parser Law
law = do name <- upto ':'
eqn <- equation
return (Law name eqn)
equation :: Parser Equation
equation = do lh <- expr
symbol "="
rh <- expr
return (lh, rh)