diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-03-09 19:51:28 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-03-09 19:51:28 +0100 |
| commit | 3bfad391d39d2c23cc01ca4c5ef5faa28575a346 (patch) | |
| tree | e3c435df6dc31072f09bd3eabafb66a874dd3aef /src/parser.hs | |
| parent | ddff2e34a8f5e7fdb4a9e67d4df1edfa393ab3b7 (diff) | |
| download | computorv1-3bfad391d39d2c23cc01ca4c5ef5faa28575a346.tar.gz computorv1-3bfad391d39d2c23cc01ca4c5ef5faa28575a346.tar.bz2 computorv1-3bfad391d39d2c23cc01ca4c5ef5faa28575a346.zip | |
Argument Checking, equation evaluation
Diffstat (limited to 'src/parser.hs')
| -rw-r--r-- | src/parser.hs | 6 |
1 files changed, 3 insertions, 3 deletions
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) |
