@@ -1,4 +1,6 @@
11-- | Prettier YAML encoding.
2+--
3+-- Since 0.8.13
24module Data.Yaml.Pretty
35 ( encodePretty
46 , Config
@@ -18,17 +20,25 @@ import Data.List (sortBy)
1820import Data.ByteString (ByteString)
1921import Prelude hiding (null)
2022
23+-- |
24+-- Since 0.8.13
2125data Config = Config
2226 { confCompare :: Text -> Text -> Ordering -- ^ Function used to sort keys in objects
2327 }
2428
2529-- | The default configuration: do not sort objects.
30+--
31+-- Since 0.8.13
2632defConfig :: Config
2733defConfig = Config mempty
2834
35+-- |
36+-- Since 0.8.13
2937getConfCompare :: Config -> Text -> Text -> Ordering
3038getConfCompare = confCompare
3139
40+-- |
41+-- Since 0.8.13
3242setConfCompare :: (Text -> Text -> Ordering) -> Config -> Config
3343setConfCompare cmp c = c { confCompare = cmp }
3444
@@ -42,5 +52,7 @@ pretty cfg = go
4252 go (Bool b) = bool b
4353
4454-- | Configurable 'encode'.
55+--
56+-- Since 0.8.13
4557encodePretty :: ToJSON a => Config -> a -> ByteString
4658encodePretty cfg = toByteString . pretty cfg . toJSON