@@ -19,8 +19,6 @@ module Web.HttpApiData (
1919 readEitherUrlPiece,
2020) where
2121
22−import Control.Arrow ((+++))
23−
2422import Data.Monoid
2523import Data.ByteString (ByteString)
2624
@@ -93,7 +91,12 @@ readEitherUrlPiece = parseMaybeHttpApiData readMaybeUrlPiece
9391
9492-- | Run @'Reader'@ as HTTP API data parser.
9593runReader :: Reader a -> Text -> Either Text a
96−runReader reader = (Text.pack +++ fst) . reader
94+runReader reader input =
95+ case reader input of
96+ Left err -> Left (Text.pack err)
97+ Right (x, rest)
98+ | Text.null rest -> Right x
99+ | otherwise -> Left ("could not convert: `" <> input <> "'")
97100
98101instance ToHttpApiData Bool where toUrlPiece = showUrlPiece
99102instance ToHttpApiData Double where toUrlPiece = showUrlPiece