2-- | Prettier YAML encoding.
13import Prelude hiding (null)
15#if !MIN_VERSION_base(4,8,0)
16import Control.Applicative ((<$>))
18import Data.Aeson.Types
19import Data.ByteString (ByteString)
20import Data.Function (on)
21import qualified Data.HashMap.Strict as HM
22import Data.List (sortBy)
23#if !MIN_VERSION_base(4,8,0)
26import Data.Text (Text)
27import qualified Data.Vector as V
29import Data.Yaml.Builder
34 { confCompare :: Text -> Text -> Ordering -- ^ Function used to sort keys in objects
37-- | The default configuration: do not sort objects.
41defConfig = Config mempty
45getConfCompare :: Config -> Text -> Text -> Ordering
46getConfCompare = confCompare
50setConfCompare :: (Text -> Text -> Ordering) -> Config -> Config
51setConfCompare cmp c = c { confCompare = cmp }
53pretty :: Config -> Value -> YamlBuilder
55 where go (Object o) = mapping (sortBy (confCompare cfg `on` fst) $ HM.toList $ HM.map go o)
56 go (Array a) = array (go <$> V.toList a)
58 go (String s) = string s
59 go (Number n) = scientific n
62-- | Configurable 'encode'.
65encodePretty :: ToJSON a => Config -> a -> ByteString
66encodePretty cfg = toByteString . pretty cfg . toJSON
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list