File: Util.hs

package info (click to toggle)
haskell-http-client 0.7.17-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 528 kB
  • sloc: haskell: 4,029; makefile: 3
file content (15 lines) | stat: -rw-r--r-- 357 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Network.HTTP.Client.Util
    ( readPositiveInt
    ) where

import Text.Read (readMaybe)
import Control.Monad (guard)

-- | Read a positive 'Int', accounting for overflow
readPositiveInt :: String -> Maybe Int
readPositiveInt s = do
  i <- readMaybe s
  guard $ i >= 0
  Just i