-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | safe PostgreSQL queries using Quasiquoters -- -- Before you Post(gres)QL, preql. -- -- preql provides a low-level interface to PostgreSQL and a -- quasiquoter that converts inline variable names to SQL parameters. -- Higher-level interfaces, checking SQL syntax & schema, are -- planned. -- -- the quickstart or the vision -- -- Most applications will want to import the top-level module -- Preql. When writing SQL instances or your own -- higher-level abstractions, you may want the lower-level, IO-specific -- functions in Preql.Wire, not all of which are re-exported -- from Preql. @package preql @version 0.3 -- | Common imports, so I don't need to repeat them everywhere module Preql.Imports -- | A type f is a Functor if it provides a function fmap -- which, given any types a and b lets you apply any -- function from (a -> b) to turn an f a into an -- f b, preserving the structure of f. Furthermore -- f needs to adhere to the following: -- -- -- -- Note, that the second law follows from the free theorem of the type -- fmap and the first law, so you need only check that the former -- condition holds. class Functor (f :: Type -> Type) -- | Using ApplicativeDo: 'fmap f as' can be -- understood as the do expression -- --
--   do a <- as
--      pure (f a)
--   
-- -- with an inferred Functor constraint. fmap :: Functor f => (a -> b) -> f a -> f b -- | Replace all locations in the input with the same value. The default -- definition is fmap . const, but this may be -- overridden with a more efficient version. -- -- Using ApplicativeDo: 'a <$ bs' can be -- understood as the do expression -- --
--   do bs
--      pure a
--   
-- -- with an inferred Functor constraint. (<$) :: Functor f => a -> f b -> f a infixl 4 <$ -- | The class Typeable allows a concrete representation of a type -- to be calculated. class Typeable (a :: k) -- | A functor with application, providing operations to -- -- -- -- A minimal complete definition must include implementations of -- pure and of either <*> or liftA2. If it -- defines both, then they must behave the same as their default -- definitions: -- --
--   (<*>) = liftA2 id
--   
-- --
--   liftA2 f x y = f <$> x <*> y
--   
-- -- Further, any definition must satisfy the following: -- -- -- -- The other methods have the following default definitions, which may be -- overridden with equivalent specialized implementations: -- -- -- -- As a consequence of these laws, the Functor instance for -- f will satisfy -- -- -- -- It may be useful to note that supposing -- --
--   forall x y. p (q x y) = f x . g y
--   
-- -- it follows from the above that -- --
--   liftA2 p (liftA2 q u v) = liftA2 f u . liftA2 g v
--   
-- -- If f is also a Monad, it should satisfy -- -- -- -- (which implies that pure and <*> satisfy the -- applicative functor laws). class Functor f => Applicative (f :: Type -> Type) -- | Lift a value. pure :: Applicative f => a -> f a -- | Sequential application. -- -- A few functors support an implementation of <*> that is -- more efficient than the default one. -- -- Using ApplicativeDo: 'fs <*> as' can be -- understood as the do expression -- --
--   do f <- fs
--      a <- as
--      pure (f a)
--   
(<*>) :: Applicative f => f (a -> b) -> f a -> f b -- | Lift a binary function to actions. -- -- Some functors support an implementation of liftA2 that is more -- efficient than the default one. In particular, if fmap is an -- expensive operation, it is likely better to use liftA2 than to -- fmap over the structure and then use <*>. -- -- This became a typeclass method in 4.10.0.0. Prior to that, it was a -- function defined in terms of <*> and fmap. -- -- Using ApplicativeDo: 'liftA2 f as bs' can be -- understood as the do expression -- --
--   do a <- as
--      b <- bs
--      pure (f a b)
--   
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c -- | Sequence actions, discarding the value of the first argument. -- -- 'as *> bs' can be understood as the do -- expression -- --
--   do as
--      bs
--   
-- -- This is a tad complicated for our ApplicativeDo extension -- which will give it a Monad constraint. For an -- Applicative constraint we write it of the form -- --
--   do _ <- as
--      b <- bs
--      pure b
--   
(*>) :: Applicative f => f a -> f b -> f b -- | Sequence actions, discarding the value of the second argument. -- -- Using ApplicativeDo: 'as <* bs' can be -- understood as the do expression -- --
--   do a <- as
--      bs
--      pure a
--   
(<*) :: Applicative f => f a -> f b -> f a infixl 4 <* infixl 4 *> infixl 4 <*> -- | Functors representing data structures that can be traversed from left -- to right. -- -- A definition of traverse must satisfy the following laws: -- -- -- -- A definition of sequenceA must satisfy the following laws: -- -- -- -- where an applicative transformation is a function -- --
--   t :: (Applicative f, Applicative g) => f a -> g a
--   
-- -- preserving the Applicative operations, i.e. -- --
--   t (pure x) = pure x
--   t (f <*> x) = t f <*> t x
--   
-- -- and the identity functor Identity and composition functors -- Compose are from Data.Functor.Identity and -- Data.Functor.Compose. -- -- A result of the naturality law is a purity law for traverse -- --
--   traverse pure = pure
--   
-- -- (The naturality law is implied by parametricity and thus so is the -- purity law [1, p15].) -- -- Instances are similar to Functor, e.g. given a data type -- --
--   data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
--   
-- -- a suitable instance would be -- --
--   instance Traversable Tree where
--      traverse f Empty = pure Empty
--      traverse f (Leaf x) = Leaf <$> f x
--      traverse f (Node l k r) = Node <$> traverse f l <*> f k <*> traverse f r
--   
-- -- This is suitable even for abstract types, as the laws for -- <*> imply a form of associativity. -- -- The superclass instances should satisfy the following: -- -- -- -- References: [1] The Essence of the Iterator Pattern, Jeremy Gibbons -- and Bruno C. d. S. Oliveira class (Functor t, Foldable t) => Traversable (t :: Type -> Type) -- | Map each element of a structure to an action, evaluate these actions -- from left to right, and collect the results. For a version that -- ignores the results see traverse_. traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) -- | Evaluate each action in the structure from left to right, and collect -- the results. For a version that ignores the results see -- sequenceA_. sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a) -- | Map each element of a structure to a monadic action, evaluate these -- actions from left to right, and collect the results. For a version -- that ignores the results see mapM_. mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) -- | Evaluate each monadic action in the structure from left to right, and -- collect the results. For a version that ignores the results see -- sequence_. sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) data TyCon -- | A bifunctor is a type constructor that takes two type arguments and is -- a functor in both arguments. That is, unlike with -- Functor, a type constructor such as Either does not need -- to be partially applied for a Bifunctor instance, and the -- methods in this class permit mapping functions over the Left -- value or the Right value, or both at the same time. -- -- Formally, the class Bifunctor represents a bifunctor from -- Hask -> Hask. -- -- Intuitively it is a bifunctor where both the first and second -- arguments are covariant. -- -- You can define a Bifunctor by either defining bimap or -- by defining both first and second. -- -- If you supply bimap, you should ensure that: -- --
--   bimap id idid
--   
-- -- If you supply first and second, ensure: -- --
--   first idid
--   second idid
--   
-- -- If you supply both, you should also ensure: -- --
--   bimap f g ≡ first f . second g
--   
-- -- These ensure by parametricity: -- --
--   bimap  (f . g) (h . i) ≡ bimap f h . bimap g i
--   first  (f . g) ≡ first  f . first  g
--   second (f . g) ≡ second f . second g
--   
class Bifunctor (p :: Type -> Type -> Type) -- | Map over both arguments at the same time. -- --
--   bimap f g ≡ first f . second g
--   
-- --

Examples

-- --
--   >>> bimap toUpper (+1) ('j', 3)
--   ('J',4)
--   
-- --
--   >>> bimap toUpper (+1) (Left 'j')
--   Left 'J'
--   
-- --
--   >>> bimap toUpper (+1) (Right 3)
--   Right 4
--   
bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d -- | Map covariantly over the first argument. -- --
--   first f ≡ bimap f id
--   
-- --

Examples

-- --
--   >>> first toUpper ('j', 3)
--   ('J',3)
--   
-- --
--   >>> first toUpper (Left 'j')
--   Left 'J'
--   
first :: Bifunctor p => (a -> b) -> p a c -> p b c -- | Map covariantly over the second argument. -- --
--   secondbimap id
--   
-- --

Examples

-- --
--   >>> second (+1) ('j', 3)
--   ('j',4)
--   
-- --
--   >>> second (+1) (Right 3)
--   Right 4
--   
second :: Bifunctor p => (b -> c) -> p a b -> p a c -- | Monads in which IO computations may be embedded. Any monad -- built by applying a sequence of monad transformers to the IO -- monad will be an instance of this class. -- -- Instances should satisfy the following laws, which state that -- liftIO is a transformer of monads: -- -- class Monad m => MonadIO (m :: Type -> Type) -- | Lift a computation from the IO monad. liftIO :: MonadIO m => IO a -> m a -- | This function may be used as a value for foldMap in a -- Foldable instance. -- --
--   foldMapDefault f ≡ getConst . traverse (Const . f)
--   
foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m -- | This function may be used as a value for fmap in a -- Functor instance, provided that traverse is defined. -- (Using fmapDefault with a Traversable instance defined -- only by sequenceA will result in infinite recursion.) -- --
--   fmapDefault f ≡ runIdentity . traverse (Identity . f)
--   
fmapDefault :: Traversable t => (a -> b) -> t a -> t b -- | The mapAccumR function behaves like a combination of -- fmap and foldr; it applies a function to each element of -- a structure, passing an accumulating parameter from right to left, and -- returning a final value of this accumulator together with the new -- structure. mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c) -- | The mapAccumL function behaves like a combination of -- fmap and foldl; it applies a function to each element of -- a structure, passing an accumulating parameter from left to right, and -- returning a final value of this accumulator together with the new -- structure. mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c) -- | forM is mapM with its arguments flipped. For a version -- that ignores the results see forM_. forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b) -- | for is traverse with its arguments flipped. For a -- version that ignores the results see for_. for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b) -- | One or none. optional :: Alternative f => f a -> f (Maybe a) newtype WrappedMonad (m :: Type -> Type) a WrapMonad :: m a -> WrappedMonad (m :: Type -> Type) a [unwrapMonad] :: WrappedMonad (m :: Type -> Type) a -> m a newtype WrappedArrow (a :: Type -> Type -> Type) b c WrapArrow :: a b c -> WrappedArrow (a :: Type -> Type -> Type) b c [unwrapArrow] :: WrappedArrow (a :: Type -> Type -> Type) b c -> a b c -- | Lists, but with an Applicative functor based on zipping. newtype ZipList a ZipList :: [a] -> ZipList a [getZipList] :: ZipList a -> [a] -- | Any type that you wish to throw or catch as an exception must be an -- instance of the Exception class. The simplest case is a new -- exception type directly below the root: -- --
--   data MyException = ThisException | ThatException
--       deriving Show
--   
--   instance Exception MyException
--   
-- -- The default method definitions in the Exception class do what -- we need in this case. You can now throw and catch -- ThisException and ThatException as exceptions: -- --
--   *Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
--   Caught ThisException
--   
-- -- In more complicated examples, you may wish to define a whole hierarchy -- of exceptions: -- --
--   ---------------------------------------------------------------------
--   -- Make the root exception type for all the exceptions in a compiler
--   
--   data SomeCompilerException = forall e . Exception e => SomeCompilerException e
--   
--   instance Show SomeCompilerException where
--       show (SomeCompilerException e) = show e
--   
--   instance Exception SomeCompilerException
--   
--   compilerExceptionToException :: Exception e => e -> SomeException
--   compilerExceptionToException = toException . SomeCompilerException
--   
--   compilerExceptionFromException :: Exception e => SomeException -> Maybe e
--   compilerExceptionFromException x = do
--       SomeCompilerException a <- fromException x
--       cast a
--   
--   ---------------------------------------------------------------------
--   -- Make a subhierarchy for exceptions in the frontend of the compiler
--   
--   data SomeFrontendException = forall e . Exception e => SomeFrontendException e
--   
--   instance Show SomeFrontendException where
--       show (SomeFrontendException e) = show e
--   
--   instance Exception SomeFrontendException where
--       toException = compilerExceptionToException
--       fromException = compilerExceptionFromException
--   
--   frontendExceptionToException :: Exception e => e -> SomeException
--   frontendExceptionToException = toException . SomeFrontendException
--   
--   frontendExceptionFromException :: Exception e => SomeException -> Maybe e
--   frontendExceptionFromException x = do
--       SomeFrontendException a <- fromException x
--       cast a
--   
--   ---------------------------------------------------------------------
--   -- Make an exception type for a particular frontend compiler exception
--   
--   data MismatchedParentheses = MismatchedParentheses
--       deriving Show
--   
--   instance Exception MismatchedParentheses where
--       toException   = frontendExceptionToException
--       fromException = frontendExceptionFromException
--   
-- -- We can now catch a MismatchedParentheses exception as -- MismatchedParentheses, SomeFrontendException or -- SomeCompilerException, but not other types, e.g. -- IOException: -- --
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
--   Caught MismatchedParentheses
--   *Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
--   *** Exception: MismatchedParentheses
--   
class (Typeable e, Show e) => Exception e typeOf7 :: Typeable t => t a b c d e f g -> TypeRep typeOf6 :: Typeable t => t a b c d e f -> TypeRep typeOf5 :: Typeable t => t a b c d e -> TypeRep typeOf4 :: Typeable t => t a b c d -> TypeRep typeOf3 :: Typeable t => t a b c -> TypeRep typeOf2 :: Typeable t => t a b -> TypeRep typeOf1 :: Typeable t => t a -> TypeRep -- | Force a TypeRep to normal form. rnfTypeRep :: TypeRep -> () -- | Takes a value of type a and returns a concrete representation -- of that type. typeRepFingerprint :: TypeRep -> Fingerprint -- | Observe the type constructor of a quantified type representation. typeRepTyCon :: TypeRep -> TyCon -- | Observe the argument types of a type representation typeRepArgs :: TypeRep -> [TypeRep] -- | Splits a type constructor application. Note that if the type -- constructor is polymorphic, this will not return the kinds that were -- used. splitTyConApp :: TypeRep -> (TyCon, [TypeRep]) -- | Build a function type. mkFunTy :: TypeRep -> TypeRep -> TypeRep -- | Applies a type to a function type. Returns: Just u if the -- first argument represents a function of type t -> u and -- the second argument represents a function of type t. -- Otherwise, returns Nothing. funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep -- | Cast over k1 -> k2 -> k3 gcast2 :: forall k1 k2 k3 c (t :: k2 -> k3 -> k1) (t' :: k2 -> k3 -> k1) (a :: k2) (b :: k3). (Typeable t, Typeable t') => c (t a b) -> Maybe (c (t' a b)) -- | Cast over k1 -> k2 gcast1 :: forall k1 k2 c (t :: k2 -> k1) (t' :: k2 -> k1) (a :: k2). (Typeable t, Typeable t') => c (t a) -> Maybe (c (t' a)) -- | A flexible variation parameterised in a type constructor gcast :: forall k (a :: k) (b :: k) c. (Typeable a, Typeable b) => c a -> Maybe (c b) -- | Extract a witness of equality of two types eqT :: forall k (a :: k) (b :: k). (Typeable a, Typeable b) => Maybe (a :~: b) -- | The type-safe cast operation cast :: (Typeable a, Typeable b) => a -> Maybe b -- | Show a type representation showsTypeRep :: TypeRep -> ShowS -- | Takes a value of type a and returns a concrete representation -- of that type. typeRep :: forall k proxy (a :: k). Typeable a => proxy a -> TypeRep -- | Observe a type representation for the type of a value. typeOf :: Typeable a => a -> TypeRep -- | A quantified type representation. type TypeRep = SomeTypeRep rnfTyCon :: TyCon -> () tyConFingerprint :: TyCon -> Fingerprint tyConName :: TyCon -> String tyConModule :: TyCon -> String tyConPackage :: TyCon -> String -- | The Const functor. newtype Const a (b :: k) Const :: a -> Const a (b :: k) [getConst] :: Const a (b :: k) -> a -- | Proxy is a type that holds no data, but has a phantom parameter -- of arbitrary type (or even kind). Its use is to provide type -- information, even though there is no value available of that type (or -- it may be too costly to create one). -- -- Historically, Proxy :: Proxy a is a safer -- alternative to the undefined :: a idiom. -- --
--   >>> Proxy :: Proxy (Void, Int -> Int)
--   Proxy
--   
-- -- Proxy can even hold types of higher kinds, -- --
--   >>> Proxy :: Proxy Either
--   Proxy
--   
-- --
--   >>> Proxy :: Proxy Functor
--   Proxy
--   
-- --
--   >>> Proxy :: Proxy complicatedStructure
--   Proxy
--   
data Proxy (t :: k) Proxy :: Proxy (t :: k) -- | Propositional equality. If a :~: b is inhabited by some -- terminating value, then the type a is the same as the type -- b. To use this equality in practice, pattern-match on the -- a :~: b to get out the Refl constructor; in the body -- of the pattern-match, the compiler knows that a ~ b. data (a :: k) :~: (b :: k) [Refl] :: forall k (a :: k). a :~: a infix 4 :~: -- | Kind heterogeneous propositional equality. Like :~:, a :~~: -- b is inhabited by a terminating value if and only if a -- is the same type as b. data (a :: k1) :~~: (b :: k2) [HRefl] :: forall k1 (a :: k1). a :~~: a infix 4 :~~: -- | The catMaybes function takes a list of Maybes and -- returns a list of all the Just values. -- --

Examples

-- -- Basic usage: -- --
--   >>> catMaybes [Just 1, Nothing, Just 3]
--   [1,3]
--   
-- -- When constructing a list of Maybe values, catMaybes can -- be used to return all of the "success" results (if the list is the -- result of a map, then mapMaybe would be more -- appropriate): -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
--   [Just 1,Nothing,Just 3]
--   
--   >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
--   [1,3]
--   
catMaybes :: [Maybe a] -> [a] -- | The fromMaybe function takes a default value and and -- Maybe value. If the Maybe is Nothing, it returns -- the default values; otherwise, it returns the value contained in the -- Maybe. -- --

Examples

-- -- Basic usage: -- --
--   >>> fromMaybe "" (Just "Hello, World!")
--   "Hello, World!"
--   
-- --
--   >>> fromMaybe "" Nothing
--   ""
--   
-- -- Read an integer from a string using readMaybe. If we fail to -- parse an integer, we want to return 0 by default: -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> fromMaybe 0 (readMaybe "5")
--   5
--   
--   >>> fromMaybe 0 (readMaybe "")
--   0
--   
fromMaybe :: a -> Maybe a -> a -- | void value discards or ignores the result of -- evaluation, such as the return value of an IO action. -- -- Using ApplicativeDo: 'void as' can be -- understood as the do expression -- --
--   do as
--      pure ()
--   
-- -- with an inferred Functor constraint. -- --

Examples

-- -- Replace the contents of a Maybe Int with unit: -- --
--   >>> void Nothing
--   Nothing
--   
--   >>> void (Just 3)
--   Just ()
--   
-- -- Replace the contents of an Either Int -- Int with unit, resulting in an Either -- Int (): -- --
--   >>> void (Left 8675309)
--   Left 8675309
--   
--   >>> void (Right 8675309)
--   Right ()
--   
-- -- Replace every element of a list with unit: -- --
--   >>> void [1,2,3]
--   [(),(),()]
--   
-- -- Replace the second element of a pair with unit: -- --
--   >>> void (1,2)
--   (1,())
--   
-- -- Discard the result of an IO action: -- --
--   >>> mapM print [1,2]
--   1
--   2
--   [(),()]
--   
--   >>> void $ mapM print [1,2]
--   1
--   2
--   
void :: Functor f => f a -> f () -- | Flipped version of <$. -- -- Using ApplicativeDo: 'as $> b' can be -- understood as the do expression -- --
--   do as
--      pure b
--   
-- -- with an inferred Functor constraint. -- --

Examples

-- -- Replace the contents of a Maybe Int with a -- constant String: -- --
--   >>> Nothing $> "foo"
--   Nothing
--   
--   >>> Just 90210 $> "foo"
--   Just "foo"
--   
-- -- Replace the contents of an Either Int -- Int with a constant String, resulting in an -- Either Int String: -- --
--   >>> Left 8675309 $> "foo"
--   Left 8675309
--   
--   >>> Right 8675309 $> "foo"
--   Right "foo"
--   
-- -- Replace each element of a list with a constant String: -- --
--   >>> [1,2,3] $> "foo"
--   ["foo","foo","foo"]
--   
-- -- Replace the second element of a pair with a constant String: -- --
--   >>> (1,2) $> "foo"
--   (1,"foo")
--   
($>) :: Functor f => f a -> b -> f b infixl 4 $> -- | Flipped version of <$>. -- --
--   (<&>) = flip fmap
--   
-- --

Examples

-- -- Apply (+1) to a list, a Just and a Right: -- --
--   >>> Just 2 <&> (+1)
--   Just 3
--   
-- --
--   >>> [1,2,3] <&> (+1)
--   [2,3,4]
--   
-- --
--   >>> Right 3 <&> (+1)
--   Right 4
--   
(<&>) :: Functor f => f a -> (a -> b) -> f b infixl 1 <&> -- | An infix synonym for fmap. -- -- The name of this operator is an allusion to $. Note the -- similarities between their types: -- --
--    ($)  ::              (a -> b) ->   a ->   b
--   (<$>) :: Functor f => (a -> b) -> f a -> f b
--   
-- -- Whereas $ is function application, <$> is function -- application lifted over a Functor. -- --

Examples

-- -- Convert from a Maybe Int to a Maybe -- String using show: -- --
--   >>> show <$> Nothing
--   Nothing
--   
--   >>> show <$> Just 3
--   Just "3"
--   
-- -- Convert from an Either Int Int to an -- Either Int String using show: -- --
--   >>> show <$> Left 17
--   Left 17
--   
--   >>> show <$> Right 17
--   Right "17"
--   
-- -- Double each element of a list: -- --
--   >>> (*2) <$> [1,2,3]
--   [2,4,6]
--   
-- -- Apply even to the second element of a pair: -- --
--   >>> even <$> (2,2)
--   (2,True)
--   
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 <$> -- | Lift a ternary function to actions. -- -- Using ApplicativeDo: 'liftA3 f as bs cs' can -- be understood as the do expression -- --
--   do a <- as
--      b <- bs
--      c <- cs
--      pure (f a b c)
--   
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d -- | Lift a function to actions. This function may be used as a value for -- fmap in a Functor instance. -- -- | Using ApplicativeDo: 'liftA f as' can be -- understood as the do expression -- --
--   do a <- as
--      pure (f a)
--   
-- -- with an inferred Functor constraint, weaker than -- Applicative. liftA :: Applicative f => (a -> b) -> f a -> f b -- | A variant of <*> with the arguments reversed. -- -- Using ApplicativeDo: 'as <**> fs' can -- be understood as the do expression -- --
--   do a <- as
--      f <- fs
--      pure (f a)
--   
(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 <**> -- | A monoid on applicative functors. -- -- If defined, some and many should be the least solutions -- of the equations: -- -- class Applicative f => Alternative (f :: Type -> Type) -- | The identity of <|> empty :: Alternative f => f a -- | An associative binary operation (<|>) :: Alternative f => f a -> f a -> f a -- | One or more. some :: Alternative f => f a -> f [a] -- | Zero or more. many :: Alternative f => f a -> f [a] infixl 3 <|> -- | Decode a ByteString containing UTF-8 encoded text. -- -- NOTE: The replacement character returned by -- OnDecodeError MUST be within the BMP plane; surrogate code -- points will automatically be remapped to the replacement char -- U+FFFD (since 0.11.3.0), whereas code points beyond -- the BMP will throw an error (since 1.2.3.1); For earlier -- versions of text using those unsupported code points would -- result in undefined behavior. decodeUtf8With :: OnDecodeError -> ByteString -> Text -- | Replace an invalid input byte with the Unicode replacement character -- U+FFFD. lenientDecode :: OnDecodeError -- | Boxed vectors, supporting efficient slicing. data Vector a -- | A space efficient, packed, unboxed Unicode text type. data Text -- | A space-efficient representation of a Word8 vector, supporting -- many efficient operations. -- -- A ByteString contains 8-bit bytes, or by using the operations -- from Data.ByteString.Char8 it can be interpreted as containing -- 8-bit characters. data ByteString module Preql.QuasiQuoter.Raw.Lex quickIndex :: Array Int (AlexAcc (Any :: Type)) -> Int -> AlexAcc (Any :: Type) data AlexReturn a AlexEOF :: AlexReturn a AlexError :: !AlexInput -> AlexReturn a AlexSkip :: !AlexInput -> !Int -> AlexReturn a AlexToken :: !AlexInput -> !Int -> a -> AlexReturn a alexScan :: (AlexPosn, Char, [Byte], String) -> Int -> AlexReturn (AlexAction LocToken) alexScanUser :: t -> (AlexPosn, Char, [Byte], String) -> Int -> AlexReturn (AlexAction LocToken) alex_scan_tkn :: t1 -> t2 -> Int# -> AlexInput -> Int# -> AlexLastAcc -> (AlexLastAcc, (AlexPosn, Char, [Byte], String)) data AlexLastAcc AlexNone :: AlexLastAcc AlexLastAcc :: !Int -> !AlexInput -> !Int -> AlexLastAcc AlexLastSkip :: !AlexInput -> !Int -> AlexLastAcc data AlexAcc user AlexAccNone :: AlexAcc user AlexAcc :: Int -> AlexAcc user AlexAccSkip :: AlexAcc user data LocToken LocToken :: AlexPosn -> Token -> LocToken [loc] :: LocToken -> AlexPosn [unLoc] :: LocToken -> Token data Token Sql :: String -> Token NumberedParam :: Word -> Token HaskellParam :: String -> Token EOF :: Token data AlexUserState AlexUserState :: FilePath -> AlexUserState [filePath] :: AlexUserState -> FilePath alexInitUserState :: AlexUserState getFilePath :: Alex FilePath setFilePath :: FilePath -> Alex () unLex :: Token -> String lex' :: (String -> Token) -> AlexAction LocToken alexMonadScan' :: Alex LocToken alexEOF :: Alex LocToken alexError' :: AlexPosn -> String -> Alex a runAlex' :: Alex a -> FilePath -> String -> Either String a lexAll :: Alex [LocToken] parseQuery' :: FilePath -> String -> Either String [LocToken] parseQuery :: FilePath -> String -> Either String [Token] alex_action_0 :: AlexAction LocToken alex_action_1 :: AlexAction LocToken alex_action_2 :: AlexAction LocToken data AlexAddr AlexA# :: Addr# -> AlexAddr alexIndexInt16OffAddr :: AlexAddr -> Int# -> Int# alexIndexInt32OffAddr :: AlexAddr -> Int# -> Int# -- | Encode a Haskell String to a list of Word8 values, in UTF8 format. utf8Encode :: Char -> [Word8] utf8Encode' :: Char -> (Word8, [Word8]) type Byte = Word8 type AlexInput = (AlexPosn, Char, [Byte], String) ignorePendingBytes :: AlexInput -> AlexInput alexInputPrevChar :: AlexInput -> Char alexGetByte :: AlexInput -> Maybe (Byte, AlexInput) data AlexPosn AlexPn :: !Int -> !Int -> !Int -> AlexPosn alexStartPos :: AlexPosn alexMove :: AlexPosn -> Char -> AlexPosn data AlexState AlexState :: !AlexPosn -> String -> !Char -> [Byte] -> !Int -> AlexUserState -> AlexState [alex_pos] :: AlexState -> !AlexPosn [alex_inp] :: AlexState -> String [alex_chr] :: AlexState -> !Char [alex_bytes] :: AlexState -> [Byte] [alex_scd] :: AlexState -> !Int [alex_ust] :: AlexState -> AlexUserState runAlex :: String -> Alex a -> Either String a newtype Alex a Alex :: (AlexState -> Either String (AlexState, a)) -> Alex a [unAlex] :: Alex a -> AlexState -> Either String (AlexState, a) alexGetInput :: Alex AlexInput alexSetInput :: AlexInput -> Alex () alexError :: String -> Alex a alexGetStartCode :: Alex Int alexSetStartCode :: Int -> Alex () alexGetUserState :: Alex AlexUserState alexSetUserState :: AlexUserState -> Alex () alexMonadScan :: Alex LocToken type AlexAction result = AlexInput -> Int -> Alex result skip :: p1 -> p2 -> Alex LocToken begin :: Int -> p1 -> p2 -> Alex LocToken andBegin :: AlexAction result -> Int -> AlexAction result token :: (AlexInput -> Int -> token) -> AlexAction token alex_tab_size :: Int alex_base :: AlexAddr alex_table :: AlexAddr alex_check :: AlexAddr alex_deflt :: AlexAddr alex_accept :: Array Int (AlexAcc user) alex_actions :: Array Int (AlexAction LocToken) instance GHC.Show.Show Preql.QuasiQuoter.Raw.Lex.AlexPosn instance GHC.Classes.Eq Preql.QuasiQuoter.Raw.Lex.AlexPosn instance GHC.Classes.Ord Preql.QuasiQuoter.Raw.Lex.Token instance GHC.Classes.Eq Preql.QuasiQuoter.Raw.Lex.Token instance GHC.Show.Show Preql.QuasiQuoter.Raw.Lex.Token instance GHC.Show.Show Preql.QuasiQuoter.Raw.Lex.LocToken instance GHC.Base.Functor Preql.QuasiQuoter.Raw.Lex.Alex instance GHC.Base.Applicative Preql.QuasiQuoter.Raw.Lex.Alex instance GHC.Base.Monad Preql.QuasiQuoter.Raw.Lex.Alex -- | Orphan instances module Preql.Wire.Orphans instance Data.Aeson.Types.ToJSON.ToJSON Database.PostgreSQL.LibPQ.Oid instance Data.Aeson.Types.FromJSON.FromJSON Database.PostgreSQL.LibPQ.Oid -- | Errors raised by functions in Preql.Wire module Preql.Wire.Errors -- | Errors that can occur in decoding a single field. data UnlocatedFieldError UnexpectedNull :: UnlocatedFieldError ParseFailure :: Text -> UnlocatedFieldError -- | A decoding error with information about the row & column of the -- result where it occured. data FieldError FieldError :: Int -> Int -> UnlocatedFieldError -> FieldError [errorRow] :: FieldError -> Int [errorColumn] :: FieldError -> Int [failure] :: FieldError -> UnlocatedFieldError data PgType -- | A Postgres type with a known ID Oid :: Oid -> PgType -- | A Postgres type which we will need to lookup by name TypeName :: Text -> PgType data TypeMismatch TypeMismatch :: PgType -> Oid -> Int -> Maybe Text -> TypeMismatch [expected] :: TypeMismatch -> PgType [actual] :: TypeMismatch -> Oid [column] :: TypeMismatch -> Int [columnName] :: TypeMismatch -> Maybe Text data QueryError ConnectionError :: Text -> QueryError DecoderError :: FieldError -> QueryError PgTypeMismatch :: [TypeMismatch] -> QueryError instance Data.Aeson.Types.ToJSON.ToJSON Preql.Wire.Errors.QueryError instance Data.Aeson.Types.FromJSON.FromJSON Preql.Wire.Errors.QueryError instance GHC.Show.Show Preql.Wire.Errors.QueryError instance GHC.Classes.Eq Preql.Wire.Errors.QueryError instance GHC.Exception.Type.Exception Preql.Wire.Errors.QueryError instance Data.Aeson.Types.ToJSON.ToJSON Preql.Wire.Errors.TypeMismatch instance Data.Aeson.Types.FromJSON.FromJSON Preql.Wire.Errors.TypeMismatch instance GHC.Show.Show Preql.Wire.Errors.TypeMismatch instance GHC.Classes.Eq Preql.Wire.Errors.TypeMismatch instance Data.Aeson.Types.ToJSON.ToJSON Preql.Wire.Errors.PgType instance Data.Aeson.Types.FromJSON.FromJSON Preql.Wire.Errors.PgType instance GHC.Show.Show Preql.Wire.Errors.PgType instance GHC.Classes.Eq Preql.Wire.Errors.PgType instance Data.Aeson.Types.ToJSON.ToJSON Preql.Wire.Errors.FieldError instance Data.Aeson.Types.FromJSON.FromJSON Preql.Wire.Errors.FieldError instance GHC.Show.Show Preql.Wire.Errors.FieldError instance GHC.Classes.Eq Preql.Wire.Errors.FieldError instance GHC.Exception.Type.Exception Preql.Wire.Errors.FieldError instance Data.Aeson.Types.ToJSON.ToJSON Preql.Wire.Errors.UnlocatedFieldError instance Data.Aeson.Types.FromJSON.FromJSON Preql.Wire.Errors.UnlocatedFieldError instance GHC.Show.Show Preql.Wire.Errors.UnlocatedFieldError instance GHC.Classes.Eq Preql.Wire.Errors.UnlocatedFieldError -- | The types in this module have invariants which cannot be checked if -- their constructors are in scope. Preql.Wire exports the type names -- only. module Preql.Wire.Internal -- | The IsString instance does no validation; the limited instances -- discourage directly manipulating strings, with the high risk of SQL -- injection. newtype Query Query :: ByteString -> Query -- | RowDecoder is Applicative but not Monad so that -- we can assemble all of the OIDs before we read any of the field data -- sent by Postgres. data RowDecoder a RowDecoder :: [PgType] -> InternalDecoder a -> RowDecoder a -- | Internal because we need IO for the libpq FFI, but we promise not to -- do any IO besides decoding. We don't even make network calls to -- Postgres in InternalDecoder type InternalDecoder = StateT DecoderState (ExceptT FieldError IO) data DecoderState DecoderState :: Result -> Row -> Column -> DecoderState [$sel:result:DecoderState] :: DecoderState -> Result [$sel:row:DecoderState] :: DecoderState -> Row [$sel:column:DecoderState] :: DecoderState -> Column decodeRow :: RowDecoder a -> Result -> Row -> ExceptT FieldError IO a getNextValue :: InternalDecoder (Maybe ByteString) instance Data.String.IsString Preql.Wire.Internal.Query instance GHC.Show.Show Preql.Wire.Internal.Query instance GHC.Classes.Eq Preql.Wire.Internal.DecoderState instance GHC.Show.Show Preql.Wire.Internal.DecoderState instance GHC.Base.Functor Preql.Wire.Internal.RowDecoder instance GHC.Base.Applicative Preql.Wire.Internal.RowDecoder -- | Template Haskell macros to generate tuple instances for FromSql & -- ToSql module Preql.Wire.Tuples alphabet :: [String] deriveFromSqlTuple :: Int -> Q [Dec] deriveToSqlTuple :: Int -> Q [Dec] module Preql.Wire.TypeInfo.Types -- | A structure representing some of the metadata regarding a PostgreSQL -- type, mostly taken from the pg_type table. data TypeInfo Basic :: {-# UNPACK #-} !Oid -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> !ByteString -> TypeInfo [typoid] :: TypeInfo -> {-# UNPACK #-} !Oid [typcategory] :: TypeInfo -> {-# UNPACK #-} !Char [typdelim] :: TypeInfo -> {-# UNPACK #-} !Char [typname] :: TypeInfo -> !ByteString Array :: {-# UNPACK #-} !Oid -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> !ByteString -> !TypeInfo -> TypeInfo [typoid] :: TypeInfo -> {-# UNPACK #-} !Oid [typcategory] :: TypeInfo -> {-# UNPACK #-} !Char [typdelim] :: TypeInfo -> {-# UNPACK #-} !Char [typname] :: TypeInfo -> !ByteString [typelem] :: TypeInfo -> !TypeInfo Range :: {-# UNPACK #-} !Oid -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> !ByteString -> !TypeInfo -> TypeInfo [typoid] :: TypeInfo -> {-# UNPACK #-} !Oid [typcategory] :: TypeInfo -> {-# UNPACK #-} !Char [typdelim] :: TypeInfo -> {-# UNPACK #-} !Char [typname] :: TypeInfo -> !ByteString [rngsubtype] :: TypeInfo -> !TypeInfo Composite :: {-# UNPACK #-} !Oid -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> !ByteString -> {-# UNPACK #-} !Oid -> !Vector Attribute -> TypeInfo [typoid] :: TypeInfo -> {-# UNPACK #-} !Oid [typcategory] :: TypeInfo -> {-# UNPACK #-} !Char [typdelim] :: TypeInfo -> {-# UNPACK #-} !Char [typname] :: TypeInfo -> !ByteString [typrelid] :: TypeInfo -> {-# UNPACK #-} !Oid [attributes] :: TypeInfo -> !Vector Attribute data Attribute Attribute :: !ByteString -> !TypeInfo -> Attribute [attname] :: Attribute -> !ByteString [atttype] :: Attribute -> !TypeInfo instance GHC.Show.Show Preql.Wire.TypeInfo.Types.TypeInfo instance GHC.Show.Show Preql.Wire.TypeInfo.Types.Attribute -- | This module contains portions of the pg_type table that are -- relevant to postgresql-simple and are believed to not change between -- PostgreSQL versions. module Preql.Wire.TypeInfo.Static -- | A structure representing some of the metadata regarding a PostgreSQL -- type, mostly taken from the pg_type table. data TypeInfo Basic :: {-# UNPACK #-} !Oid -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> !ByteString -> TypeInfo [typoid] :: TypeInfo -> {-# UNPACK #-} !Oid [typcategory] :: TypeInfo -> {-# UNPACK #-} !Char [typdelim] :: TypeInfo -> {-# UNPACK #-} !Char [typname] :: TypeInfo -> !ByteString Array :: {-# UNPACK #-} !Oid -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> !ByteString -> !TypeInfo -> TypeInfo [typoid] :: TypeInfo -> {-# UNPACK #-} !Oid [typcategory] :: TypeInfo -> {-# UNPACK #-} !Char [typdelim] :: TypeInfo -> {-# UNPACK #-} !Char [typname] :: TypeInfo -> !ByteString [typelem] :: TypeInfo -> !TypeInfo Range :: {-# UNPACK #-} !Oid -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> !ByteString -> !TypeInfo -> TypeInfo [typoid] :: TypeInfo -> {-# UNPACK #-} !Oid [typcategory] :: TypeInfo -> {-# UNPACK #-} !Char [typdelim] :: TypeInfo -> {-# UNPACK #-} !Char [typname] :: TypeInfo -> !ByteString [rngsubtype] :: TypeInfo -> !TypeInfo Composite :: {-# UNPACK #-} !Oid -> {-# UNPACK #-} !Char -> {-# UNPACK #-} !Char -> !ByteString -> {-# UNPACK #-} !Oid -> !Vector Attribute -> TypeInfo [typoid] :: TypeInfo -> {-# UNPACK #-} !Oid [typcategory] :: TypeInfo -> {-# UNPACK #-} !Char [typdelim] :: TypeInfo -> {-# UNPACK #-} !Char [typname] :: TypeInfo -> !ByteString [typrelid] :: TypeInfo -> {-# UNPACK #-} !Oid [attributes] :: TypeInfo -> !Vector Attribute staticTypeInfo :: Oid -> Maybe TypeInfo bool :: TypeInfo boolOid :: Oid bytea :: TypeInfo byteaOid :: Oid char :: TypeInfo charOid :: Oid name :: TypeInfo nameOid :: Oid int8 :: TypeInfo int8Oid :: Oid int2 :: TypeInfo int2Oid :: Oid int4 :: TypeInfo int4Oid :: Oid regproc :: TypeInfo regprocOid :: Oid text :: TypeInfo textOid :: Oid oid :: TypeInfo oidOid :: Oid tid :: TypeInfo tidOid :: Oid xid :: TypeInfo xidOid :: Oid cid :: TypeInfo cidOid :: Oid xml :: TypeInfo xmlOid :: Oid point :: TypeInfo pointOid :: Oid lseg :: TypeInfo lsegOid :: Oid path :: TypeInfo pathOid :: Oid box :: TypeInfo boxOid :: Oid polygon :: TypeInfo polygonOid :: Oid line :: TypeInfo lineOid :: Oid cidr :: TypeInfo cidrOid :: Oid float4 :: TypeInfo float4Oid :: Oid float8 :: TypeInfo float8Oid :: Oid unknown :: TypeInfo unknownOid :: Oid circle :: TypeInfo circleOid :: Oid money :: TypeInfo moneyOid :: Oid macaddr :: TypeInfo macaddrOid :: Oid inet :: TypeInfo inetOid :: Oid bpchar :: TypeInfo bpcharOid :: Oid varchar :: TypeInfo varcharOid :: Oid date :: TypeInfo dateOid :: Oid time :: TypeInfo timeOid :: Oid timestamp :: TypeInfo timestampOid :: Oid timestamptz :: TypeInfo timestamptzOid :: Oid interval :: TypeInfo intervalOid :: Oid timetz :: TypeInfo timetzOid :: Oid bit :: TypeInfo bitOid :: Oid varbit :: TypeInfo varbitOid :: Oid numeric :: TypeInfo numericOid :: Oid refcursor :: TypeInfo refcursorOid :: Oid record :: TypeInfo recordOid :: Oid void :: TypeInfo voidOid :: Oid array_record :: TypeInfo array_recordOid :: Oid regprocedure :: TypeInfo regprocedureOid :: Oid regoper :: TypeInfo regoperOid :: Oid regoperator :: TypeInfo regoperatorOid :: Oid regclass :: TypeInfo regclassOid :: Oid regtype :: TypeInfo regtypeOid :: Oid uuid :: TypeInfo uuidOid :: Oid json :: TypeInfo jsonOid :: Oid jsonb :: TypeInfo jsonbOid :: Oid int2vector :: TypeInfo int2vectorOid :: Oid oidvector :: TypeInfo oidvectorOid :: Oid array_xml :: TypeInfo array_xmlOid :: Oid array_json :: TypeInfo array_jsonOid :: Oid array_line :: TypeInfo array_lineOid :: Oid array_cidr :: TypeInfo array_cidrOid :: Oid array_circle :: TypeInfo array_circleOid :: Oid array_money :: TypeInfo array_moneyOid :: Oid array_bool :: TypeInfo array_boolOid :: Oid array_bytea :: TypeInfo array_byteaOid :: Oid array_char :: TypeInfo array_charOid :: Oid array_name :: TypeInfo array_nameOid :: Oid array_int2 :: TypeInfo array_int2Oid :: Oid array_int2vector :: TypeInfo array_int2vectorOid :: Oid array_int4 :: TypeInfo array_int4Oid :: Oid array_regproc :: TypeInfo array_regprocOid :: Oid array_text :: TypeInfo array_textOid :: Oid array_tid :: TypeInfo array_tidOid :: Oid array_xid :: TypeInfo array_xidOid :: Oid array_cid :: TypeInfo array_cidOid :: Oid array_oidvector :: TypeInfo array_oidvectorOid :: Oid array_bpchar :: TypeInfo array_bpcharOid :: Oid array_varchar :: TypeInfo array_varcharOid :: Oid array_int8 :: TypeInfo array_int8Oid :: Oid array_point :: TypeInfo array_pointOid :: Oid array_lseg :: TypeInfo array_lsegOid :: Oid array_path :: TypeInfo array_pathOid :: Oid array_box :: TypeInfo array_boxOid :: Oid array_float4 :: TypeInfo array_float4Oid :: Oid array_float8 :: TypeInfo array_float8Oid :: Oid array_polygon :: TypeInfo array_polygonOid :: Oid array_oid :: TypeInfo array_oidOid :: Oid array_macaddr :: TypeInfo array_macaddrOid :: Oid array_inet :: TypeInfo array_inetOid :: Oid array_timestamp :: TypeInfo array_timestampOid :: Oid array_date :: TypeInfo array_dateOid :: Oid array_time :: TypeInfo array_timeOid :: Oid array_timestamptz :: TypeInfo array_timestamptzOid :: Oid array_interval :: TypeInfo array_intervalOid :: Oid array_numeric :: TypeInfo array_numericOid :: Oid array_timetz :: TypeInfo array_timetzOid :: Oid array_bit :: TypeInfo array_bitOid :: Oid array_varbit :: TypeInfo array_varbitOid :: Oid array_refcursor :: TypeInfo array_refcursorOid :: Oid array_regprocedure :: TypeInfo array_regprocedureOid :: Oid array_regoper :: TypeInfo array_regoperOid :: Oid array_regoperator :: TypeInfo array_regoperatorOid :: Oid array_regclass :: TypeInfo array_regclassOid :: Oid array_regtype :: TypeInfo array_regtypeOid :: Oid array_uuid :: TypeInfo array_uuidOid :: Oid array_jsonb :: TypeInfo array_jsonbOid :: Oid int4range :: TypeInfo int4rangeOid :: Oid _int4range :: TypeInfo _int4rangeOid :: Oid numrange :: TypeInfo numrangeOid :: Oid _numrange :: TypeInfo _numrangeOid :: Oid tsrange :: TypeInfo tsrangeOid :: Oid _tsrange :: TypeInfo _tsrangeOid :: Oid tstzrange :: TypeInfo tstzrangeOid :: Oid _tstzrange :: TypeInfo _tstzrangeOid :: Oid daterange :: TypeInfo daterangeOid :: Oid _daterange :: TypeInfo _daterangeOid :: Oid int8range :: TypeInfo int8rangeOid :: Oid _int8range :: TypeInfo _int8rangeOid :: Oid module Preql.Wire.Types data TimeTZ TimeTZ :: !TimeOfDay -> !TimeZone -> TimeTZ instance GHC.Classes.Eq Preql.Wire.Types.TimeTZ instance GHC.Show.Show Preql.Wire.Types.TimeTZ module Preql.Wire.ToSql -- | A FieldEncoder for a type a consists of a function -- from a to it's binary representation, and an Postgres OID -- which tells Postgres it's type & how to decode it. data FieldEncoder a FieldEncoder :: Oid -> (a -> Builder) -> FieldEncoder a runFieldEncoder :: FieldEncoder p -> p -> (Oid, ByteString) type RowEncoder a = a -> [(Oid, ByteString)] runEncoder :: RowEncoder p -> p -> [Maybe (Oid, ByteString, Format)] oneField :: FieldEncoder a -> RowEncoder a -- | Types which can be encoded to a single Postgres field. class ToSqlField a toSqlField :: ToSqlField a => FieldEncoder a -- | ToSql a is sufficient to pass a as parameters to a -- paramaterized query. class ToSql a toSql :: ToSql a => RowEncoder a toSqlJsonField :: ToJSON a => FieldEncoder a instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q, Preql.Wire.ToSql.ToSqlField r, Preql.Wire.ToSql.ToSqlField s, Preql.Wire.ToSql.ToSqlField t, Preql.Wire.ToSql.ToSqlField u, Preql.Wire.ToSql.ToSqlField v, Preql.Wire.ToSql.ToSqlField w, Preql.Wire.ToSql.ToSqlField x, Preql.Wire.ToSql.ToSqlField y) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q, Preql.Wire.ToSql.ToSqlField r, Preql.Wire.ToSql.ToSqlField s, Preql.Wire.ToSql.ToSqlField t, Preql.Wire.ToSql.ToSqlField u, Preql.Wire.ToSql.ToSqlField v, Preql.Wire.ToSql.ToSqlField w, Preql.Wire.ToSql.ToSqlField x) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q, Preql.Wire.ToSql.ToSqlField r, Preql.Wire.ToSql.ToSqlField s, Preql.Wire.ToSql.ToSqlField t, Preql.Wire.ToSql.ToSqlField u, Preql.Wire.ToSql.ToSqlField v, Preql.Wire.ToSql.ToSqlField w) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q, Preql.Wire.ToSql.ToSqlField r, Preql.Wire.ToSql.ToSqlField s, Preql.Wire.ToSql.ToSqlField t, Preql.Wire.ToSql.ToSqlField u, Preql.Wire.ToSql.ToSqlField v) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q, Preql.Wire.ToSql.ToSqlField r, Preql.Wire.ToSql.ToSqlField s, Preql.Wire.ToSql.ToSqlField t, Preql.Wire.ToSql.ToSqlField u) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q, Preql.Wire.ToSql.ToSqlField r, Preql.Wire.ToSql.ToSqlField s, Preql.Wire.ToSql.ToSqlField t) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q, Preql.Wire.ToSql.ToSqlField r, Preql.Wire.ToSql.ToSqlField s) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q, Preql.Wire.ToSql.ToSqlField r) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p, Preql.Wire.ToSql.ToSqlField q) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o, Preql.Wire.ToSql.ToSqlField p) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n, Preql.Wire.ToSql.ToSqlField o) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m, Preql.Wire.ToSql.ToSqlField n) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l, Preql.Wire.ToSql.ToSqlField m) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l, m) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k, Preql.Wire.ToSql.ToSqlField l) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k, l) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j, Preql.Wire.ToSql.ToSqlField k) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j, k) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i, Preql.Wire.ToSql.ToSqlField j) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i, j) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h, Preql.Wire.ToSql.ToSqlField i) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h, i) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g, Preql.Wire.ToSql.ToSqlField h) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g, h) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f, Preql.Wire.ToSql.ToSqlField g) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f, g) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e, Preql.Wire.ToSql.ToSqlField f) => Preql.Wire.ToSql.ToSql (a, b, c, d, e, f) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d, Preql.Wire.ToSql.ToSqlField e) => Preql.Wire.ToSql.ToSql (a, b, c, d, e) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c, Preql.Wire.ToSql.ToSqlField d) => Preql.Wire.ToSql.ToSql (a, b, c, d) instance Preql.Wire.ToSql.ToSql GHC.Types.Bool instance Preql.Wire.ToSql.ToSql GHC.Int.Int16 instance Preql.Wire.ToSql.ToSql GHC.Int.Int32 instance Preql.Wire.ToSql.ToSql GHC.Int.Int64 instance Preql.Wire.ToSql.ToSql GHC.Types.Float instance Preql.Wire.ToSql.ToSql GHC.Types.Double instance Preql.Wire.ToSql.ToSql GHC.Types.Char instance Preql.Wire.ToSql.ToSql GHC.Base.String instance Preql.Wire.ToSql.ToSql Data.Text.Internal.Text instance Preql.Wire.ToSql.ToSql Data.Text.Internal.Lazy.Text instance Preql.Wire.ToSql.ToSql Data.ByteString.Internal.ByteString instance Preql.Wire.ToSql.ToSql Data.ByteString.Lazy.Internal.ByteString instance Preql.Wire.ToSql.ToSql Data.Time.Clock.Internal.UTCTime.UTCTime instance Preql.Wire.ToSql.ToSql Data.Time.Calendar.Days.Day instance Preql.Wire.ToSql.ToSql Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay instance Preql.Wire.ToSql.ToSql Preql.Wire.Types.TimeTZ instance Preql.Wire.ToSql.ToSql Data.UUID.Types.Internal.UUID instance Preql.Wire.ToSql.ToSql Data.Aeson.Types.Internal.Value instance Preql.Wire.ToSql.ToSql () instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b) => Preql.Wire.ToSql.ToSql (a, b) instance (Preql.Wire.ToSql.ToSqlField a, Preql.Wire.ToSql.ToSqlField b, Preql.Wire.ToSql.ToSqlField c) => Preql.Wire.ToSql.ToSql (a, b, c) instance Preql.Wire.ToSql.ToSqlField GHC.Types.Bool instance Preql.Wire.ToSql.ToSqlField GHC.Int.Int16 instance Preql.Wire.ToSql.ToSqlField GHC.Int.Int32 instance Preql.Wire.ToSql.ToSqlField GHC.Int.Int64 instance Preql.Wire.ToSql.ToSqlField GHC.Types.Float instance Preql.Wire.ToSql.ToSqlField GHC.Types.Double instance Preql.Wire.ToSql.ToSqlField GHC.Types.Char instance Preql.Wire.ToSql.ToSqlField GHC.Base.String instance Preql.Wire.ToSql.ToSqlField Data.Text.Internal.Text instance Preql.Wire.ToSql.ToSqlField Data.Text.Internal.Lazy.Text instance Preql.Wire.ToSql.ToSqlField Data.ByteString.Internal.ByteString instance Preql.Wire.ToSql.ToSqlField Data.ByteString.Lazy.Internal.ByteString instance Preql.Wire.ToSql.ToSqlField Data.Time.Clock.Internal.UTCTime.UTCTime instance Preql.Wire.ToSql.ToSqlField Data.Time.Calendar.Days.Day instance Preql.Wire.ToSql.ToSqlField Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay instance Preql.Wire.ToSql.ToSqlField Preql.Wire.Types.TimeTZ instance Preql.Wire.ToSql.ToSqlField Data.UUID.Types.Internal.UUID instance Preql.Wire.ToSql.ToSqlField Data.Aeson.Types.Internal.Value instance Data.Functor.Contravariant.Contravariant Preql.Wire.ToSql.FieldEncoder -- | Decoding values from Postgres wire format to Haskell. module Preql.Wire.FromSql -- | A FieldDecoder for a type a consists of an OID -- indicating the Postgres type which can be decoded, and a parser from -- the binary representation of that type to the Haskell representation. data FieldDecoder a FieldDecoder :: PgType -> BinaryParser a -> FieldDecoder a throwLocated :: UnlocatedFieldError -> InternalDecoder a decodeVector :: (PgType -> IO (Either QueryError Oid)) -> RowDecoder a -> Result -> IO (Either QueryError (Vector a)) notNull :: FieldDecoder a -> RowDecoder a nullable :: FieldDecoder a -> RowDecoder (Maybe a) class FromSqlField a fromSqlField :: FromSqlField a => FieldDecoder a class FromSql a fromSql :: FromSql a => RowDecoder a fromSqlJsonField :: FromJSON a => FieldDecoder a instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q, Preql.Wire.FromSql.FromSql r, Preql.Wire.FromSql.FromSql s, Preql.Wire.FromSql.FromSql t, Preql.Wire.FromSql.FromSql u, Preql.Wire.FromSql.FromSql v, Preql.Wire.FromSql.FromSql w, Preql.Wire.FromSql.FromSql x, Preql.Wire.FromSql.FromSql y) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q, Preql.Wire.FromSql.FromSql r, Preql.Wire.FromSql.FromSql s, Preql.Wire.FromSql.FromSql t, Preql.Wire.FromSql.FromSql u, Preql.Wire.FromSql.FromSql v, Preql.Wire.FromSql.FromSql w, Preql.Wire.FromSql.FromSql x) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q, Preql.Wire.FromSql.FromSql r, Preql.Wire.FromSql.FromSql s, Preql.Wire.FromSql.FromSql t, Preql.Wire.FromSql.FromSql u, Preql.Wire.FromSql.FromSql v, Preql.Wire.FromSql.FromSql w) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q, Preql.Wire.FromSql.FromSql r, Preql.Wire.FromSql.FromSql s, Preql.Wire.FromSql.FromSql t, Preql.Wire.FromSql.FromSql u, Preql.Wire.FromSql.FromSql v) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q, Preql.Wire.FromSql.FromSql r, Preql.Wire.FromSql.FromSql s, Preql.Wire.FromSql.FromSql t, Preql.Wire.FromSql.FromSql u) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q, Preql.Wire.FromSql.FromSql r, Preql.Wire.FromSql.FromSql s, Preql.Wire.FromSql.FromSql t) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q, Preql.Wire.FromSql.FromSql r, Preql.Wire.FromSql.FromSql s) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q, Preql.Wire.FromSql.FromSql r) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p, Preql.Wire.FromSql.FromSql q) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o, Preql.Wire.FromSql.FromSql p) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n, Preql.Wire.FromSql.FromSql o) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m, Preql.Wire.FromSql.FromSql n) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l, Preql.Wire.FromSql.FromSql m) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l, m) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k, Preql.Wire.FromSql.FromSql l) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k, l) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j, Preql.Wire.FromSql.FromSql k) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j, k) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i, Preql.Wire.FromSql.FromSql j) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i, j) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h, Preql.Wire.FromSql.FromSql i) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h, i) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g, Preql.Wire.FromSql.FromSql h) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g, h) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f, Preql.Wire.FromSql.FromSql g) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f, g) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e, Preql.Wire.FromSql.FromSql f) => Preql.Wire.FromSql.FromSql (a, b, c, d, e, f) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d, Preql.Wire.FromSql.FromSql e) => Preql.Wire.FromSql.FromSql (a, b, c, d, e) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c, Preql.Wire.FromSql.FromSql d) => Preql.Wire.FromSql.FromSql (a, b, c, d) instance GHC.Base.Functor Preql.Wire.FromSql.FieldDecoder instance Preql.Wire.FromSql.FromSql GHC.Types.Bool instance Preql.Wire.FromSql.FromSql GHC.Int.Int16 instance Preql.Wire.FromSql.FromSql GHC.Int.Int32 instance Preql.Wire.FromSql.FromSql GHC.Int.Int64 instance Preql.Wire.FromSql.FromSql GHC.Types.Float instance Preql.Wire.FromSql.FromSql GHC.Types.Double instance Preql.Wire.FromSql.FromSql GHC.Base.String instance Preql.Wire.FromSql.FromSql Data.Text.Internal.Text instance Preql.Wire.FromSql.FromSql Data.Text.Internal.Lazy.Text instance Preql.Wire.FromSql.FromSql Data.ByteString.Internal.ByteString instance Preql.Wire.FromSql.FromSql Data.ByteString.Lazy.Internal.ByteString instance Preql.Wire.FromSql.FromSql Data.Time.Clock.Internal.UTCTime.UTCTime instance Preql.Wire.FromSql.FromSql Data.Time.Calendar.Days.Day instance Preql.Wire.FromSql.FromSql Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay instance Preql.Wire.FromSql.FromSql Preql.Wire.Types.TimeTZ instance Preql.Wire.FromSql.FromSql Data.UUID.Types.Internal.UUID instance Preql.Wire.FromSql.FromSql Database.PostgreSQL.LibPQ.Oid instance Preql.Wire.FromSql.FromSql Data.Aeson.Types.Internal.Value instance Preql.Wire.FromSql.FromSqlField a => Preql.Wire.FromSql.FromSql (GHC.Maybe.Maybe a) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b) => Preql.Wire.FromSql.FromSql (a, b) instance (Preql.Wire.FromSql.FromSql a, Preql.Wire.FromSql.FromSql b, Preql.Wire.FromSql.FromSql c) => Preql.Wire.FromSql.FromSql (a, b, c) instance Preql.Wire.FromSql.FromSqlField GHC.Types.Bool instance Preql.Wire.FromSql.FromSqlField GHC.Int.Int16 instance Preql.Wire.FromSql.FromSqlField GHC.Int.Int32 instance Preql.Wire.FromSql.FromSqlField GHC.Int.Int64 instance Preql.Wire.FromSql.FromSqlField GHC.Types.Float instance Preql.Wire.FromSql.FromSqlField GHC.Types.Double instance Preql.Wire.FromSql.FromSqlField GHC.Base.String instance Preql.Wire.FromSql.FromSqlField Data.Text.Internal.Text instance Preql.Wire.FromSql.FromSqlField Data.Text.Internal.Lazy.Text instance Preql.Wire.FromSql.FromSqlField Data.ByteString.Internal.ByteString instance Preql.Wire.FromSql.FromSqlField Data.ByteString.Lazy.Internal.ByteString instance Preql.Wire.FromSql.FromSqlField Data.Time.Clock.Internal.UTCTime.UTCTime instance Preql.Wire.FromSql.FromSqlField Data.Time.Calendar.Days.Day instance Preql.Wire.FromSql.FromSqlField Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay instance Preql.Wire.FromSql.FromSqlField Preql.Wire.Types.TimeTZ instance Preql.Wire.FromSql.FromSqlField Data.UUID.Types.Internal.UUID instance Preql.Wire.FromSql.FromSqlField Database.PostgreSQL.LibPQ.Oid instance Preql.Wire.FromSql.FromSqlField Data.Aeson.Types.Internal.Value module Preql.Wire.Query queryWith :: RowEncoder p -> RowDecoder r -> Connection -> Query -> p -> IO (Either QueryError (Vector r)) queryWith_ :: RowEncoder p -> Connection -> Query -> p -> IO (Either QueryError ()) execParams :: RowEncoder p -> Connection -> ByteString -> p -> IO (Either QueryError Result) query :: (ToSql p, FromSql r) => Connection -> Query -> p -> IO (Either QueryError (Vector r)) query_ :: ToSql p => Connection -> Query -> p -> IO (Either QueryError ()) connectionError :: Connection -> Maybe a -> IO (Either Text a) lookupType :: Connection -> PgType -> IO (Either QueryError Oid) data IsolationLevel ReadCommitted :: IsolationLevel RepeatableRead :: IsolationLevel Serializable :: IsolationLevel begin :: Connection -> IsolationLevel -> IO (Either QueryError ()) commit :: Connection -> IO (Either QueryError ()) rollback :: Connection -> IO (Either QueryError ()) instance GHC.Enum.Bounded Preql.Wire.Query.IsolationLevel instance GHC.Enum.Enum Preql.Wire.Query.IsolationLevel instance GHC.Classes.Ord Preql.Wire.Query.IsolationLevel instance GHC.Classes.Eq Preql.Wire.Query.IsolationLevel instance GHC.Read.Read Preql.Wire.Query.IsolationLevel instance GHC.Show.Show Preql.Wire.Query.IsolationLevel -- | This module re-exports definitions from Wire.* that are expected to be -- useful module Preql.Wire class FromSql a class FromSqlField a -- | ToSql a is sufficient to pass a as parameters to a -- paramaterized query. class ToSql a -- | Types which can be encoded to a single Postgres field. class ToSqlField a data QueryError ConnectionError :: Text -> QueryError DecoderError :: FieldError -> QueryError PgTypeMismatch :: [TypeMismatch] -> QueryError -- | A decoding error with information about the row & column of the -- result where it occured. data FieldError FieldError :: Int -> Int -> UnlocatedFieldError -> FieldError [errorRow] :: FieldError -> Int [errorColumn] :: FieldError -> Int [failure] :: FieldError -> UnlocatedFieldError -- | Errors that can occur in decoding a single field. data UnlocatedFieldError UnexpectedNull :: UnlocatedFieldError ParseFailure :: Text -> UnlocatedFieldError data TypeMismatch TypeMismatch :: PgType -> Oid -> Int -> Maybe Text -> TypeMismatch [expected] :: TypeMismatch -> PgType [actual] :: TypeMismatch -> Oid [column] :: TypeMismatch -> Int [columnName] :: TypeMismatch -> Maybe Text -- | Errors that can occur in decoding a single field. data UnlocatedFieldError UnexpectedNull :: UnlocatedFieldError ParseFailure :: Text -> UnlocatedFieldError -- | A decoding error with information about the row & column of the -- result where it occured. data FieldError FieldError :: Int -> Int -> UnlocatedFieldError -> FieldError [errorRow] :: FieldError -> Int [errorColumn] :: FieldError -> Int [failure] :: FieldError -> UnlocatedFieldError data PgType -- | A Postgres type with a known ID Oid :: Oid -> PgType -- | A Postgres type which we will need to lookup by name TypeName :: Text -> PgType data TypeMismatch TypeMismatch :: PgType -> Oid -> Int -> Maybe Text -> TypeMismatch [expected] :: TypeMismatch -> PgType [actual] :: TypeMismatch -> Oid [column] :: TypeMismatch -> Int [columnName] :: TypeMismatch -> Maybe Text data QueryError ConnectionError :: Text -> QueryError DecoderError :: FieldError -> QueryError PgTypeMismatch :: [TypeMismatch] -> QueryError -- | RowDecoder is Applicative but not Monad so that -- we can assemble all of the OIDs before we read any of the field data -- sent by Postgres. data RowDecoder a -- | The IsString instance does no validation; the limited instances -- discourage directly manipulating strings, with the high risk of SQL -- injection. data Query data TimeTZ TimeTZ :: !TimeOfDay -> !TimeZone -> TimeTZ -- | ToSql a is sufficient to pass a as parameters to a -- paramaterized query. class ToSql a toSql :: ToSql a => RowEncoder a -- | Types which can be encoded to a single Postgres field. class ToSqlField a toSqlField :: ToSqlField a => FieldEncoder a type RowEncoder a = a -> [(Oid, ByteString)] -- | A FieldEncoder for a type a consists of a function -- from a to it's binary representation, and an Postgres OID -- which tells Postgres it's type & how to decode it. data FieldEncoder a FieldEncoder :: Oid -> (a -> Builder) -> FieldEncoder a runFieldEncoder :: FieldEncoder p -> p -> (Oid, ByteString) runEncoder :: RowEncoder p -> p -> [Maybe (Oid, ByteString, Format)] oneField :: FieldEncoder a -> RowEncoder a toSqlJsonField :: ToJSON a => FieldEncoder a class FromSql a fromSql :: FromSql a => RowDecoder a class FromSqlField a fromSqlField :: FromSqlField a => FieldDecoder a -- | A FieldDecoder for a type a consists of an OID -- indicating the Postgres type which can be decoded, and a parser from -- the binary representation of that type to the Haskell representation. data FieldDecoder a FieldDecoder :: PgType -> BinaryParser a -> FieldDecoder a throwLocated :: UnlocatedFieldError -> InternalDecoder a decodeVector :: (PgType -> IO (Either QueryError Oid)) -> RowDecoder a -> Result -> IO (Either QueryError (Vector a)) notNull :: FieldDecoder a -> RowDecoder a nullable :: FieldDecoder a -> RowDecoder (Maybe a) fromSqlJsonField :: FromJSON a => FieldDecoder a data IsolationLevel ReadCommitted :: IsolationLevel RepeatableRead :: IsolationLevel Serializable :: IsolationLevel module Preql.QuasiQuoter.Raw.TH -- | A list of n Names beginning with the given character cNames :: Char -> Int -> Q [Name] -- | Convert a rewritten SQL string to a ByteString makeQuery :: String -> Q Exp -- | Given a SQL query with ${} antiquotes, splice a pair (Query p r, -- p) or a function p' -> (Query p r, p) if the SQL -- string includes both antiquote and positional parameters. -- -- The sql Quasiquoter allows passing parameters to a query by -- name, inside a ${} antiquote. For example: [sql| SELECT -- name, age FROM cats WHERE age >= ${minAge} and age < ${maxAge} -- |] The Haskell term within {} must be a variable in -- scope; more complex expressions are not supported. -- -- Antiquotes are replaced by positional ($1, $2) parameters -- supported by Postgres, and the encoded values are sent with -- PexecParams -- -- Mixed named & numbered parameters are also supported. It is hoped -- that this will be useful when migrating existing queries. For example: -- query $ [sql| SELECT name, age FROM cats WHERE age >= ${minAge} -- and age < $1 |] maxAge Named parameters will be assigned -- numbers higher than the highest numbered paramater placeholder. -- -- A quote with only named parameters is converted to a tuple '(Query, -- p)'. For example: ("SELECT name, age FROM cats WHERE age >= $1 -- and age < $2", (minAge, maxAge)) If there are no parameters, -- the inner tuple is (), like ("SELECT * FROM cats", -- ()). If there are both named & numbered params, the splice is -- a function taking a tuple and returning (Query, p) where p -- includes both named & numbered params. For example: a -> -- ("SELECT name, age FROM cats WHERE age >= $1 and age < $2", (a, -- maxAge)) sql :: QuasiQuoter tupleOrSingle :: [Name] -> Exp expressionOnly :: String -> (String -> Q Exp) -> QuasiQuoter maxParam :: [Token] -> Word numberAntiquotes :: Word -> [Token] -> (String, [String]) tupleE :: [Exp] -> Exp -- | We use IO in the representation of Transaction, but we don't want to -- allow arbitrary IO, only SQL queries. So keep it private. module Preql.Effect.Internal -- | A Transaction can only contain SQL queries (and pure functions). newtype Transaction a Transaction :: ExceptT QueryError (ReaderT Connection IO) a -> Transaction a instance GHC.Base.Monad Preql.Effect.Internal.Transaction instance GHC.Base.Applicative Preql.Effect.Internal.Transaction instance GHC.Base.Functor Preql.Effect.Internal.Transaction -- | SQL Effect class, basically capturing some way of accessing a -- database. module Preql.Effect -- | SqlQuery is separate from SQL so that nested -- Transactions are statically prevented. query can be -- used directly within any SQL monad (running a single-statement -- transaction), or within a Transaction. -- -- Users should not need to define instances, as every SQL -- instance implies a SqlQuery instance. class Monad m => SqlQuery (m :: * -> *) -- | Run a parameterized query that returns data. The tuple argument is -- typically provided by the sql Quasiquoter. query :: (SqlQuery m, ToSql p, FromSql r) => (Query, p) -> m (Vector r) -- | Run a parameterized query that does not return data. query_ :: (SqlQuery m, ToSql p) => (Query, p) -> m () -- | An Effect class for running SQL queries. You can think of this as a -- context specifying a particular Postgres connection (or connection -- pool). A minimal instance defines withConnection. -- -- Override the remaining methods to log errors before rethrowing, or not -- to rethrow. class SqlQuery m => SQL (m :: * -> *) -- | Run multiple queries in a transaction. runTransaction' :: SQL m => IsolationLevel -> Transaction a -> m a -- | Run multiple queries in a transaction. runTransaction' :: (SQL m, MonadIO m) => IsolationLevel -> Transaction a -> m a -- | runTransaction covers the most common patterns of -- mult-statement transactions. withConnection is useful when -- you want more control, or want to override the defaults that your -- instance defines. For example: - change the number of retries - -- interleave calls to other services with the Postgres transaction - -- ensure a prepared statement is shared among successive transactions withConnection :: SQL m => (Connection -> m a) -> m a -- | Run a query on the specified Connection queryOn :: (SQL m, ToSql p, FromSql r) => Connection -> (Query, p) -> m (Vector r) -- | Run a query on the specified Connection queryOn :: (SQL m, ToSql p, FromSql r, MonadIO m) => Connection -> (Query, p) -> m (Vector r) queryOn_ :: (SQL m, ToSql p) => Connection -> (Query, p) -> m () queryOn_ :: (SQL m, ToSql p, MonadIO m) => Connection -> (Query, p) -> m () -- | Run a Transaction with full Serializable isolation. runTransaction :: SQL m => Transaction a -> m a -- | Run the provided Transaction. If it fails with a -- QueryError, roll back. runTransactionIO :: IsolationLevel -> Transaction a -> Connection -> IO (Either QueryError a) -- | A Transaction can only contain SQL queries (and pure functions). data Transaction a instance Preql.Effect.SQL (Control.Monad.Trans.Reader.ReaderT Database.PostgreSQL.LibPQ.Internal.Connection GHC.Types.IO) instance (GHC.Base.Monad m, Preql.Effect.SQL m) => Preql.Effect.SqlQuery m instance Preql.Effect.SQL m => Preql.Effect.SQL (Control.Monad.Trans.Except.ExceptT e m) instance Preql.Effect.SQL m => Preql.Effect.SQL (Control.Monad.Trans.Reader.ReaderT r m) instance Preql.Effect.SQL m => Preql.Effect.SQL (Control.Monad.Trans.Maybe.MaybeT m) instance Preql.Effect.SQL m => Preql.Effect.SQL (Control.Monad.Trans.State.Lazy.StateT s m) instance Preql.Effect.SQL m => Preql.Effect.SQL (Control.Monad.Trans.State.Strict.StateT s m) instance (GHC.Base.Monoid w, Preql.Effect.SQL m) => Preql.Effect.SQL (Control.Monad.Trans.RWS.Strict.RWST r w s m) instance (GHC.Base.Monoid w, Preql.Effect.SQL m) => Preql.Effect.SQL (Control.Monad.Trans.RWS.Lazy.RWST r w s m) instance Preql.Effect.SqlQuery Preql.Effect.Internal.Transaction module Preql -- | An Effect class for running SQL queries. You can think of this as a -- context specifying a particular Postgres connection (or connection -- pool). A minimal instance defines withConnection. -- -- Override the remaining methods to log errors before rethrowing, or not -- to rethrow. class SqlQuery m => SQL (m :: * -> *) -- | Run multiple queries in a transaction. runTransaction' :: SQL m => IsolationLevel -> Transaction a -> m a -- | Run multiple queries in a transaction. runTransaction' :: (SQL m, MonadIO m) => IsolationLevel -> Transaction a -> m a -- | runTransaction covers the most common patterns of -- mult-statement transactions. withConnection is useful when -- you want more control, or want to override the defaults that your -- instance defines. For example: - change the number of retries - -- interleave calls to other services with the Postgres transaction - -- ensure a prepared statement is shared among successive transactions withConnection :: SQL m => (Connection -> m a) -> m a -- | Run a query on the specified Connection queryOn :: (SQL m, ToSql p, FromSql r) => Connection -> (Query, p) -> m (Vector r) -- | Run a query on the specified Connection queryOn :: (SQL m, ToSql p, FromSql r, MonadIO m) => Connection -> (Query, p) -> m (Vector r) queryOn_ :: (SQL m, ToSql p) => Connection -> (Query, p) -> m () queryOn_ :: (SQL m, ToSql p, MonadIO m) => Connection -> (Query, p) -> m () -- | Given a SQL query with ${} antiquotes, splice a pair (Query p r, -- p) or a function p' -> (Query p r, p) if the SQL -- string includes both antiquote and positional parameters. -- -- The sql Quasiquoter allows passing parameters to a query by -- name, inside a ${} antiquote. For example: [sql| SELECT -- name, age FROM cats WHERE age >= ${minAge} and age < ${maxAge} -- |] The Haskell term within {} must be a variable in -- scope; more complex expressions are not supported. -- -- Antiquotes are replaced by positional ($1, $2) parameters -- supported by Postgres, and the encoded values are sent with -- PexecParams -- -- Mixed named & numbered parameters are also supported. It is hoped -- that this will be useful when migrating existing queries. For example: -- query $ [sql| SELECT name, age FROM cats WHERE age >= ${minAge} -- and age < $1 |] maxAge Named parameters will be assigned -- numbers higher than the highest numbered paramater placeholder. -- -- A quote with only named parameters is converted to a tuple '(Query, -- p)'. For example: ("SELECT name, age FROM cats WHERE age >= $1 -- and age < $2", (minAge, maxAge)) If there are no parameters, -- the inner tuple is (), like ("SELECT * FROM cats", -- ()). If there are both named & numbered params, the splice is -- a function taking a tuple and returning (Query, p) where p -- includes both named & numbered params. For example: a -> -- ("SELECT name, age FROM cats WHERE age >= $1 and age < $2", (a, -- maxAge)) sql :: QuasiQuoter -- | A Transaction can only contain SQL queries (and pure functions). data Transaction a -- | The IsString instance does no validation; the limited instances -- discourage directly manipulating strings, with the high risk of SQL -- injection. data Query -- | Run the provided Transaction. If it fails with a -- QueryError, roll back. runTransactionIO :: IsolationLevel -> Transaction a -> Connection -> IO (Either QueryError a) class FromSql a class FromSqlField a -- | ToSql a is sufficient to pass a as parameters to a -- paramaterized query. class ToSql a -- | Types which can be encoded to a single Postgres field. class ToSqlField a data QueryError ConnectionError :: Text -> QueryError DecoderError :: FieldError -> QueryError PgTypeMismatch :: [TypeMismatch] -> QueryError -- | A decoding error with information about the row & column of the -- result where it occured. data FieldError FieldError :: Int -> Int -> UnlocatedFieldError -> FieldError [errorRow] :: FieldError -> Int [errorColumn] :: FieldError -> Int [failure] :: FieldError -> UnlocatedFieldError -- | Errors that can occur in decoding a single field. data UnlocatedFieldError UnexpectedNull :: UnlocatedFieldError ParseFailure :: Text -> UnlocatedFieldError data TypeMismatch TypeMismatch :: PgType -> Oid -> Int -> Maybe Text -> TypeMismatch [expected] :: TypeMismatch -> PgType [actual] :: TypeMismatch -> Oid [column] :: TypeMismatch -> Int [columnName] :: TypeMismatch -> Maybe Text