mirror of
https://github.com/zoriya/applicative-getopt.git
synced 2026-06-01 18:25:57 +00:00
MaybeInt Parser
This commit is contained in:
+22
-1
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user