git.iko.soy/typeable/http-api-data
on master help sign in
Rename helper to parseMaybeHttpApiData and loose error message
ca853c6Nickolay Kudasov
Web/HttpApiData.hs+5−5
@@ -5,7 +5,7 @@
5module Web.HttpApiData (
5module Web.HttpApiData (
6 ToHttpApiData (..),
6 ToHttpApiData (..),
7 FromHttpApiData (..),
7 FromHttpApiData (..),
8− parseMaybeUrlPiece,
8+ parseMaybeHttpApiData,
9 showUrlPiece,
9 showUrlPiece,
10 readMaybeUrlPiece,
10 readMaybeUrlPiece,
11 readEitherUrlPiece,
11 readEitherUrlPiece,
@@ -58,10 +58,10 @@ class FromHttpApiData a where
58 parseQueryParam = parseUrlPiece
58 parseQueryParam = parseUrlPiece
59
59
60-- | Convert @'Maybe'@ parser into @'Either' 'Text'@ parser with default error message.
60-- | Convert @'Maybe'@ parser into @'Either' 'Text'@ parser with default error message.
61−parseMaybeUrlPiece :: (Text -> Maybe a) -> (Text -> Either Text a)
61+parseMaybeHttpApiData :: (Text -> Maybe a) -> (Text -> Either Text a)
62−parseMaybeUrlPiece parse input =
62+parseMaybeHttpApiData parse input =
63 case parse input of
63 case parse input of
64− Nothing -> Left ("parseUrlPiece: could not convert: `" <> input <> "'")
64+ Nothing -> Left ("could not convert: `" <> input <> "'")
65 Just val -> Right val
65 Just val -> Right val
66
66
67-- | Convert to URL piece using @'Show'@ instance.
67-- | Convert to URL piece using @'Show'@ instance.
@@ -74,7 +74,7 @@ readMaybeUrlPiece = readMaybe . Text.unpack
74
74
75-- | Parse URL piece using @'Read'@ instance.
75-- | Parse URL piece using @'Read'@ instance.
76readEitherUrlPiece :: Read a => Text -> Either Text a
76readEitherUrlPiece :: Read a => Text -> Either Text a
77−readEitherUrlPiece = parseMaybeUrlPiece readMaybeUrlPiece
77+readEitherUrlPiece = parseMaybeHttpApiData readMaybeUrlPiece
78
78
79-- | Run @'Reader'@ as HTTP API data parser.
79-- | Run @'Reader'@ as HTTP API data parser.
80runReader :: Reader a -> Text -> Either Text a
80runReader :: Reader a -> Text -> Either Text a