git.iko.soy/typeable/http-api-data
on master help sign in
Add documentation for PathPiece/PathMultiPiece classes
commitf0a5c50a5f8baaaf5b81b7236e95f36dcb550bb7 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateSun 4 Oct 2015, 02:20 (11 years ago) parente8e821f
1 file changed+8−2
Web/PathPieces.hs+8−2
Web/PathPieces.hs+8−2
@@ -15,11 +15,14 @@ import Text.Read (readMaybe)
1515
1616import Web.HttpApiData
1717
18+-- | Convert Haskell values to and from route pieces.
1819class PathPiece s where
20+ -- | Convert from route piece.
1921 fromPathPiece :: S.Text -> Maybe s
2022 default fromPathPiece :: FromHttpApiData s => S.Text -> Maybe s
2123 fromPathPiece = either (const Nothing) Just . parseUrlPiece
2224
25+ -- | Convert to route piece.
2326 toPathPiece :: s -> S.Text
2427 default toPathPiece :: ToHttpApiData s => s -> S.Text
2528 toPathPiece = toUrlPiece
@@ -56,9 +59,12 @@ instance (PathPiece a) => PathPiece (Maybe a) where
5659 Just s -> "Just " `S.append` toPathPiece s
5760 _ -> "Nothing"
5861
62+-- | Convert Haskell values to and from sequence of route pieces.
5963class PathMultiPiece s where
60− fromPathMultiPiece :: [S.Text] -> Maybe s
61− toPathMultiPiece :: s -> [S.Text]
64+ -- | Convert from sequence of route pieces.
65+ fromPathMultiPiece :: [S.Text] -> Maybe s
66+ -- | Convert to sequence of route pieces.
67+ toPathMultiPiece :: s -> [S.Text]
6268
6369instance PathPiece a => PathMultiPiece [a] where
6470 fromPathMultiPiece = mapM fromPathPiece