Skip to content

Commit 8b4e339

Browse files
committed
D.Text: export defaultStyle
Exporting the default rendering style allows us to consistently format text without needing to write a Text instance.
1 parent 9accafe commit 8b4e339

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Cabal/Distribution/Text.hs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
--
1414
module Distribution.Text (
1515
Text(..),
16+
defaultStyle,
1617
display,
1718
simpleParse,
1819
) where
@@ -27,13 +28,15 @@ class Text a where
2728
disp :: a -> Disp.Doc
2829
parse :: Parse.ReadP r a
2930

31+
-- | The default rendering style used in Cabal for console output.
32+
defaultStyle :: Disp.Style
33+
defaultStyle = Disp.Style { Disp.mode = Disp.PageMode
34+
, Disp.lineLength = 79
35+
, Disp.ribbonsPerLine = 1.0
36+
}
37+
3038
display :: Text a => a -> String
31-
display = Disp.renderStyle style . disp
32-
where style = Disp.Style {
33-
Disp.mode = Disp.PageMode,
34-
Disp.lineLength = 79,
35-
Disp.ribbonsPerLine = 1.0
36-
}
39+
display = Disp.renderStyle defaultStyle . disp
3740

3841
simpleParse :: Text a => String -> Maybe a
3942
simpleParse str = case [ p | (p, s) <- Parse.readP_to_S parse str

0 commit comments

Comments
 (0)