diff --git a/prettyprinter/src/Prettyprinter/Internal.hs b/prettyprinter/src/Prettyprinter/Internal.hs index ca4c0b10..32747c97 100755 --- a/prettyprinter/src/Prettyprinter/Internal.hs +++ b/prettyprinter/src/Prettyprinter/Internal.hs @@ -976,7 +976,7 @@ concatWith f ds -- lorem ipsum dolor sit amet -- -- For automatic line breaks, consider using 'fillSep' instead. -hsep :: [Doc ann] -> Doc ann +hsep :: Foldable f => f (Doc ann) -> Doc ann hsep = concatWith (<+>) -- | @('vsep' xs)@ concatenates all documents @xs@ above each other. If a @@ -1006,7 +1006,7 @@ hsep = concatWith (<+>) -- -- Since 'group'ing a 'vsep' is rather common, 'sep' is a built-in for doing -- that. -vsep :: [Doc ann] -> Doc ann +vsep :: Foldable f => f (Doc ann) -> Doc ann vsep = concatWith (\x y -> x <> line <> y) -- | @('fillSep' xs)@ concatenates the documents @xs@ horizontally with @'<+>'@ @@ -1028,7 +1028,7 @@ vsep = concatWith (\x y -> x <> line <> y) -- Docs: lorem ipsum dolor sit amet lorem -- ipsum dolor sit amet lorem ipsum dolor -- sit amet lorem ipsum dolor sit amet -fillSep :: [Doc ann] -> Doc ann +fillSep :: Foldable f => f (Doc ann) -> Doc ann fillSep = concatWith (\x y -> x <> softline <> y) -- | @('sep' xs)@ tries laying out the documents @xs@ separated with 'space's, @@ -1051,7 +1051,7 @@ fillSep = concatWith (\x y -> x <> softline <> y) -- @ -- 'sep' = 'group' . 'vsep' -- @ -sep :: [Doc ann] -> Doc ann +sep :: Foldable f => f (Doc ann) -> Doc ann sep = group . vsep @@ -1064,7 +1064,7 @@ sep = group . vsep -- >>> let docs = Util.words "lorem ipsum dolor" -- >>> hcat docs -- loremipsumdolor -hcat :: [Doc ann] -> Doc ann +hcat :: Foldable f => f (Doc ann) -> Doc ann hcat = concatWith (<>) -- | @('vcat' xs)@ vertically concatenates the documents @xs@. If it is @@ -1083,7 +1083,7 @@ hcat = concatWith (<>) -- -- Since 'group'ing a 'vcat' is rather common, 'cat' is a built-in shortcut for -- it. -vcat :: [Doc ann] -> Doc ann +vcat :: Foldable f => f (Doc ann) -> Doc ann vcat = concatWith (\x y -> x <> line' <> y) -- | @('fillCat' xs)@ concatenates documents @xs@ horizontally with @'<>'@ as @@ -1112,7 +1112,7 @@ vcat = concatWith (\x y -> x <> line' <> y) -- Grouped: loremipsumdolorsitametlorem -- ipsumdolorsitametloremipsumdolorsitamet -- loremipsumdolorsitamet -fillCat :: [Doc ann] -> Doc ann +fillCat :: Foldable f => f (Doc ann) -> Doc ann fillCat = concatWith (\x y -> x <> softline' <> y) -- | @('cat' xs)@ tries laying out the documents @xs@ separated with nothing, @@ -1134,7 +1134,7 @@ fillCat = concatWith (\x y -> x <> softline' <> y) -- @ -- 'cat' = 'group' . 'vcat' -- @ -cat :: [Doc ann] -> Doc ann +cat :: Foldable f => f (Doc ann) -> Doc ann cat = group . vcat @@ -1806,8 +1806,8 @@ defaultLayoutOptions = LayoutOptions { layoutPageWidth = defaultPageWidth } -- | This is the default layout algorithm, and it is used by 'show', 'putDoc' -- and 'hPutDoc'. -- --- @'layoutPretty'@ commits to rendering something in a certain way if the --- remainder of the current line fits the layout constraints; in other words, +-- @'layoutPretty'@ commits to rendering something in a certain way if the +-- remainder of the current line fits the layout constraints; in other words, -- it has up to one line of lookahead when rendering. Consider using the -- smarter, but a bit less performant, @'layoutSmart'@ algorithm if the results -- seem to run off to the right before having lots of line breaks.