From c32525c9ce425c65fb73937d4c88ef4fd4850dba Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 5 May 2016 18:06:20 +0200 Subject: [PATCH] Add haddock documentation --- src/Json.hs | 14 +++++++++----- src/Main.hs | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Json.hs b/src/Json.hs index 0083867..8ca033f 100644 --- a/src/Json.hs +++ b/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 \ No newline at end of file +pprint = putStrLn . repr diff --git a/src/Main.hs b/src/Main.hs index 0631349..715353b 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -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