2016-08-06 12:22:11 +03:00
|
|
|
module Hasql.Private.Prelude
|
2015-11-08 21:18:59 +03:00
|
|
|
(
|
2014-08-03 17:48:18 +04:00
|
|
|
module Exports,
|
2015-11-08 21:09:42 +03:00
|
|
|
LazyByteString,
|
|
|
|
ByteStringBuilder,
|
|
|
|
LazyText,
|
|
|
|
TextBuilder,
|
|
|
|
bug,
|
|
|
|
bottom,
|
2015-11-20 09:29:46 +03:00
|
|
|
forMToZero_,
|
2015-11-21 12:01:32 +03:00
|
|
|
forMFromZero_,
|
2015-11-21 09:57:44 +03:00
|
|
|
strictCons,
|
2014-08-03 17:48:18 +04:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
|
|
|
|
-- base-prelude
|
|
|
|
-------------------------
|
2017-07-31 09:22:21 +03:00
|
|
|
import BasePrelude as Exports hiding (assert, left, right, isLeft, isRight, fromLeft, fromRight, error, (<>), First(..), Last(..), new)
|
2014-08-03 17:48:18 +04:00
|
|
|
|
2014-11-30 02:39:32 +03:00
|
|
|
-- transformers
|
2014-08-03 17:48:18 +04:00
|
|
|
-------------------------
|
2014-11-30 02:39:32 +03:00
|
|
|
import Control.Monad.IO.Class as Exports
|
2015-11-08 21:09:42 +03:00
|
|
|
import Control.Monad.Trans.Class as Exports
|
|
|
|
import Control.Monad.Trans.Maybe as Exports hiding (liftListen, liftPass)
|
|
|
|
import Control.Monad.Trans.Reader as Exports hiding (liftCallCC, liftCatch)
|
|
|
|
import Control.Monad.Trans.State.Strict as Exports hiding (liftCallCC, liftCatch, liftListen, liftPass)
|
2014-11-30 02:39:32 +03:00
|
|
|
import Data.Functor.Identity as Exports
|
2014-08-03 17:48:18 +04:00
|
|
|
|
2015-12-21 16:45:10 +03:00
|
|
|
-- mtl
|
|
|
|
-------------------------
|
|
|
|
import Control.Monad.Error.Class as Exports (MonadError (..))
|
|
|
|
|
2015-11-08 21:09:42 +03:00
|
|
|
-- data-default-class
|
2014-12-27 04:45:08 +03:00
|
|
|
-------------------------
|
2015-11-08 21:09:42 +03:00
|
|
|
import Data.Default.Class as Exports
|
2014-12-27 04:45:08 +03:00
|
|
|
|
2015-11-08 21:09:42 +03:00
|
|
|
-- profunctors
|
2014-12-27 04:45:08 +03:00
|
|
|
-------------------------
|
2015-11-08 21:09:42 +03:00
|
|
|
import Data.Profunctor.Unsafe as Exports
|
2014-12-27 04:45:08 +03:00
|
|
|
|
2015-11-08 21:09:42 +03:00
|
|
|
-- contravariant
|
2014-10-13 02:21:27 +04:00
|
|
|
-------------------------
|
2015-11-08 21:09:42 +03:00
|
|
|
import Data.Functor.Contravariant as Exports
|
|
|
|
import Data.Functor.Contravariant.Divisible as Exports
|
2014-10-23 20:04:11 +04:00
|
|
|
|
2015-11-09 07:10:40 +03:00
|
|
|
-- contravariant-extras
|
|
|
|
-------------------------
|
|
|
|
import Contravariant.Extras as Exports
|
|
|
|
|
2014-12-27 03:29:36 +03:00
|
|
|
-- either
|
2014-08-05 17:02:08 +04:00
|
|
|
-------------------------
|
2014-12-27 03:29:36 +03:00
|
|
|
import Control.Monad.Trans.Either as Exports
|
2017-07-31 09:22:21 +03:00
|
|
|
import Data.Either.Combinators as Exports
|
2014-10-12 22:32:51 +04:00
|
|
|
|
2016-02-23 09:39:57 +03:00
|
|
|
-- semigroups
|
|
|
|
-------------------------
|
|
|
|
import Data.Semigroup as Exports
|
|
|
|
|
2015-11-08 21:09:42 +03:00
|
|
|
-- hashable
|
2014-08-05 04:07:18 +04:00
|
|
|
-------------------------
|
2015-11-08 21:09:42 +03:00
|
|
|
import Data.Hashable as Exports (Hashable(..))
|
|
|
|
|
|
|
|
-- text
|
|
|
|
-------------------------
|
|
|
|
import Data.Text as Exports (Text)
|
|
|
|
|
|
|
|
-- bytestring
|
|
|
|
-------------------------
|
|
|
|
import Data.ByteString as Exports (ByteString)
|
|
|
|
|
2014-10-25 21:23:53 +04:00
|
|
|
-- vector
|
|
|
|
-------------------------
|
|
|
|
import Data.Vector as Exports (Vector)
|
|
|
|
|
2015-11-08 21:09:42 +03:00
|
|
|
-- dlist
|
2014-08-04 02:36:41 +04:00
|
|
|
-------------------------
|
2015-11-08 21:09:42 +03:00
|
|
|
import Data.DList as Exports (DList)
|
|
|
|
|
|
|
|
-- placeholders
|
|
|
|
-------------------------
|
|
|
|
import Development.Placeholders as Exports
|
|
|
|
|
|
|
|
-- loch-th
|
|
|
|
-------------------------
|
|
|
|
import Debug.Trace.LocationTH as Exports
|
|
|
|
|
|
|
|
-- custom
|
|
|
|
-------------------------
|
|
|
|
import qualified Debug.Trace.LocationTH
|
|
|
|
import qualified Data.Text.Lazy
|
|
|
|
import qualified Data.Text.Lazy.Builder
|
|
|
|
import qualified Data.ByteString.Lazy
|
|
|
|
import qualified Data.ByteString.Builder
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
bug =
|
|
|
|
[e| $(Debug.Trace.LocationTH.failure) . (msg <>) |]
|
|
|
|
where
|
|
|
|
msg = "A \"hasql\" package bug: " :: String
|
|
|
|
|
|
|
|
bottom =
|
|
|
|
[e| $bug "Bottom evaluated" |]
|
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
|