@@ -38,6 +38,9 @@ import Text.ParserCombinators.ReadP (readP_to_S)
3838import TextShow (TextShow, showt)
3939#endif
4040
41+-- $setup
42+-- >>> import Data.Time
43+
4144-- | Convert value to HTTP API data.
4245class ToHttpApiData a where
4346 {-# MINIMAL toUrlPiece | toQueryParam #-}
@@ -267,6 +270,10 @@ instance ToHttpApiData Word8 where toUrlPiece = showt
267270instance ToHttpApiData Word16 where toUrlPiece = showt
268271instance ToHttpApiData Word32 where toUrlPiece = showt
269272instance ToHttpApiData Word64 where toUrlPiece = showt
273+
274+-- |
275+-- >>> toUrlPiece (fromGregorian 2015 10 03)
276+-- "2015-10-03"
270277instance ToHttpApiData Day where toUrlPiece = T.pack . show
271278
272279instance ToHttpApiData String where toUrlPiece = T.pack
@@ -321,6 +328,7 @@ instance FromHttpApiData Version where
321328 _ -> defaultParseError s
322329
323330#if MIN_VERSION_base(4,8,0)
331+-- | Parsing a @'Void'@ value is always an error, considering @'Void'@ as a data type with no constructors.
324332instance FromHttpApiData Void where
325333 parseUrlPiece _ = Left "Void cannot be parsed!"
326334#endif
@@ -343,6 +351,10 @@ instance FromHttpApiData Word64 where parseUrlPiece = parseBounded decimal
343351instance FromHttpApiData String where parseUrlPiece = Right . T.unpack
344352instance FromHttpApiData Text where parseUrlPiece = Right
345353instance FromHttpApiData L.Text where parseUrlPiece = Right . L.fromStrict
354+
355+-- |
356+-- >>> toGregorian <$> parseUrlPiece "2016-12-01"
357+-- Right (2016,12,1)
346358instance FromHttpApiData Day where parseUrlPiece = readEitherTextData
347359
348360instance FromHttpApiData All where parseUrlPiece = fmap All . parseUrlPiece