From 3ad26674d3eb238afcc89e99c7dbadc81c10fb99 Mon Sep 17 00:00:00 2001 From: Samae Date: Sat, 2 Dec 2023 18:09:32 +0200 Subject: [PATCH] Use newtypes to retain more information --- src/INAST.hs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/INAST.hs b/src/INAST.hs index 816a12c..e5d21c9 100644 --- a/src/INAST.hs +++ b/src/INAST.hs @@ -29,19 +29,19 @@ insuranceNetworkParser = many1 line , INASTExprInsurerId <$> insurerId ] -- ::= "<" lt :: Parser INASTLt - lt = "<" *> integer + lt = INASTLt <$> ("<" *> integer) -- ::= ">" gt :: Parser INASTGt - gt = ">" *> integer + gt = INASTGt <$> (">" *> integer) -- ::= "=" eq :: Parser INASTEq - eq = "=" *> integer + eq = INASTEq <$> ("=" *> integer) -- ::= "I" insurerId :: Parser INASTInsurerId - insurerId = "I" *> integer + insurerId = INASTInsurerId <$> ("I" *> integer) -- ::= "%" percent :: Parser INASTPercent - percent = integer <* "%" + percent = INASTPercent <$> integer <* "%" -- ::= | -- Overapproximation of the grammar integer :: Parser Int @@ -58,8 +58,13 @@ data INASTExpr = INASTExprLt INASTLt | INASTExprInsurerId INASTInsurerId deriving (Show) -type INASTLt = Int -type INASTGt = Int -type INASTEq = Int -type INASTInsurerId = Int -type INASTPercent = Int +newtype INASTLt = INASTLt Int + deriving (Show) +newtype INASTGt = INASTGt Int + deriving (Show) +newtype INASTEq = INASTEq Int + deriving (Show) +newtype INASTInsurerId = INASTInsurerId Int + deriving (Show) +newtype INASTPercent = INASTPercent Int + deriving (Show)