Use newtypes to retain more information
This commit is contained in:
parent
af7ebce206
commit
3ad26674d3
1 changed files with 15 additions and 10 deletions
25
src/INAST.hs
25
src/INAST.hs
|
@ -29,19 +29,19 @@ insuranceNetworkParser = many1 line
|
|||
, INASTExprInsurerId <$> insurerId ]
|
||||
-- <lesser-than> ::= "<" <integer>
|
||||
lt :: Parser INASTLt
|
||||
lt = "<" *> integer
|
||||
lt = INASTLt <$> ("<" *> integer)
|
||||
-- <greater-than> ::= ">" <integer>
|
||||
gt :: Parser INASTGt
|
||||
gt = ">" *> integer
|
||||
gt = INASTGt <$> (">" *> integer)
|
||||
-- <equals> ::= "=" <integer>
|
||||
eq :: Parser INASTEq
|
||||
eq = "=" *> integer
|
||||
eq = INASTEq <$> ("=" *> integer)
|
||||
-- <insurer-id> ::= "I" <integer>
|
||||
insurerId :: Parser INASTInsurerId
|
||||
insurerId = "I" *> integer
|
||||
insurerId = INASTInsurerId <$> ("I" *> integer)
|
||||
-- <percent> ::= <integer> "%"
|
||||
percent :: Parser INASTPercent
|
||||
percent = integer <* "%"
|
||||
percent = INASTPercent <$> integer <* "%"
|
||||
-- <integer> ::= <digit> | <non-zero-digit> <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)
|
||||
|
|
Loading…
Reference in a new issue