From 250cb777adb303841626af86de526341d57d2f7c Mon Sep 17 00:00:00 2001 From: defanor Date: Sat, 16 Dec 2017 11:29:57 +0300 Subject: Update documentation --- Coalpit.hs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Coalpit.hs b/Coalpit.hs index 3efd73f..10228d6 100644 --- a/Coalpit.hs +++ b/Coalpit.hs @@ -21,7 +21,7 @@ import Coalpit data Foo = Foo { bar :: Maybe Int , baz :: String - } deriving (Show, Generic, Coalpit) + } deriving (Show, Generic, 'Coalpit') main :: IO () main = do @@ -59,7 +59,7 @@ Then, in a shell: {-# LANGUAGE ScopedTypeVariables #-} module Coalpit ( - -- * Core classes + -- * Core class Coalpit(..) -- * Utility functions , fromArgs @@ -67,11 +67,13 @@ module Coalpit ( -- * Options , Options(..) , defOpt - -- * Parsing helpers + -- * Parsing and printing helpers , Parser , CLArg(..) , pS , readArg + , pTime + , timeArg ) where import Data.List @@ -480,14 +482,28 @@ instance Coalpit Scientific where argHelper _ _ _ = "SCIENTIFIC" -pTime :: ParseTime a => Options -> String -> Parser a +-- | Parses a time argument. +pTime :: ParseTime a + => Options + -- ^ Options, to read 'timeLocale' from. + -> String + -- ^ Time format to use. + -> Parser a pTime opt tf = try $ do x <- token (Right . unArg) Nothing case readSTime False (timeLocale opt) tf x of [(t, "")] -> pure t _ -> fail "Failed to parse time" -timeArg :: FormatTime t => Options -> String -> t -> [String] +-- | Composes a time argument. +timeArg :: FormatTime t + => Options + -- ^ Options, to read 'timeLocale' from. + -> String + -- ^ Time format to use. + -> t + -- ^ Time value. + -> [String] timeArg opt tf t = [formatTime (timeLocale opt) tf t] -- | Uses 'dateTimeFormat'. -- cgit v1.2.3