There was an error while loading. Please reload this page.
1 parent 08d06a8 commit 64b0613Copy full SHA for 64b0613
1 file changed
Cabal/src/Distribution/GetOpt.hs
@@ -117,12 +117,14 @@ usageInfo header (map flattenNames -> options) = unlines (header : table)
117
rowOption name = indent : padTo (nameWidth - 2) name
118
119
-- | Pad a string to a given length with spaces.
120
+-- >>> padTo 5 "123"
121
+-- "123 "
122
--
--- If the string is longer than the given length, it is truncated.
123
+-- If the string is longer than the given length, it is not truncated.
124
-- >>> padTo 3 "12345"
--- "123"
125
+-- "12345"
126
padTo :: Int -> String -> String
-padTo n x = take n (x ++ repeat ' ')
127
+padTo = flip $ foldr (\ch rest n -> ch : rest (n - 1)) (`replicate` ' ')
128
129
-- | Flatten the short and long option names into a single string for display.
130
flattenNames :: OptDescr a -> OptHelp
0 commit comments