summaryrefslogtreecommitdiff
path: root/Coalpit.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-16 11:29:57 +0300
committerdefanor <defanor@uberspace.net>2017-12-16 11:29:57 +0300
commit250cb777adb303841626af86de526341d57d2f7c (patch)
tree82dcdb4965d70408a5cd936dc26a9ddde4c7c507 /Coalpit.hs
parent10958faa61301446a980ea93cb2e77287b51a225 (diff)
Update documentation
Diffstat (limited to 'Coalpit.hs')
-rw-r--r--Coalpit.hs26
1 files 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'.