Skip to content
Snippets Groups Projects
Commit 8b4e3393 authored by ttuegel's avatar ttuegel
Browse files

D.Text: export defaultStyle

Exporting the default rendering style allows us to consistently format
text without needing to write a Text instance.
parent 9accafeb
Branches fix-typo
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
--
module Distribution.Text (
Text(..),
defaultStyle,
display,
simpleParse,
) where
......@@ -27,13 +28,15 @@ class Text a where
disp :: a -> Disp.Doc
parse :: Parse.ReadP r a
-- | The default rendering style used in Cabal for console output.
defaultStyle :: Disp.Style
defaultStyle = Disp.Style { Disp.mode = Disp.PageMode
, Disp.lineLength = 79
, Disp.ribbonsPerLine = 1.0
}
display :: Text a => a -> String
display = Disp.renderStyle style . disp
where style = Disp.Style {
Disp.mode = Disp.PageMode,
Disp.lineLength = 79,
Disp.ribbonsPerLine = 1.0
}
display = Disp.renderStyle defaultStyle . disp
simpleParse :: Text a => String -> Maybe a
simpleParse str = case [ p | (p, s) <- Parse.readP_to_S parse str
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment