hasql/library/Hasql/Private/Prelude.hs

138 lines
5.5 KiB
Haskell
Raw Normal View History

module Hasql.Private.Prelude
2022-06-20 13:54:54 +03:00
( module Exports,
LazyByteString,
ByteStringBuilder,
LazyText,
TextBuilder,
forMToZero_,
forMFromZero_,
strictCons,
mapLeft,
)
2014-08-03 17:48:18 +04:00
where
2022-06-20 13:54:54 +03:00
import Control.Applicative as Exports hiding (WrappedArrow (..))
2021-03-23 15:06:42 +03:00
import Control.Arrow as Exports hiding (first, second)
import Control.Category as Exports
import Control.Concurrent as Exports
import Control.Exception as Exports
2022-06-20 13:54:54 +03:00
import Control.Monad as Exports hiding (fail, forM, forM_, mapM, mapM_, msum, sequence, sequence_)
import Control.Monad.Error.Class as Exports (MonadError (..))
2021-03-23 15:06:42 +03:00
import Control.Monad.Fail as Exports
import Control.Monad.Fix as Exports hiding (fix)
2022-06-20 13:54:54 +03:00
import Control.Monad.IO.Class as Exports
import Control.Monad.Reader.Class as Exports (MonadReader (..))
2021-03-23 15:06:42 +03:00
import Control.Monad.ST as Exports
2022-06-20 13:54:54 +03:00
import Control.Monad.Trans.Class as Exports
import Control.Monad.Trans.Cont as Exports hiding (callCC, shift)
import Control.Monad.Trans.Except as Exports (Except, ExceptT (ExceptT), catchE, except, mapExcept, mapExceptT, runExcept, runExceptT, throwE, withExcept, withExceptT)
import Control.Monad.Trans.Maybe as Exports
import Control.Monad.Trans.Reader as Exports (Reader, ReaderT (ReaderT), mapReader, mapReaderT, runReader, runReaderT, withReader, withReaderT)
import Control.Monad.Trans.State.Strict as Exports (State, StateT (StateT), evalState, evalStateT, execState, execStateT, mapState, mapStateT, runState, runStateT, withState, withStateT)
import Control.Monad.Trans.Writer.Strict as Exports (Writer, WriterT (..), execWriter, execWriterT, mapWriter, mapWriterT, runWriter)
2021-03-23 15:06:42 +03:00
import Data.Bifunctor as Exports
import Data.Bits as Exports
import Data.Bool as Exports
2022-06-20 13:54:54 +03:00
import Data.ByteString as Exports (ByteString)
import qualified Data.ByteString.Builder
import qualified Data.ByteString.Lazy
2021-03-23 15:06:42 +03:00
import Data.Char as Exports
import Data.Coerce as Exports
import Data.Complex as Exports
2022-06-20 13:54:54 +03:00
import Data.DList as Exports (DList)
2021-03-23 15:06:42 +03:00
import Data.Data as Exports
import Data.Dynamic as Exports
import Data.Either as Exports
import Data.Fixed as Exports
import Data.Foldable as Exports hiding (toList)
import Data.Function as Exports hiding (id, (.))
import Data.Functor as Exports
import Data.Functor.Compose as Exports
import Data.Functor.Contravariant as Exports
2022-06-20 13:54:54 +03:00
import Data.Functor.Contravariant.Divisible as Exports
import Data.Functor.Identity as Exports
import Data.Hashable as Exports (Hashable (..))
2021-03-23 15:06:42 +03:00
import Data.IORef as Exports
2022-06-20 13:54:54 +03:00
import Data.Int as Exports
2021-03-23 15:06:42 +03:00
import Data.Ix as Exports
2022-06-20 13:54:54 +03:00
import Data.List as Exports hiding (all, and, any, concat, concatMap, elem, find, foldl, foldl', foldl1, foldr, foldr1, isSubsequenceOf, mapAccumL, mapAccumR, maximum, maximumBy, minimum, minimumBy, notElem, or, product, sortOn, sum, uncons)
import Data.List.NonEmpty as Exports (NonEmpty (..))
2021-03-23 15:06:42 +03:00
import Data.Maybe as Exports
import Data.Monoid as Exports hiding (Alt, (<>))
import Data.Ord as Exports
2022-06-20 13:54:54 +03:00
import Data.Profunctor.Unsafe as Exports
2021-03-23 15:06:42 +03:00
import Data.Proxy as Exports
import Data.Ratio as Exports
import Data.STRef as Exports
import Data.Scientific as Exports (Scientific)
2022-06-20 13:54:54 +03:00
import Data.Semigroup as Exports hiding (First (..), Last (..))
2021-03-23 15:06:42 +03:00
import Data.String as Exports
2022-06-20 13:54:54 +03:00
import Data.Text as Exports (Text)
import qualified Data.Text.Lazy
import qualified Data.Text.Lazy.Builder
import Data.Time as Exports
2021-03-23 15:06:42 +03:00
import Data.Traversable as Exports
import Data.Tuple as Exports
import Data.UUID as Exports (UUID)
2021-03-23 15:06:42 +03:00
import Data.Unique as Exports
2022-06-20 13:54:54 +03:00
import Data.Vector as Exports (Vector)
2021-03-23 15:06:42 +03:00
import Data.Version as Exports
import Data.Void as Exports
import Data.Word as Exports
import Debug.Trace as Exports
import Foreign.ForeignPtr as Exports
import Foreign.Ptr as Exports
import Foreign.StablePtr as Exports
import Foreign.Storable as Exports
2022-06-20 13:54:54 +03:00
import GHC.Conc as Exports hiding (orElse, threadWaitRead, threadWaitReadSTM, threadWaitWrite, threadWaitWriteSTM, withMVar)
import GHC.Exts as Exports (IsList (..), groupWith, inline, lazy, sortWith)
2021-03-23 15:06:42 +03:00
import GHC.Generics as Exports (Generic)
import GHC.IO.Exception as Exports
import GHC.OverloadedLabels as Exports
import Numeric as Exports
import System.Environment as Exports
import System.Exit as Exports
import System.IO as Exports (Handle, hClose)
import System.IO.Error as Exports
import System.IO.Unsafe as Exports
import System.Mem as Exports
import System.Mem.StableName as Exports
import System.Timeout as Exports
import Text.ParserCombinators.ReadP as Exports (ReadP, readP_to_S, readS_to_P)
2022-06-20 13:54:54 +03:00
import Text.ParserCombinators.ReadPrec as Exports (ReadPrec, readP_to_Prec, readPrec_to_P, readPrec_to_S, readS_to_Prec)
import Text.Printf as Exports (hPrintf, printf)
2021-03-23 15:06:42 +03:00
import Unsafe.Coerce as Exports
2022-06-20 13:54:54 +03:00
import Prelude as Exports hiding (Read, all, and, any, concat, concatMap, elem, fail, foldl, foldl1, foldr, foldr1, id, mapM, mapM_, maximum, minimum, notElem, or, product, sequence, sequence_, sum, (.))
2015-11-08 21:09:42 +03:00
type LazyByteString =
Data.ByteString.Lazy.ByteString
type ByteStringBuilder =
Data.ByteString.Builder.Builder
type LazyText =
Data.Text.Lazy.Text
type TextBuilder =
Data.Text.Lazy.Builder.Builder
2015-11-20 09:29:46 +03:00
{-# INLINE forMToZero_ #-}
forMToZero_ :: Applicative m => Int -> (Int -> m a) -> m ()
forMToZero_ !startN f =
($ pred startN) $ fix $ \loop !n -> if n >= 0 then f n *> loop (pred n) else pure ()
2015-11-21 09:57:44 +03:00
2015-11-21 12:01:32 +03:00
{-# INLINE forMFromZero_ #-}
forMFromZero_ :: Applicative m => Int -> (Int -> m a) -> m ()
forMFromZero_ !endN f =
($ 0) $ fix $ \loop !n -> if n < endN then f n *> loop (succ n) else pure ()
2015-11-21 09:57:44 +03:00
{-# INLINE strictCons #-}
strictCons :: a -> [a] -> [a]
strictCons !a b =
let !c = a : b in c
2017-11-26 11:24:40 +03:00
{-# INLINE mapLeft #-}
mapLeft :: (a -> c) -> Either a b -> Either c b
mapLeft f =
either (Left . f) Right