structural decomposition in partitionParams
Avoids partial !!
This commit is contained in:
parent
7d51ceb0ff
commit
517aa13913
1 changed files with 4 additions and 6 deletions
|
@ -104,12 +104,10 @@ external params = do
|
||||||
- rsync and not be useful.
|
- rsync and not be useful.
|
||||||
-}
|
-}
|
||||||
partitionParams :: [String] -> ([String], [String])
|
partitionParams :: [String] -> ([String], [String])
|
||||||
partitionParams params
|
partitionParams ps = case segment (== "--") ps of
|
||||||
| null segments = ([], [])
|
params:fieldparams:_ -> (params, fieldparams)
|
||||||
| length segments < 2 = (segments !! 0, [])
|
[params] -> (params, [])
|
||||||
| otherwise = (segments !! 0, segments !! 1)
|
_ -> ([], [])
|
||||||
where
|
|
||||||
segments = segment (== "--") params
|
|
||||||
|
|
||||||
parseFields :: [String] -> [(String, String)]
|
parseFields :: [String] -> [(String, String)]
|
||||||
parseFields = map (separate (== '='))
|
parseFields = map (separate (== '='))
|
||||||
|
|
Loading…
Reference in a new issue