From 3bfad391d39d2c23cc01ca4c5ef5faa28575a346 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 9 Mar 2020 19:51:28 +0100 Subject: Argument Checking, equation evaluation --- src/parser.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/parser.hs') diff --git a/src/parser.hs b/src/parser.hs index 7929c26..df0ac10 100644 --- a/src/parser.hs +++ b/src/parser.hs @@ -5,6 +5,8 @@ import Control.Monad import Data.Char import Numeric.Natural +import Equation + newtype Parser a = Parser (String -> Maybe (a, String)) @@ -49,10 +51,8 @@ sepBy :: Parser a -> Parser b -> Parser [a] sepBy x sep = ((:) <$> x <*> many (sep *> x)) <|> pure [] +-- Equation parsers -- 1 * X^0 + 2 * X^1 + 1 * 3 * X^2 = 0 -data Equation = Equation { left :: Polynomial, right :: Polynomial } deriving (Show) -type Polynomial = [Term] -data Term = Term { coefficient :: Float, exponent :: Natural } deriving (Show) coefficientP :: Parser Float coefficientP = read <$> (floatP <|> digitsP) -- cgit