MaybeInt Parser

This commit is contained in:
Zoe Roux
2021-03-08 17:58:08 +01:00
parent 30b74b129f
commit 167e62c2bc
+22 -1
View File
@@ -60,4 +60,25 @@ int =
x <- num
return (-x)
<|>
num
num
maybeInt :: Parser (Maybe Int)
maybeInt = P $ \str -> case parse int str of
Nothing -> Just (Nothing, str)
Just (y, lo) -> Just (Just y, lo)
data Configuration = Configuration {
rule :: Int,
start :: Maybe Int,
lines :: Maybe Int,
window :: Maybe Int,
move :: Maybe Int
} deriving Show
defaultConfiguration = Configuration {
rule = 0,
start = Just 0,
Main.lines = Nothing,
window = Just 80,
move = Just 0
}