Write better docs (and remove last use if undefined)

This commit is contained in:
Alex Mason 2016-09-02 16:17:17 +10:00
parent 7293717a0d
commit 32fa3490cf

View file

@ -35,8 +35,8 @@ type ISO8601Date = "%Y-%m-%d"
type ISO8601DateTime = "%Y-%m-%dT%H:%M:%S" type ISO8601DateTime = "%Y-%m-%dT%H:%M:%S"
type ISO8601DateTimeZ = "%Y-%m-%dT%H:%M:%S%z" type ISO8601DateTimeZ = "%Y-%m-%dT%H:%M:%S%z"
-- | A wrapper around a time type which can be parsed/rendered to with `format', -- | An `FTime` is a wrapper around a time type which can be
-- as specified in 'Data.Time.Format'. -- parsed/rendered with `format', as specified in "Data.Time.Format".
-- --
-- Example: -- Example:
-- --
@ -75,9 +75,17 @@ instance (KnownSymbol format, T.ParseTime t) => FromHttpApiData (FTime format t)
toFormatProxy :: FTime format t -> Proxy format toFormatProxy :: FTime format t -> Proxy format
toFormatProxy _ = Proxy toFormatProxy _ = Proxy
-- | Returns the sttring representation of the type level @format@ string
--
-- >>> getFormat (undefined :: FTime ISO8601Date UTCTime)
-- "%Y-%m-%d"
getFormat :: KnownSymbol format => FTime format t -> String getFormat :: KnownSymbol format => FTime format t -> String
getFormat t = symbolVal (toFormatProxy t) getFormat t = symbolVal (toFormatProxy t)
-- | Renders an @FTime format t@ using the format `format'.
--
-- >>> renderFTime (FTime (fromGregorian 2016 9 2) :: FTime ISO8601Date Day)
-- "2016-09-02"
renderFTime :: (KnownSymbol format, T.FormatTime t) => FTime format t -> String renderFTime :: (KnownSymbol format, T.FormatTime t) => FTime format t -> String
renderFTime tt@(FTime t) = T.formatTime T.defaultTimeLocale (getFormat tt) t renderFTime tt@(FTime t) = T.formatTime T.defaultTimeLocale (getFormat tt) t
@ -88,10 +96,10 @@ parseFTime str = res where
++ str ++ "\" with format \"" ++ fmt ++ "\"" ++ str ++ "\" with format \"" ++ fmt ++ "\""
Just t -> Right (FTime t) Just t -> Right (FTime t)
fmt = getFormat (toFTimeTy res) fmt = symbolVal (toFTimeTy res)
toFTimeTy :: Either Text (FTime format t) -> FTime format a toFTimeTy :: Either Text (FTime format t) -> Proxy format
toFTimeTy _ = undefined toFTimeTy _ = Proxy
ptime :: T.ParseTime t => T.TimeLocale -> String -> String -> Maybe t ptime :: T.ParseTime t => T.TimeLocale -> String -> String -> Maybe t
@ -109,5 +117,6 @@ rtime = T.readSTime False
-- >>> import Data.Aeson -- >>> import Data.Aeson
-- >>> import Data.Text -- >>> import Data.Text
-- >>> import Data.Time.Calendar -- >>> import Data.Time.Calendar
-- >>> import Data.Time.Clock (UTCTime)
-- >>> data Event -- >>> data Event
-- >>> instance ToJSON Event where { toJSON = undefined } -- >>> instance ToJSON Event where { toJSON = undefined }