summaryrefslogtreecommitdiffhomepage
path: root/lib/Language/Haskell/Stylish/Printer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Language/Haskell/Stylish/Printer.hs')
-rw-r--r--lib/Language/Haskell/Stylish/Printer.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Language/Haskell/Stylish/Printer.hs b/lib/Language/Haskell/Stylish/Printer.hs
index 886f912..a7ddf5e 100644
--- a/lib/Language/Haskell/Stylish/Printer.hs
+++ b/lib/Language/Haskell/Stylish/Printer.hs
@@ -44,6 +44,7 @@ module Language.Haskell.Stylish.Printer
, space
, spaces
, suffix
+ , pad
-- ** Advanced combinators
, withColumns
@@ -323,6 +324,13 @@ prefix pa pb = pa >> pb
suffix :: P a -> P b -> P a
suffix pa pb = pb >> pa
+-- | Indent to a given number of spaces. If the current line already exceeds
+-- that number in length, nothing happens.
+pad :: Int -> P ()
+pad n = do
+ len <- length <$> getCurrentLine
+ spaces $ n - len
+
-- | Gets comment on supplied 'line' and removes it from the state
removeLineComment :: Int -> P (Maybe AnnotationComment)
removeLineComment line =