Add haddock documentation
This commit is contained in:
parent
a1837d70fe
commit
c32525c9ce
14
src/Json.hs
14
src/Json.hs
@ -1,3 +1,4 @@
|
||||
-- | JSON utilities
|
||||
module Json where
|
||||
|
||||
import Data.Aeson
|
||||
@ -8,17 +9,19 @@ import Data.List (intercalate)
|
||||
import qualified Data.Vector as V
|
||||
import qualified Data.HashMap.Strict as H
|
||||
|
||||
-- Get the JSON value of a key
|
||||
-- | Get the JSON value of a key
|
||||
(|.) :: Object -> Text -> Value
|
||||
obj |. key = case parse (.: key) obj of
|
||||
Success val -> val
|
||||
Error err -> toJSON err
|
||||
|
||||
-- Get the String value of a key
|
||||
|
||||
-- | Get the String value of a key
|
||||
(|:) :: Object -> Text -> String
|
||||
obj |: key = repr (obj |. key)
|
||||
|
||||
-- Create a String representation of a JSON value
|
||||
|
||||
-- | Create a String representation of a 'Value'
|
||||
repr :: Value -> String
|
||||
repr obj = repr' obj 0 where
|
||||
repr' val lev =
|
||||
@ -34,6 +37,7 @@ repr obj = repr' obj 0 where
|
||||
indent l = '\n' : (concat . replicate l) " "
|
||||
dump o l k = concat [indent l, unpack k, ": ", repr' (o |. k) (l+1)]
|
||||
|
||||
-- Pretty print a JSON value
|
||||
|
||||
-- | Pretty print a JSON 'Value'
|
||||
pprint :: Value -> IO ()
|
||||
pprint = putStrLn . repr
|
||||
pprint = putStrLn . repr
|
||||
|
@ -1,4 +1,6 @@
|
||||
{-# LANGUAGE RecordWildCards, OverloadedStrings #-}
|
||||
-- | Main module
|
||||
module Main where
|
||||
|
||||
import Json
|
||||
|
||||
@ -56,6 +58,9 @@ description = info (helper <*> options)
|
||||
<> footer "Stat rosa pristina nomine, nomina nuda tenemus." )
|
||||
|
||||
|
||||
|
||||
-- * Program
|
||||
|
||||
-- | Main function
|
||||
main :: IO ()
|
||||
main = execParser description >>= exec where
|
||||
|
Loading…
Reference in New Issue
Block a user