on master help sign in
BuildUnicodeTable: use foldr
f48e449Jonathan Daugherty
tools/BuildUnicodeTable.hs+5−7
@@ -46,13 +46,11 @@ usage = do
46
46
47 putStrLn $ usageInfo pn (options config)
47 putStrLn $ usageInfo pn (options config)
48
48
49−configFromArgs :: [Arg] -> Config -> Config
49+updateConfigFromArg :: Arg -> Config -> Config
50−configFromArgs [] c =
50+updateConfigFromArg Help c =
51 c
51 c
52−configFromArgs (Help:as) c =
53− configFromArgs as c
54−configFromArgs (OutputPath p:as) c =
52+updateConfigFromArg (OutputPath p) c =
55− configFromArgs as (c { configOutputPath = Just p })
53+ c { configOutputPath = Just p }
56
54
57main :: IO ()
55main :: IO ()
58main = do
56main = do
@@ -68,7 +66,7 @@ main = do
68 usage
66 usage
69 exitFailure
67 exitFailure
70
68
71− let config = configFromArgs args defConfig
69+ let config = foldr updateConfigFromArg defConfig args
72
70
73 outputPath <- case configOutputPath config of
71 outputPath <- case configOutputPath config of
74 Nothing -> do
72 Nothing -> do