module Database.PostgreSQL.Replicant.Util where

import Control.Exception
import GHC.Int

mkInt64 :: Int -> Int64
mkInt64 :: Int -> Int64
mkInt64 Int
k = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
k Int64 -> Int64 -> Int64
forall a. Num a => a -> a -> a
* Int64
1000000

maybeThrow :: Exception e => e -> Maybe a -> IO a
maybeThrow :: e -> Maybe a -> IO a
maybeThrow e
exc = \case
  Maybe a
Nothing -> e -> IO a
forall e a. Exception e => e -> IO a
throwIO e
exc
  Just a
x  -> a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x