1{-# LANGUAGE OverloadedStrings #-} 2{-# LANGUAGE ScopedTypeVariables #-} 3module Network.HTTP.Client.Util 4 ( readPositiveInt 5 ) where 6 7import Text.Read (readMaybe) 8import Control.Monad (guard) 9 10-- | Read a positive 'Int', accounting for overflow 11readPositiveInt :: String -> Maybe Int 12readPositiveInt s = do 13 i <- readMaybe s 14 guard $ i >= 0 15 Just i 16