-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An SQL-generating DSL targeting SQLite -- -- An SQL-generating DSL targeting SQLite. Allows SQLite queries to be -- written within Haskell in a typesafe and composable fashion. This -- package is old and unmaintained. It may work, or it may not. If you -- are interested in reviving it please file an issue on the GitHub -- repository. @package opaleye-sqlite @version 0.0.1.1 module Opaleye.SQLite.Internal.HaskellDB.Sql newtype SqlTable SqlTable :: String -> SqlTable newtype SqlColumn SqlColumn :: String -> SqlColumn -- | A valid SQL name for a parameter. type SqlName = String data SqlOrderNulls SqlNullsFirst :: SqlOrderNulls SqlNullsLast :: SqlOrderNulls data SqlOrderDirection SqlAsc :: SqlOrderDirection SqlDesc :: SqlOrderDirection data SqlOrder SqlOrder :: SqlOrderDirection -> SqlOrderNulls -> SqlOrder [sqlOrderDirection] :: SqlOrder -> SqlOrderDirection [sqlOrderNulls] :: SqlOrder -> SqlOrderNulls -- | Expressions in SQL statements. data SqlExpr ColumnSqlExpr :: SqlColumn -> SqlExpr BinSqlExpr :: String -> SqlExpr -> SqlExpr -> SqlExpr PrefixSqlExpr :: String -> SqlExpr -> SqlExpr PostfixSqlExpr :: String -> SqlExpr -> SqlExpr FunSqlExpr :: String -> [SqlExpr] -> SqlExpr -- | Aggregate functions separate from normal functions. AggrFunSqlExpr :: String -> [SqlExpr] -> SqlExpr ConstSqlExpr :: String -> SqlExpr CaseSqlExpr :: [(SqlExpr, SqlExpr)] -> SqlExpr -> SqlExpr ListSqlExpr :: [SqlExpr] -> SqlExpr ParamSqlExpr :: Maybe SqlName -> SqlExpr -> SqlExpr PlaceHolderSqlExpr :: SqlExpr ParensSqlExpr :: SqlExpr -> SqlExpr CastSqlExpr :: String -> SqlExpr -> SqlExpr DefaultSqlExpr :: SqlExpr -- | Data type for SQL UPDATE statements. data SqlUpdate SqlUpdate :: SqlTable -> [(SqlColumn, SqlExpr)] -> [SqlExpr] -> SqlUpdate -- | Data type for SQL DELETE statements. data SqlDelete SqlDelete :: SqlTable -> [SqlExpr] -> SqlDelete data SqlInsert SqlInsert :: SqlTable -> [SqlColumn] -> NonEmpty [SqlExpr] -> SqlInsert instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.Sql.SqlTable instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.Sql.SqlColumn instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.Sql.SqlOrderNulls instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.Sql.SqlOrderDirection instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.Sql.SqlOrder instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.Sql.SqlExpr module Opaleye.SQLite.Internal.HaskellDB.Sql.Print deliteral :: SqlExpr -> SqlExpr ppUpdate :: SqlUpdate -> Doc ppDelete :: SqlDelete -> Doc ppInsert :: SqlInsert -> Doc ppSqlExpr :: SqlExpr -> Doc ppWhere :: [SqlExpr] -> Doc ppGroupBy :: [SqlExpr] -> Doc ppOrderBy :: [(SqlExpr, SqlOrder)] -> Doc ppTable :: SqlTable -> Doc ppAs :: String -> Doc -> Doc commaV :: (a -> Doc) -> [a] -> Doc commaH :: (a -> Doc) -> [a] -> Doc module Opaleye.SQLite.Internal.Helpers (.:) :: (r -> z) -> (a -> b -> r) -> a -> b -> z infixr 8 .: (.:.) :: (r -> z) -> (a -> b -> c -> r) -> a -> b -> c -> z infixr 8 .:. (.::) :: (r -> z) -> (a -> b -> c -> d -> r) -> a -> b -> c -> d -> z infixr 8 .:: (.::.) :: (r -> z) -> (a -> b -> c -> d -> e -> r) -> a -> b -> c -> d -> e -> z infixr 8 .::. module Opaleye.SQLite.Internal.Tag newtype Tag UnsafeTag :: Int -> Tag start :: Tag next :: Tag -> Tag unsafeUnTag :: Tag -> Int tagWith :: Tag -> String -> String instance GHC.Show.Show Opaleye.SQLite.Internal.Tag.Tag instance GHC.Read.Read Opaleye.SQLite.Internal.Tag.Tag module Opaleye.SQLite.Internal.HaskellDB.PrimQuery type TableName = String type Attribute = String type Name = String type Scheme = [Attribute] type Assoc = [(Attribute, PrimExpr)] data Symbol Symbol :: String -> Tag -> Symbol data PrimExpr AttrExpr :: Symbol -> PrimExpr BaseTableAttrExpr :: Attribute -> PrimExpr BinExpr :: BinOp -> PrimExpr -> PrimExpr -> PrimExpr UnExpr :: UnOp -> PrimExpr -> PrimExpr AggrExpr :: AggrOp -> PrimExpr -> PrimExpr ConstExpr :: Literal -> PrimExpr CaseExpr :: [(PrimExpr, PrimExpr)] -> PrimExpr -> PrimExpr ListExpr :: [PrimExpr] -> PrimExpr ParamExpr :: Maybe Name -> PrimExpr -> PrimExpr FunExpr :: Name -> [PrimExpr] -> PrimExpr -- | Cast an expression to a given type. CastExpr :: Name -> PrimExpr -> PrimExpr DefaultInsertExpr :: PrimExpr data Literal NullLit :: Literal -- | represents a default value DefaultLit :: Literal BoolLit :: Bool -> Literal StringLit :: String -> Literal ByteStringLit :: ByteString -> Literal IntegerLit :: Integer -> Literal DoubleLit :: Double -> Literal -- | used for hacking in custom SQL OtherLit :: String -> Literal data BinOp OpEq :: BinOp OpLt :: BinOp OpLtEq :: BinOp OpGt :: BinOp OpGtEq :: BinOp OpNotEq :: BinOp OpAnd :: BinOp OpOr :: BinOp OpLike :: BinOp OpIn :: BinOp OpOther :: String -> BinOp OpCat :: BinOp OpPlus :: BinOp OpMinus :: BinOp OpMul :: BinOp OpDiv :: BinOp OpMod :: BinOp OpBitNot :: BinOp OpBitAnd :: BinOp OpBitOr :: BinOp OpBitXor :: BinOp OpAsg :: BinOp data UnOp OpNot :: UnOp OpIsNull :: UnOp OpIsNotNull :: UnOp OpLength :: UnOp OpAbs :: UnOp OpNegate :: UnOp OpLower :: UnOp OpUpper :: UnOp UnOpOther :: String -> UnOp data AggrOp AggrCount :: AggrOp AggrSum :: AggrOp AggrAvg :: AggrOp AggrMin :: AggrOp AggrMax :: AggrOp AggrStdDev :: AggrOp AggrStdDevP :: AggrOp AggrVar :: AggrOp AggrVarP :: AggrOp AggrBoolOr :: AggrOp AggrBoolAnd :: AggrOp AggrArr :: AggrOp AggrStringAggr :: PrimExpr -> AggrOp AggrOther :: String -> AggrOp data OrderExpr OrderExpr :: OrderOp -> PrimExpr -> OrderExpr data OrderNulls NullsFirst :: OrderNulls NullsLast :: OrderNulls data OrderDirection OpAsc :: OrderDirection OpDesc :: OrderDirection data OrderOp OrderOp :: OrderDirection -> OrderNulls -> OrderOp [orderDirection] :: OrderOp -> OrderDirection [orderNulls] :: OrderOp -> OrderNulls instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.Symbol instance GHC.Read.Read Opaleye.SQLite.Internal.HaskellDB.PrimQuery.Symbol instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.Literal instance GHC.Read.Read Opaleye.SQLite.Internal.HaskellDB.PrimQuery.Literal instance GHC.Read.Read Opaleye.SQLite.Internal.HaskellDB.PrimQuery.BinOp instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.BinOp instance GHC.Read.Read Opaleye.SQLite.Internal.HaskellDB.PrimQuery.UnOp instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.UnOp instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.PrimExpr instance GHC.Read.Read Opaleye.SQLite.Internal.HaskellDB.PrimQuery.PrimExpr instance GHC.Read.Read Opaleye.SQLite.Internal.HaskellDB.PrimQuery.AggrOp instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.AggrOp instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.OrderNulls instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.OrderDirection instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.OrderOp instance GHC.Show.Show Opaleye.SQLite.Internal.HaskellDB.PrimQuery.OrderExpr module Opaleye.SQLite.Internal.PrimQuery data LimitOp LimitOp :: Int -> LimitOp OffsetOp :: Int -> LimitOp LimitOffsetOp :: Int -> Int -> LimitOp data BinOp Except :: BinOp Union :: BinOp UnionAll :: BinOp data JoinType LeftJoin :: JoinType data PrimQuery Unit :: PrimQuery BaseTable :: String -> [(Symbol, PrimExpr)] -> PrimQuery Product :: NonEmpty PrimQuery -> [PrimExpr] -> PrimQuery Aggregate :: [(Symbol, (Maybe AggrOp, PrimExpr))] -> PrimQuery -> PrimQuery Order :: [OrderExpr] -> PrimQuery -> PrimQuery Limit :: LimitOp -> PrimQuery -> PrimQuery Join :: JoinType -> PrimExpr -> PrimQuery -> PrimQuery -> PrimQuery Values :: [Symbol] -> [[PrimExpr]] -> PrimQuery Binary :: BinOp -> [(Symbol, (PrimExpr, PrimExpr))] -> (PrimQuery, PrimQuery) -> PrimQuery type PrimQueryFold p = (p, String -> [(Symbol, PrimExpr)] -> p, NonEmpty p -> [PrimExpr] -> p, [(Symbol, (Maybe AggrOp, PrimExpr))] -> p -> p, [OrderExpr] -> p -> p, LimitOp -> p -> p, JoinType -> PrimExpr -> p -> p -> p, [Symbol] -> [[PrimExpr]] -> p, BinOp -> [(Symbol, (PrimExpr, PrimExpr))] -> (p, p) -> p) foldPrimQuery :: PrimQueryFold p -> PrimQuery -> p times :: PrimQuery -> PrimQuery -> PrimQuery restrict :: PrimExpr -> PrimQuery -> PrimQuery isUnit :: PrimQuery -> Bool instance GHC.Show.Show Opaleye.SQLite.Internal.PrimQuery.LimitOp instance GHC.Show.Show Opaleye.SQLite.Internal.PrimQuery.BinOp instance GHC.Show.Show Opaleye.SQLite.Internal.PrimQuery.JoinType instance GHC.Show.Show Opaleye.SQLite.Internal.PrimQuery.PrimQuery module Opaleye.SQLite.Internal.Optimize optimize :: PrimQuery -> PrimQuery removeUnit :: PrimQuery -> PrimQuery mergeProduct :: PrimQuery -> PrimQuery module Opaleye.SQLite.Internal.PackMap -- | A PackMap a b s t encodes -- how an s contains an updatable sequence of a inside -- it. Each a in the sequence can be updated to a b -- (and the s changes to a t to reflect this change of -- type). -- -- PackMap is just like a Traversal from the lens -- package. PackMap has a different order of arguments to -- Traversal because it typically needs to be made a -- Profunctor (and indeed ProductProfunctor) in s -- and t. It is unclear at this point whether we want the same -- Traversal laws to hold or not. Our use cases may be much more -- general. data PackMap a b s t PackMap :: (forall f. Applicative f => (a -> f b) -> s -> f t) -> PackMap a b s t -- | Replaces the targeted occurences of a in s with -- b (changing the s to a t in the process). -- This can be done via an Applicative action. -- -- traversePM is just like traverse from the -- lens package. traversePM used to be called -- packmap. traversePM :: Applicative f => PackMap a b s t -> (a -> f b) -> s -> f t -- | Modify the targeted occurrences of a in s with -- b (changing the s to a t in the process). -- -- overPM is just like over from the lens -- pacakge. overPM :: PackMap a b s t -> (a -> b) -> s -> t -- | A helpful monad for writing columns in the AST type PM a = State (a, Int) new :: PM a String write :: a -> PM [a] () run :: PM [a] r -> (r, [a]) -- | Make a fresh name for an input value (the variable primExpr -- type is typically actually a PrimExpr) based on the supplied -- function and the unique Tag that is used as part of our -- QueryArr. -- -- Add the fresh name and the input value it refers to to the list in the -- state parameter. extractAttrPE :: (primExpr -> String -> String) -> Tag -> primExpr -> PM [(Symbol, primExpr)] PrimExpr -- | As extractAttrPE but ignores the primExpr when making -- the fresh column name and just uses the supplied String and -- Tag. extractAttr :: String -> Tag -> primExpr -> PM [(Symbol, primExpr)] PrimExpr eitherFunction :: Functor f => (a -> f b) -> (a' -> f b') -> Either a a' -> f (Either b b') instance GHC.Base.Functor (Opaleye.SQLite.Internal.PackMap.PackMap a b s) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.PackMap.PackMap a b s) instance Data.Profunctor.Unsafe.Profunctor (Opaleye.SQLite.Internal.PackMap.PackMap a b) instance Data.Profunctor.Product.Class.ProductProfunctor (Opaleye.SQLite.Internal.PackMap.PackMap a b) instance Data.Profunctor.Product.Class.SumProfunctor (Opaleye.SQLite.Internal.PackMap.PackMap a b) module Opaleye.SQLite.Internal.HaskellDB.Sql.Generate data SqlGenerator SqlGenerator :: (TableName -> [PrimExpr] -> Assoc -> SqlUpdate) -> (TableName -> [PrimExpr] -> SqlDelete) -> (TableName -> [Attribute] -> NonEmpty [PrimExpr] -> SqlInsert) -> (PrimExpr -> SqlExpr) -> (Literal -> String) -> (String -> String) -> SqlGenerator [sqlUpdate] :: SqlGenerator -> TableName -> [PrimExpr] -> Assoc -> SqlUpdate [sqlDelete] :: SqlGenerator -> TableName -> [PrimExpr] -> SqlDelete [sqlInsert] :: SqlGenerator -> TableName -> [Attribute] -> NonEmpty [PrimExpr] -> SqlInsert [sqlExpr] :: SqlGenerator -> PrimExpr -> SqlExpr [sqlLiteral] :: SqlGenerator -> Literal -> String -- | Turn a string into a quoted string. Quote characters and any escaping -- are handled by this function. [sqlQuote] :: SqlGenerator -> String -> String module Opaleye.SQLite.Internal.HaskellDB.Sql.Default mkSqlGenerator :: SqlGenerator -> SqlGenerator defaultSqlGenerator :: SqlGenerator toSqlOrder :: SqlGenerator -> OrderExpr -> (SqlExpr, SqlOrder) toSqlColumn :: Attribute -> SqlColumn toSqlAssoc :: SqlGenerator -> Assoc -> [(SqlColumn, SqlExpr)] defaultSqlUpdate :: SqlGenerator -> TableName -> [PrimExpr] -> Assoc -> SqlUpdate defaultSqlInsert :: SqlGenerator -> TableName -> [Attribute] -> NonEmpty [PrimExpr] -> SqlInsert defaultSqlDelete :: SqlGenerator -> TableName -> [PrimExpr] -> SqlDelete defaultSqlExpr :: SqlGenerator -> PrimExpr -> SqlExpr showBinOp :: BinOp -> String data UnOpType UnOpFun :: UnOpType UnOpPrefix :: UnOpType UnOpPostfix :: UnOpType sqlUnOp :: UnOp -> (String, UnOpType) showAggrOp :: AggrOp -> String defaultSqlLiteral :: SqlGenerator -> Literal -> String defaultSqlQuote :: SqlGenerator -> String -> String quote :: String -> String -- | Escape characters that need escaping FIXME: Escaping control -- characters probably doesn't work in SQLite Need more tests escape :: Char -> String -- | Quote binary literals using Postgresql's hex format. binQuote :: ByteString -> String module Opaleye.SQLite.Internal.Sql data Select SelectFrom :: From -> Select Table :: SqlTable -> Select SelectJoin :: Join -> Select SelectValues :: Values -> Select SelectBinary :: Binary -> Select data SelectAttrs Star :: SelectAttrs SelectAttrs :: NonEmpty (SqlExpr, Maybe SqlColumn) -> SelectAttrs data From From :: SelectAttrs -> [Select] -> [SqlExpr] -> Maybe (NonEmpty SqlExpr) -> [(SqlExpr, SqlOrder)] -> Maybe Int -> Maybe Int -> From [attrs] :: From -> SelectAttrs [tables] :: From -> [Select] [criteria] :: From -> [SqlExpr] [groupBy] :: From -> Maybe (NonEmpty SqlExpr) [orderBy] :: From -> [(SqlExpr, SqlOrder)] [limit] :: From -> Maybe Int [offset] :: From -> Maybe Int data Join Join :: JoinType -> (Select, Select) -> SqlExpr -> Join [jJoinType] :: Join -> JoinType [jTables] :: Join -> (Select, Select) [jCond] :: Join -> SqlExpr data Values Values :: SelectAttrs -> [[SqlExpr]] -> Values [vAttrs] :: Values -> SelectAttrs [vValues] :: Values -> [[SqlExpr]] data Binary Binary :: BinOp -> Select -> Select -> Binary [bOp] :: Binary -> BinOp [bSelect1] :: Binary -> Select [bSelect2] :: Binary -> Select data JoinType LeftJoin :: JoinType data BinOp Except :: BinOp Union :: BinOp UnionAll :: BinOp data TableName String :: TableName data Returning a Returning :: a -> [SqlExpr] -> Returning a sqlQueryGenerator :: PrimQueryFold Select sql :: ([PrimExpr], PrimQuery, Tag) -> Select unit :: Select baseTable :: String -> [(Symbol, PrimExpr)] -> Select product :: NonEmpty Select -> [PrimExpr] -> Select aggregate :: [(Symbol, (Maybe AggrOp, PrimExpr))] -> Select -> Select aggrExpr :: Maybe AggrOp -> PrimExpr -> PrimExpr order :: [OrderExpr] -> Select -> Select limit_ :: LimitOp -> Select -> Select join :: JoinType -> PrimExpr -> Select -> Select -> Select values :: [Symbol] -> [[PrimExpr]] -> Select binary :: BinOp -> [(Symbol, (PrimExpr, PrimExpr))] -> (Select, Select) -> Select joinType :: JoinType -> JoinType binOp :: BinOp -> BinOp newSelect :: From sqlExpr :: PrimExpr -> SqlExpr sqlBinding :: (Symbol, PrimExpr) -> (SqlExpr, Maybe SqlColumn) ensureColumns :: [(SqlExpr, Maybe a)] -> NonEmpty (SqlExpr, Maybe a) instance GHC.Show.Show Opaleye.SQLite.Internal.Sql.SelectAttrs instance GHC.Show.Show Opaleye.SQLite.Internal.Sql.Values instance GHC.Show.Show Opaleye.SQLite.Internal.Sql.JoinType instance GHC.Show.Show Opaleye.SQLite.Internal.Sql.BinOp instance GHC.Show.Show Opaleye.SQLite.Internal.Sql.From instance GHC.Show.Show Opaleye.SQLite.Internal.Sql.Join instance GHC.Show.Show Opaleye.SQLite.Internal.Sql.Select instance GHC.Show.Show Opaleye.SQLite.Internal.Sql.Binary module Opaleye.SQLite.Internal.Print type TableAlias = String ppSql :: Select -> Doc ppSelectFrom :: From -> Doc ppSelectJoin :: Join -> Doc ppSelectValues :: Values -> Doc ppSelectBinary :: Binary -> Doc ppJoinType :: JoinType -> Doc ppAttrs :: SelectAttrs -> Doc nameAs :: (SqlExpr, Maybe SqlColumn) -> Doc ppTables :: [Select] -> Doc tableAlias :: Int -> Select -> (TableAlias, Select) ppTable :: (TableAlias, Select) -> Doc ppGroupBy :: Maybe (NonEmpty SqlExpr) -> Doc ppLimit :: Maybe Int -> Doc ppOffset :: Maybe Int -> Doc ppValues :: [[SqlExpr]] -> Doc ppValuesRow :: [SqlExpr] -> Doc ppBinOp :: BinOp -> Doc ppInsertReturning :: Returning SqlInsert -> Doc ppUpdateReturning :: Returning SqlUpdate -> Doc module Opaleye.SQLite.Internal.Column -- | The Num and Fractional instances for Column -- a are too general. For example, they allow you to add two -- Column Strings. This will be fixed in a subsequent -- release. newtype Column a Column :: PrimExpr -> Column a data Nullable a Nullable :: Nullable a unColumn :: Column a -> PrimExpr -- | Deprecated: Use unsafeCoerceColumn instead unsafeCoerce :: Column a -> Column b unsafeCoerceColumn :: Column a -> Column b binOp :: BinOp -> Column a -> Column b -> Column c unOp :: UnOp -> Column a -> Column b unsafeCase_ :: [(Column pgBool, Column a)] -> Column a -> Column a unsafeIfThenElse :: Column pgBool -> Column a -> Column a -> Column a unsafeGt :: Column a -> Column a -> Column pgBool unsafeEq :: Column a -> Column a -> Column pgBool class PGNum a pgFromInteger :: PGNum a => Integer -> Column a class PGFractional a pgFromRational :: PGFractional a => Rational -> Column a unsafeCast :: String -> Column a -> Column b instance GHC.Show.Show (Opaleye.SQLite.Internal.Column.Column a) instance (Opaleye.SQLite.Internal.Column.PGNum a, Opaleye.SQLite.Internal.Column.PGFractional a) => GHC.Real.Fractional (Opaleye.SQLite.Internal.Column.Column a) instance Opaleye.SQLite.Internal.Column.PGNum a => GHC.Num.Num (Opaleye.SQLite.Internal.Column.Column a) module Opaleye.SQLite.Internal.PGTypes unsafePgFormatTime :: FormatTime t => Name -> String -> t -> Column c literalColumn :: Literal -> Column a castToType :: Name -> String -> Column c strictDecodeUtf8 :: ByteString -> String lazyDecodeUtf8 :: ByteString -> String module Opaleye.SQLite.Internal.Binary extractBinaryFields :: Tag -> (PrimExpr, PrimExpr) -> PM [(Symbol, (PrimExpr, PrimExpr))] PrimExpr newtype Binaryspec columns columns' Binaryspec :: PackMap (PrimExpr, PrimExpr) PrimExpr (columns, columns) columns' -> Binaryspec columns columns' runBinaryspec :: Applicative f => Binaryspec columns columns' -> ((PrimExpr, PrimExpr) -> f PrimExpr) -> (columns, columns) -> f columns' binaryspecColumn :: Binaryspec (Column a) (Column a) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.Binary.Binaryspec (Opaleye.SQLite.Internal.Column.Column a) (Opaleye.SQLite.Internal.Column.Column a) instance GHC.Base.Functor (Opaleye.SQLite.Internal.Binary.Binaryspec a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.Binary.Binaryspec a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.Binary.Binaryspec instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.Binary.Binaryspec module Opaleye.SQLite.Internal.Aggregate -- | An Aggregator takes a collection of rows of type a, -- groups them, and transforms each group into a single row of type -- b. This corresponds to aggregators using GROUP BY in -- SQL. -- -- An Aggregator corresponds closely to a Fold from the -- foldl package. Whereas an Aggregator a -- b takes each group of type a to a single row of type -- b, a Fold a b takes a list of -- a and returns a single row of type b. newtype Aggregator a b Aggregator :: PackMap (Maybe AggrOp, PrimExpr) PrimExpr a b -> Aggregator a b makeAggr' :: Maybe AggrOp -> Aggregator (Column a) (Column b) makeAggr :: AggrOp -> Aggregator (Column a) (Column b) runAggregator :: Applicative f => Aggregator a b -> ((Maybe AggrOp, PrimExpr) -> f PrimExpr) -> a -> f b aggregateU :: Aggregator a b -> (a, PrimQuery, Tag) -> (b, PrimQuery, Tag) extractAggregateFields :: Tag -> (Maybe AggrOp, PrimExpr) -> PM [(Symbol, (Maybe AggrOp, PrimExpr))] PrimExpr instance GHC.Base.Functor (Opaleye.SQLite.Internal.Aggregate.Aggregator a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.Aggregate.Aggregator a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.Aggregate.Aggregator instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.Aggregate.Aggregator instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.SQLite.Internal.Aggregate.Aggregator module Opaleye.SQLite.PGTypes data PGJsonb data PGJson data PGBytea data PGArray a data PGCitext data PGUuid data PGTimestamptz data PGTimestamp data PGTime data PGText data PGNumeric data PGInt2 data PGInt4 data PGInt8 data PGFloat8 data PGFloat4 data PGDate data PGBool -- | Warning: literalColumn has been moved to -- Opaleye.Internal.PGTypes literalColumn :: Literal -> Column a pgString :: String -> Column PGText pgLazyByteString :: ByteString -> Column PGBytea pgStrictByteString :: ByteString -> Column PGBytea pgStrictText :: Text -> Column PGText pgLazyText :: Text -> Column PGText pgInt4 :: Int -> Column PGInt4 pgInt8 :: Int64 -> Column PGInt8 pgDouble :: Double -> Column PGFloat8 pgBool :: Bool -> Column PGBool pgUUID :: UUID -> Column PGUuid -- | Warning: unsafePgFormatTime has been moved to -- Opaleye.Internal.PGTypes unsafePgFormatTime :: FormatTime t => Name -> String -> t -> Column c pgDay :: Day -> Column PGDate pgUTCTime :: UTCTime -> Column PGTimestamptz pgLocalTime :: LocalTime -> Column PGTimestamp pgTimeOfDay :: TimeOfDay -> Column PGTime pgCiStrictText :: CI Text -> Column PGCitext pgCiLazyText :: CI Text -> Column PGCitext pgJSON :: String -> Column PGJson pgStrictJSON :: ByteString -> Column PGJson pgLazyJSON :: ByteString -> Column PGJson pgJSONB :: String -> Column PGJsonb pgStrictJSONB :: ByteString -> Column PGJsonb pgLazyJSONB :: ByteString -> Column PGJsonb instance Opaleye.SQLite.Internal.Column.PGNum Opaleye.SQLite.PGTypes.PGInt4 instance Opaleye.SQLite.Internal.Column.PGNum Opaleye.SQLite.PGTypes.PGInt8 instance Opaleye.SQLite.Internal.Column.PGNum Opaleye.SQLite.PGTypes.PGFloat8 instance Opaleye.SQLite.Internal.Column.PGFractional Opaleye.SQLite.PGTypes.PGFloat8 module Opaleye.SQLite.Column -- | A NULL of any type null :: Column (Nullable a) isNull :: Column (Nullable a) -> Column PGBool -- | If the Column (Nullable a) is NULL then return the Column -- b otherwise map the underlying Column a using the -- provided function. -- -- The Opaleye equivalent of the maybe function. matchNullable :: Column b -> (Column a -> Column b) -> Column (Nullable a) -> Column b -- | If the Column (Nullable a) is NULL then return the provided -- Column a otherwise return the underlying Column a. -- -- The Opaleye equivalent of the fromMaybe function fromNullable :: Column a -> Column (Nullable a) -> Column a -- | The Opaleye equivalent of Just toNullable :: Column a -> Column (Nullable a) -- | If the argument is Nothing return NULL otherwise return the -- provided value coerced to a nullable type. maybeToNullable :: Maybe (Column a) -> Column (Nullable a) -- | Cast a column to any other type. This is safe for some conversions -- such as uuid to text. unsafeCast :: String -> Column a -> Column b -- | The Num and Fractional instances for Column -- a are too general. For example, they allow you to add two -- Column Strings. This will be fixed in a subsequent -- release. data Column a data Nullable a -- | Deprecated: Use unsafeCoerceColumn instead unsafeCoerce :: Column a -> Column b unsafeCoerceColumn :: Column a -> Column b module Opaleye.SQLite.Internal.Unpackspec newtype Unpackspec columns columns' -- | An Unpackspec columns columns' allows you to -- extract and modify a sequence of PrimExprs inside a value of -- type columns. -- -- For example, the Default instance of type Unpackspec -- (Column a, Column b) (Column a, Column b) allows you -- to manipulate or extract the two PrimExprs inside a (Column -- a, Column b). The Default instance of type Foo -- (Column a) (Column b) (Column c) will allow you to manipulate or -- extract the three PrimExprs contained therein (for a -- user-defined product type Foo, assuming the -- makeAdaptorAndInstance splice from -- Data.Profunctor.Product.TH has been run). -- -- You can create Unpackspecs by hand using -- unpackspecColumn and the Profunctor, -- ProductProfunctor and SumProfunctor operations. -- However, in practice users should almost never need to create or -- manipulate them. Typically they will be created automatically by the -- Default instance. Unpackspec :: PackMap PrimExpr PrimExpr columns columns' -> Unpackspec columns columns' -- | Target the single PrimExpr inside a Column unpackspecColumn :: Unpackspec (Column a) (Column a) -- | Modify all the targeted PrimExprs runUnpackspec :: Applicative f => Unpackspec columns b -> (PrimExpr -> f PrimExpr) -> columns -> f b -- | Extract all the targeted PrimExprs collectPEs :: Unpackspec s t -> s -> [PrimExpr] instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.Unpackspec.Unpackspec (Opaleye.SQLite.Internal.Column.Column a) (Opaleye.SQLite.Internal.Column.Column a) instance GHC.Base.Functor (Opaleye.SQLite.Internal.Unpackspec.Unpackspec a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.Unpackspec.Unpackspec a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.Unpackspec.Unpackspec instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.Unpackspec.Unpackspec instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.SQLite.Internal.Unpackspec.Unpackspec module Opaleye.SQLite.Internal.Values valuesU :: Unpackspec columns columns' -> Valuesspec columns columns' -> [columns] -> ((), Tag) -> (columns', PrimQuery, Tag) extractValuesEntry :: PrimExpr -> PM [PrimExpr] PrimExpr extractValuesField :: Tag -> PrimExpr -> PM [(Symbol, PrimExpr)] PrimExpr newtype Valuesspec columns columns' Valuesspec :: PackMap PrimExpr PrimExpr () columns' -> Valuesspec columns columns' runValuesspec :: Applicative f => Valuesspec columns columns' -> (PrimExpr -> f PrimExpr) -> f columns' instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.Values.Valuesspec (Opaleye.SQLite.Internal.Column.Column Opaleye.SQLite.PGTypes.PGInt4) (Opaleye.SQLite.Internal.Column.Column Opaleye.SQLite.PGTypes.PGInt4) instance GHC.Base.Functor (Opaleye.SQLite.Internal.Values.Valuesspec a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.Values.Valuesspec a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.Values.Valuesspec instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.Values.Valuesspec module Opaleye.SQLite.Internal.QueryArr newtype QueryArr a b QueryArr :: ((a, PrimQuery, Tag) -> (b, PrimQuery, Tag)) -> QueryArr a b type Query = QueryArr () simpleQueryArr :: ((a, Tag) -> (b, PrimQuery, Tag)) -> QueryArr a b runQueryArr :: QueryArr a b -> (a, PrimQuery, Tag) -> (b, PrimQuery, Tag) runSimpleQueryArr :: QueryArr a b -> (a, Tag) -> (b, PrimQuery, Tag) runSimpleQueryArrStart :: QueryArr a b -> a -> (b, PrimQuery, Tag) runQueryArrUnpack :: Unpackspec a b -> Query a -> ([PrimExpr], PrimQuery, Tag) first3 :: (a1 -> b) -> (a1, a2, a3) -> (b, a2, a3) instance Control.Category.Category Opaleye.SQLite.Internal.QueryArr.QueryArr instance Control.Arrow.Arrow Opaleye.SQLite.Internal.QueryArr.QueryArr instance GHC.Base.Functor (Opaleye.SQLite.Internal.QueryArr.QueryArr a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.QueryArr.QueryArr a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.QueryArr.QueryArr instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.QueryArr.QueryArr module Opaleye.SQLite.Internal.TableMaker newtype ViewColumnMaker strings columns ViewColumnMaker :: PackMap () () strings columns -> ViewColumnMaker strings columns newtype ColumnMaker columns columns' ColumnMaker :: PackMap PrimExpr PrimExpr columns columns' -> ColumnMaker columns columns' runViewColumnMaker :: ViewColumnMaker strings tablecolumns -> strings -> tablecolumns runColumnMaker :: Applicative f => ColumnMaker tablecolumns columns -> (PrimExpr -> f PrimExpr) -> tablecolumns -> f columns tableColumn :: ViewColumnMaker String (Column a) column :: ColumnMaker (Column a) (Column a) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.TableMaker.ColumnMaker (Opaleye.SQLite.Internal.Column.Column a) (Opaleye.SQLite.Internal.Column.Column a) instance GHC.Base.Functor (Opaleye.SQLite.Internal.TableMaker.ColumnMaker a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.TableMaker.ColumnMaker a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.TableMaker.ColumnMaker instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.TableMaker.ColumnMaker instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.TableMaker.ViewColumnMaker GHC.Base.String (Opaleye.SQLite.Internal.Column.Column a) instance GHC.Base.Functor (Opaleye.SQLite.Internal.TableMaker.ViewColumnMaker a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.TableMaker.ViewColumnMaker a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.TableMaker.ViewColumnMaker instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.TableMaker.ViewColumnMaker module Opaleye.SQLite.Internal.Table data Table writerColumns viewColumns Table :: String -> TableProperties writerColumns viewColumns -> Table writerColumns viewColumns data TableProperties writerColumns viewColumns TableProperties :: Writer writerColumns viewColumns -> View viewColumns -> TableProperties writerColumns viewColumns data View columns View :: columns -> View columns newtype Writer columns dummy Writer :: (forall f. Functor f => PackMap (f PrimExpr, String) () (f columns) ()) -> Writer columns dummy queryTable :: ColumnMaker viewColumns columns -> Table writerColumns viewColumns -> Tag -> (columns, PrimQuery) runColumnMaker :: ColumnMaker tablecolumns columns -> Tag -> tablecolumns -> (columns, [(Symbol, PrimExpr)]) runWriter :: Writer columns columns' -> columns -> [(PrimExpr, String)] runWriter' :: Writer columns columns' -> NonEmpty columns -> (NonEmpty [PrimExpr], [String]) data Zip a Zip :: NonEmpty [a] -> Zip a [unZip] :: Zip a -> NonEmpty [a] required :: String -> Writer (Column a) (Column a) optional :: String -> Writer (Maybe (Column a)) (Column a) instance GHC.Base.Semigroup (Opaleye.SQLite.Internal.Table.Zip a) instance GHC.Base.Monoid (Opaleye.SQLite.Internal.Table.Zip a) instance GHC.Base.Functor (Opaleye.SQLite.Internal.Table.Table a) instance GHC.Base.Functor (Opaleye.SQLite.Internal.Table.TableProperties a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.Table.TableProperties a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.Table.TableProperties instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.Table.TableProperties instance GHC.Base.Functor (Opaleye.SQLite.Internal.Table.Writer a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.Table.Writer a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.Table.Writer instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.Table.Writer module Opaleye.SQLite.Internal.RunQuery -- | A QueryRunnerColumn pgType haskellType -- encodes how to turn a value of Postgres type pgType into a -- value of Haskell type haskellType. For example a value of -- type QueryRunnerColumn PGText String encodes how -- to turn a PGText result from the database into a Haskell -- String. data QueryRunnerColumn sqlType haskellType QueryRunnerColumn :: Unpackspec (Column sqlType) () -> FieldParser haskellType -> QueryRunnerColumn sqlType haskellType data QueryRunner columns haskells -- | Have we actually requested any columns? If we asked for zero columns -- then the SQL generator will have to put a dummy 0 into the SELECT -- statement, since we can't select zero columns. In that case we have to -- make sure we read a single Int. QueryRunner :: Unpackspec columns () -> (columns -> RowParser haskells) -> (columns -> Bool) -> QueryRunner columns haskells fieldQueryRunnerColumn :: FromField haskell => QueryRunnerColumn coltype haskell queryRunner :: QueryRunnerColumn a b -> QueryRunner (Column a) b queryRunnerColumnNullable :: QueryRunnerColumn a b -> QueryRunnerColumn (Nullable a) (Maybe b) -- | A QueryRunnerColumnDefault pgType haskellType -- represents the default way to turn a pgType result from the -- database into a Haskell value of type haskelType. class QueryRunnerColumnDefault pgType haskellType queryRunnerColumnDefault :: QueryRunnerColumnDefault pgType haskellType => QueryRunnerColumn pgType haskellType instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault a b => Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault (Opaleye.SQLite.Internal.Column.Nullable a) (GHC.Maybe.Maybe b) instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault a b => Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.RunQuery.QueryRunner (Opaleye.SQLite.Internal.Column.Column a) b instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGInt4 GHC.Types.Int instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGInt8 GHC.Int.Int64 instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGText GHC.Base.String instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGFloat8 GHC.Types.Double instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGBool GHC.Types.Bool instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGBytea Data.ByteString.Internal.ByteString instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGBytea Data.ByteString.Lazy.Internal.ByteString instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGText Data.Text.Internal.Text instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGText Data.Text.Internal.Lazy.Text instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGDate Data.Time.Calendar.Days.Day instance Opaleye.SQLite.Internal.RunQuery.QueryRunnerColumnDefault Opaleye.SQLite.PGTypes.PGTimestamptz Data.Time.Clock.Internal.UTCTime.UTCTime instance GHC.Base.Functor (Opaleye.SQLite.Internal.RunQuery.QueryRunner c) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.RunQuery.QueryRunner c) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.RunQuery.QueryRunner instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.RunQuery.QueryRunner instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.SQLite.Internal.RunQuery.QueryRunner module Opaleye.SQLite.Internal.Order -- | An Order represents an expression to order on and a sort -- direction. Multiple Orders can be composed with mappend. -- If two rows are equal according to the first Order, the second -- is used, and so on. newtype Order a Order :: (a -> [(OrderOp, PrimExpr)]) -> Order a order :: OrderOp -> (a -> Column b) -> Order a orderByU :: Order a -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag) limit' :: Int -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag) offset' :: Int -> (a, PrimQuery, Tag) -> (a, PrimQuery, Tag) instance Data.Functor.Contravariant.Contravariant Opaleye.SQLite.Internal.Order.Order instance GHC.Base.Semigroup (Opaleye.SQLite.Internal.Order.Order a) instance GHC.Base.Monoid (Opaleye.SQLite.Internal.Order.Order a) instance Data.Functor.Contravariant.Divisible.Divisible Opaleye.SQLite.Internal.Order.Order instance Data.Functor.Contravariant.Divisible.Decidable Opaleye.SQLite.Internal.Order.Order module Opaleye.SQLite.Internal.Join newtype NullMaker a b NullMaker :: (a -> b) -> NullMaker a b toNullable :: NullMaker a b -> a -> b extractLeftJoinFields :: Int -> Tag -> PrimExpr -> PM [(Symbol, PrimExpr)] PrimExpr instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.Join.NullMaker (Opaleye.SQLite.Internal.Column.Column a) (Opaleye.SQLite.Internal.Column.Column (Opaleye.SQLite.Internal.Column.Nullable a)) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.Join.NullMaker (Opaleye.SQLite.Internal.Column.Column (Opaleye.SQLite.Internal.Column.Nullable a)) (Opaleye.SQLite.Internal.Column.Column (Opaleye.SQLite.Internal.Column.Nullable a)) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.Join.NullMaker instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.Join.NullMaker -- | This modules defines the QueryArr arrow, which is an arrow that -- represents selecting data from a database, and composing multiple -- queries together. module Opaleye.SQLite.QueryArr data QueryArr a b type Query = QueryArr () module Opaleye.SQLite.Order -- | Typeclass for Postgres types which support ordering operations. class PGOrd a -- | Order the rows of a Query according to the Order. -- --
-- import Data.Monoid (<>) -- -- -- Order by the first column ascending. When first columns are equal -- -- order by second column descending. -- example :: Query (Column PGInt4, Column PGText) -- -> Query (Column PGInt4, Column PGText) -- example = orderBy (asc fst <> desc snd) --orderBy :: Order a -> Query a -> Query a -- | Specify an ascending ordering by the given expression. (Any NULLs -- appear last) asc :: PGOrd b => (a -> Column b) -> Order a -- | Specify an descending ordering by the given expression. (Any NULLs -- appear first) desc :: PGOrd b => (a -> Column b) -> Order a -- | Specify an ascending ordering by the given expression. (Any NULLs -- appear first) ascNullsFirst :: PGOrd b => (a -> Column b) -> Order a -- | Specify an descending ordering by the given expression. (Any NULLs -- appear last) descNullsLast :: PGOrd b => (a -> Column b) -> Order a -- | Limit the results of the given query to the given maximum number of -- items. limit :: Int -> Query a -> Query a -- | Offset the results of the given query by the given amount, skipping -- that many result rows. offset :: Int -> Query a -> Query a -- | An Order represents an expression to order on and a sort -- direction. Multiple Orders can be composed with mappend. -- If two rows are equal according to the first Order, the second -- is used, and so on. data Order a instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGBool instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGDate instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGFloat8 instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGFloat4 instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGInt8 instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGInt4 instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGInt2 instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGNumeric instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGText instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGTime instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGTimestamptz instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGTimestamp instance Opaleye.SQLite.Order.PGOrd Opaleye.SQLite.PGTypes.PGCitext module Opaleye.SQLite.Operators -- | Restrict query results to a particular condition. Corresponds to the -- guard method of the MonadPlus class. restrict :: QueryArr (Column PGBool) () doubleOfInt :: Column PGInt4 -> Column PGFloat8 (.==) :: Column a -> Column a -> Column PGBool infix 4 .== (./=) :: Column a -> Column a -> Column PGBool infix 4 ./= (.>) :: PGOrd a => Column a -> Column a -> Column PGBool infix 4 .> (.<) :: PGOrd a => Column a -> Column a -> Column PGBool infix 4 .< (.<=) :: PGOrd a => Column a -> Column a -> Column PGBool infix 4 .<= (.>=) :: PGOrd a => Column a -> Column a -> Column PGBool infix 4 .>= case_ :: [(Column PGBool, Column a)] -> Column a -> Column a ifThenElse :: Column PGBool -> Column a -> Column a -> Column a (.&&) :: Column PGBool -> Column PGBool -> Column PGBool infixr 3 .&& (.||) :: Column PGBool -> Column PGBool -> Column PGBool infixr 2 .|| not :: Column PGBool -> Column PGBool (.++) :: Column PGText -> Column PGText -> Column PGText lower :: Column PGText -> Column PGText upper :: Column PGText -> Column PGText like :: Column PGText -> Column PGText -> Column PGBool ors :: Foldable f => f (Column PGBool) -> Column PGBool in_ :: (Functor f, Foldable f) => f (Column a) -> Column a -> Column PGBool module Opaleye.SQLite.Join -- | leftJoin's use of the Default typeclass means that the -- compiler will have trouble inferring types. It is strongly recommended -- that you provide full type signatures when using leftJoin. -- -- Example specialization: -- --
-- leftJoin :: Query (Column a, Column b) -- -> Query (Column c, Column (Nullable d)) -- -> (((Column a, Column b), (Column c, Column (Nullable d))) -> Column PGBool) -- -> Query ((Column a, Column b), (Column (Nullable c), Column (Nullable d))) --leftJoin :: (Default Unpackspec columnsA columnsA, Default Unpackspec columnsB columnsB, Default NullMaker columnsB nullableColumnsB) => Query columnsA -> Query columnsB -> ((columnsA, columnsB) -> Column PGBool) -> Query (columnsA, nullableColumnsB) leftJoinExplicit :: Unpackspec columnsA columnsA -> Unpackspec columnsB columnsB -> NullMaker columnsB nullableColumnsB -> Query columnsA -> Query columnsB -> ((columnsA, columnsB) -> Column PGBool) -> Query (columnsA, nullableColumnsB) module Opaleye.SQLite.Binary -- | Example type specialization: -- --
-- unionAll :: Query (Column a, Column b) -- -> Query (Column a, Column b) -- -> Query (Column a, Column b) ---- -- Assuming the makeAdaptorAndInstance splice has been run for -- the product type Foo: -- --
-- unionAll :: Query (Foo (Column a) (Column b) (Column c)) -- -> Query (Foo (Column a) (Column b) (Column c)) -- -> Query (Foo (Column a) (Column b) (Column c)) --unionAll :: Default Binaryspec columns columns => Query columns -> Query columns -> Query columns unionAllExplicit :: Binaryspec columns columns' -> Query columns -> Query columns -> Query columns' -- | Perform aggregations on query results. module Opaleye.SQLite.Aggregate -- | Given a Query producing rows of type a and an -- Aggregator accepting rows of type a, apply the -- aggregator to the results of the query. aggregate :: Aggregator a b -> Query a -> Query b -- | Group the aggregation by equality on the input to groupBy. groupBy :: Aggregator (Column a) (Column a) -- | Sum all rows in a group. sum :: Aggregator (Column a) (Column a) -- | Count the number of non-null rows in a group. count :: Aggregator (Column a) (Column PGInt8) -- | Average of a group avg :: Aggregator (Column PGFloat8) (Column PGFloat8) -- | Maximum of a group max :: PGOrd a => Aggregator (Column a) (Column a) -- | Maximum of a group min :: PGOrd a => Aggregator (Column a) (Column a) boolOr :: Aggregator (Column PGBool) (Column PGBool) boolAnd :: Aggregator (Column PGBool) (Column PGBool) arrayAgg :: Aggregator (Column a) (Column (PGArray a)) stringAgg :: Column PGText -> Aggregator (Column PGText) (Column PGText) -- | An Aggregator takes a collection of rows of type a, -- groups them, and transforms each group into a single row of type -- b. This corresponds to aggregators using GROUP BY in -- SQL. -- -- An Aggregator corresponds closely to a Fold from the -- foldl package. Whereas an Aggregator a -- b takes each group of type a to a single row of type -- b, a Fold a b takes a list of -- a and returns a single row of type b. data Aggregator a b module Opaleye.SQLite.Internal.Distinct distinctExplicit :: Distinctspec columns columns' -> Query columns -> Query columns' newtype Distinctspec a b Distinctspec :: Aggregator a b -> Distinctspec a b instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Internal.Distinct.Distinctspec (Opaleye.SQLite.Internal.Column.Column a) (Opaleye.SQLite.Internal.Column.Column a) instance GHC.Base.Functor (Opaleye.SQLite.Internal.Distinct.Distinctspec a) instance GHC.Base.Applicative (Opaleye.SQLite.Internal.Distinct.Distinctspec a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Internal.Distinct.Distinctspec instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Internal.Distinct.Distinctspec instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.SQLite.Internal.Distinct.Distinctspec module Opaleye.SQLite.Distinct -- | Remove duplicate items from the query result. -- -- Example type specialization: -- --
-- distinct :: Query (Column a, Column b) -> Query (Column a, Column b) ---- -- Assuming the makeAdaptorAndInstance splice has been run for -- the product type Foo: -- --
-- distinct :: Query (Foo (Column a) (Column b) (Column c)) -> Query (Foo (Column a) (Column b) (Column c)) --distinct :: Default Distinctspec columns columns => Query columns -> Query columns distinctExplicit :: Distinctspec columns columns' -> Query columns -> Query columns' module Opaleye.SQLite.Sql -- | Example type specialization: -- --
-- showSqlForPostgres :: Query (Column a, Column b) -> String ---- -- Assuming the makeAdaptorAndInstance splice has been run for -- the product type Foo: -- --
-- showSqlForPostgres :: Query (Foo (Column a) (Column b) (Column c)) -> String --showSqlForPostgres :: forall columns. Default Unpackspec columns columns => Query columns -> String showSqlForPostgresUnopt :: forall columns. Default Unpackspec columns columns => Query columns -> String showSqlForPostgresExplicit :: Unpackspec columns b -> Query columns -> String showSqlForPostgresUnoptExplicit :: Unpackspec columns b -> Query columns -> String formatAndShowSQL :: ([PrimExpr], PrimQuery, Tag) -> String module Opaleye.SQLite.RunQuery -- | runQuery's use of the Default typeclass means that the -- compiler will have trouble inferring types. It is strongly recommended -- that you provide full type signatures when using runQuery. -- -- Example type specialization: -- --
-- runQuery :: Query (Column PGInt4, Column PGText) -> IO [(Column Int, Column String)] ---- -- Assuming the makeAdaptorAndInstance splice has been run for -- the product type Foo: -- --
-- runQuery :: Query (Foo (Column PGInt4) (Column PGText) (Column PGBool) -- -> IO [(Foo (Column Int) (Column String) (Column Bool)] ---- -- Opaleye types are converted to Haskell types based on instances of the -- QueryRunnerColumnDefault typeclass. runQuery :: Default QueryRunner columns haskells => Connection -> Query columns -> IO [haskells] runQueryExplicit :: QueryRunner columns haskells -> Connection -> Query columns -> IO [haskells] -- | Use queryRunnerColumn to make an instance to allow you to run -- queries on your own datatypes. For example: -- --
-- newtype Foo = Foo Int -- instance Default QueryRunnerColumn Foo Foo where -- def = queryRunnerColumn (unsafeCoerce :: Column Foo -> Column PGInt4) Foo def --queryRunnerColumn :: (Column a' -> Column a) -> (b -> b') -> QueryRunnerColumn a b -> QueryRunnerColumn a' b' data QueryRunner columns haskells -- | A QueryRunnerColumn pgType haskellType -- encodes how to turn a value of Postgres type pgType into a -- value of Haskell type haskellType. For example a value of -- type QueryRunnerColumn PGText String encodes how -- to turn a PGText result from the database into a Haskell -- String. data QueryRunnerColumn sqlType haskellType fieldQueryRunnerColumn :: FromField haskell => QueryRunnerColumn coltype haskell module Opaleye.SQLite.SqlTypes type SqlInt = PGInt4 type SqlText = PGText type SqlReal = PGFloat8 type SqlDate = PGDate type SqlBool = PGBool sqlString :: String -> Column SqlText sqlStrictText :: Text -> Column SqlText sqlLazyText :: Text -> Column SqlText sqlInt :: Int -> Column SqlInt sqlReal :: Double -> Column SqlReal sqlBool :: Bool -> Column SqlBool module Opaleye.SQLite.Constant newtype Constant haskells columns Constant :: (haskells -> columns) -> Constant haskells columns [constantExplicit] :: Constant haskells columns -> haskells -> columns constant :: Default Constant haskells columns => haskells -> columns instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Constant.Constant haskell (Opaleye.SQLite.Internal.Column.Column sql) => Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Constant.Constant (GHC.Maybe.Maybe haskell) (Opaleye.SQLite.Internal.Column.Column (Opaleye.SQLite.Internal.Column.Nullable sql)) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Constant.Constant GHC.Types.Int (Opaleye.SQLite.Internal.Column.Column Opaleye.SQLite.SqlTypes.SqlInt) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Constant.Constant GHC.Base.String (Opaleye.SQLite.Internal.Column.Column Opaleye.SQLite.SqlTypes.SqlText) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Constant.Constant Data.Text.Internal.Text (Opaleye.SQLite.Internal.Column.Column Opaleye.SQLite.SqlTypes.SqlText) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Constant.Constant Data.Text.Internal.Lazy.Text (Opaleye.SQLite.Internal.Column.Column Opaleye.SQLite.SqlTypes.SqlText) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Constant.Constant GHC.Types.Double (Opaleye.SQLite.Internal.Column.Column Opaleye.SQLite.SqlTypes.SqlReal) instance Data.Profunctor.Product.Default.Class.Default Opaleye.SQLite.Constant.Constant GHC.Types.Bool (Opaleye.SQLite.Internal.Column.Column Opaleye.SQLite.SqlTypes.SqlBool) instance GHC.Base.Functor (Opaleye.SQLite.Constant.Constant a) instance GHC.Base.Applicative (Opaleye.SQLite.Constant.Constant a) instance Data.Profunctor.Unsafe.Profunctor Opaleye.SQLite.Constant.Constant instance Data.Profunctor.Product.Class.ProductProfunctor Opaleye.SQLite.Constant.Constant instance Data.Profunctor.Product.Class.SumProfunctor Opaleye.SQLite.Constant.Constant module Opaleye.SQLite.Table -- | Example type specialization: -- --
-- queryTable :: Table w (Column a, Column b) -> Query (Column a, Column b) ---- -- Assuming the makeAdaptorAndInstance splice has been run for -- the product type Foo: -- --
-- queryTable :: Table w (Foo (Column a) (Column b) (Column c)) -> Query (Foo (Column a) (Column b) (Column c)) --queryTable :: Default ColumnMaker columns columns => Table a columns -> Query columns queryTableExplicit :: ColumnMaker tablecolumns columns -> Table a tablecolumns -> Query columns required :: String -> TableProperties (Column a) (Column a) optional :: String -> TableProperties (Maybe (Column a)) (Column a) data View columns data Writer columns dummy data Table writerColumns viewColumns Table :: String -> TableProperties writerColumns viewColumns -> Table writerColumns viewColumns data TableProperties writerColumns viewColumns module Opaleye.SQLite.Manipulation type Int64 = () arrangeInsert :: Table columns a -> columns -> SqlInsert arrangeInsertSql :: Table columns a -> columns -> String runInsert :: Connection -> Table columns columns' -> columns -> IO Int64 arrangeInsertMany :: Table columns a -> NonEmpty columns -> SqlInsert arrangeInsertManySql :: Table columns a -> NonEmpty columns -> String runInsertMany :: Connection -> Table columns columns' -> [columns] -> IO Int64 arrangeUpdate :: Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> SqlUpdate arrangeUpdateSql :: Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> String runUpdate :: Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> IO Int64 arrangeDelete :: Table a columnsR -> (columnsR -> Column PGBool) -> SqlDelete arrangeDeleteSql :: Table a columnsR -> (columnsR -> Column PGBool) -> String runDelete :: Connection -> Table a columnsR -> (columnsR -> Column PGBool) -> IO Int64 arrangeInsertReturning :: Unpackspec returned ignored -> Table columnsW columnsR -> columnsW -> (columnsR -> returned) -> Returning SqlInsert arrangeInsertReturningSql :: Unpackspec returned ignored -> Table columnsW columnsR -> columnsW -> (columnsR -> returned) -> String runInsertReturningExplicit :: QueryRunner returned haskells -> Connection -> Table columnsW columnsR -> columnsW -> (columnsR -> returned) -> IO [haskells] -- | runInsertReturning's use of the Default typeclass -- means that the compiler will have trouble inferring types. It is -- strongly recommended that you provide full type signatures when using -- runInsertReturning. runInsertReturning :: Default QueryRunner returned haskells => Connection -> Table columnsW columnsR -> columnsW -> (columnsR -> returned) -> IO [haskells] arrangeUpdateReturning :: Unpackspec returned ignored -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> Returning SqlUpdate arrangeUpdateReturningSql :: Unpackspec returned ignored -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> String runUpdateReturningExplicit :: QueryRunner returned haskells -> Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> IO [haskells] runUpdateReturning :: Default QueryRunner returned haskells => Connection -> Table columnsW columnsR -> (columnsR -> columnsW) -> (columnsR -> Column PGBool) -> (columnsR -> returned) -> IO [haskells] data Unpackspec columns columns' module Opaleye.SQLite.Values -- | Example type specialization: -- --
-- values :: [(Column a, Column b)] -> Query (Column a, Column b) ---- -- Assuming the makeAdaptorAndInstance splice has been run for -- the product type Foo: -- --
-- queryTable :: [Foo (Column a) (Column b) (Column c)] -> Query (Foo (Column a) (Column b) (Column c)) --values :: (Default Valuesspec columns columns, Default Unpackspec columns columns) => [columns] -> Query columns valuesExplicit :: Unpackspec columns columns' -> Valuesspec columns columns' -> [columns] -> Query columns' module Opaleye.SQLite