    module Network.Socket.SendFile.Util
        ( wrapSendFile'
        ) where

    -- | wraps sendFile' to check arguments
    wrapSendFile' :: Integral i => (a -> b -> i -> i -> i -> IO c) -> a -> b -> Integer -> Integer -> Integer -> IO c
    wrapSendFile' :: (a -> b -> i -> i -> i -> IO c)
    -> a -> b -> Integer -> Integer -> Integer -> IO c
    wrapSendFile' fun :: a -> b -> i -> i -> i -> IO c
    fun outp :: a
    outp inp :: b
    inp blockSize :: Integer
    blockSize off :: Integer
    off count :: Integer
    count
    --    | count     == 0 = return () -- Send nothing -- why do the work? Also, Windows and FreeBSD treat '0' as 'send the whole file'.
        | Integer
    count     Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <  0 = [Char] -> IO c
    forall a. HasCallStack => [Char] -> a
    error "SendFile - count must be a positive integer"
        | (Integer
    count Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= 0) Bool -> Bool -> Bool
    && (Integer
    blockSize Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= 0) = [Char] -> IO c
    forall a. HasCallStack => [Char] -> a
    error "SendFile - blockSize must be a positive integer greater than 1"
        | Integer
    off       Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <  0 = [Char] -> IO c
    forall a. HasCallStack => [Char] -> a
    error "SendFile - offset must be a positive integer"
        | Bool
    otherwise      = a -> b -> i -> i -> i -> IO c
    fun a
    outp b
    inp (Integer -> i
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Integer
    blockSize) (Integer -> i
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Integer
    off) (Integer -> i
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Integer
    count)