git.iko.soy/typeable/http-api-data
on master help sign in
Add example for parseBounded
commit2923902067d1aaa532619d1d0f542901b6c6e629 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateWed 7 Oct 2015, 13:17 (11 years ago) parent62ce86f
1 file changed+3
Web/HttpApiData/Internal.hs+3
Web/HttpApiData/Internal.hs+3
@@ -146,6 +146,9 @@ runReader reader input =
146146 | otherwise -> defaultParseError input
147147
148148-- | Run @'Reader'@ to parse bounded integral value with bounds checking.
149+--
150+-- >>> parseBounded decimal "256" :: Either Text Word8
151+-- Left "out of bounds: `256' (should be between 0 and 255)"
149152parseBounded :: forall a. (Bounded a, Integral a) => Reader Integer -> Text -> Either Text a
150153parseBounded reader input = do
151154 n <- runReader reader input