-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An SQL-generating DSL targeting SQLite -- @package opaleye-sqlite @version 0.0.0.0 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 Show SqlTable instance Show SqlColumn instance Show SqlOrderNulls instance Show SqlOrderDirection instance Show SqlOrder instance Show SqlExpr module Opaleye.SQLite.Internal.HaskellDB.Sql.Print 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 (.:.) :: (r -> z) -> (a -> b -> c -> r) -> a -> b -> c -> z (.::) :: (r -> z) -> (a -> b -> c -> d -> r) -> a -> b -> c -> d -> z (.::.) :: (r -> z) -> (a -> b -> c -> d -> e -> r) -> a -> b -> c -> d -> e -> z module Opaleye.SQLite.Internal.Tag newtype Tag UnsafeTag :: Int -> Tag start :: Tag next :: Tag -> Tag unsafeUnTag :: Tag -> Int tagWith :: Tag -> String -> String instance Read Tag instance Show 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 Read Symbol instance Show Symbol instance Read Literal instance Show Literal instance Show BinOp instance Read BinOp instance Show UnOp instance Read UnOp instance Show AggrOp instance Read AggrOp instance Read PrimExpr instance Show PrimExpr instance Show OrderNulls instance Show OrderDirection instance Show OrderOp instance Show 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 Show LimitOp instance Show BinOp instance Show JoinType instance Show 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 :: (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 SumProfunctor (PackMap a b) instance ProductProfunctor (PackMap a b) instance Profunctor (PackMap a b) instance Applicative (PackMap a b s) instance Functor (PackMap a b s) 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 Show SelectAttrs instance Show Values instance Show JoinType instance Show BinOp instance Show Binary instance Show Select instance Show Join instance Show From 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 Show (Column a) instance (PGNum a, PGFractional a) => Fractional (Column a) instance PGNum a => Num (Column a) 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 ProductProfunctor Binaryspec instance Profunctor Binaryspec instance Applicative (Binaryspec a) instance Functor (Binaryspec a) instance Default Binaryspec (Column a) (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.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 SumProfunctor Aggregator instance ProductProfunctor Aggregator instance Profunctor Aggregator instance Applicative (Aggregator a) instance Functor (Aggregator a) module Opaleye.SQLite.PGTypes data PGBool data PGDate data PGFloat4 data PGFloat8 data PGInt8 data PGInt4 data PGInt2 data PGNumeric data PGText data PGTime data PGTimestamp data PGTimestamptz data PGUuid data PGCitext data PGArray a data PGBytea data PGJson data PGJsonb -- | 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 PGFractional PGFloat8 instance PGNum PGInt8 instance PGNum PGInt4 instance PGNum PGFloat8 module Opaleye.SQLite.SqlTypes type SqlBool = PGBool type SqlDate = PGDate type SqlReal = PGFloat8 type SqlText = PGText type SqlInt = PGInt4 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.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 SumProfunctor Unpackspec instance ProductProfunctor Unpackspec instance Profunctor Unpackspec instance Applicative (Unpackspec a) instance Functor (Unpackspec a) instance Default Unpackspec (Column a) (Column a) 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 ProductProfunctor QueryArr instance Profunctor QueryArr instance Applicative (QueryArr a) instance Functor (QueryArr a) instance Arrow QueryArr instance Category QueryArr -- | 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.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 :: Default Unpackspec columns columns => Query columns -> String showSqlForPostgresUnopt :: 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.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 ProductProfunctor Valuesspec instance Profunctor Valuesspec instance Applicative (Valuesspec a) instance Functor (Valuesspec a) instance Default Valuesspec (Column PGInt4) (Column PGInt4) 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.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 ProductProfunctor NullMaker instance Profunctor NullMaker instance Default NullMaker (Column (Nullable a)) (Column (Nullable a)) instance Default NullMaker (Column a) (Column (Nullable a)) 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.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 SumProfunctor QueryRunner instance ProductProfunctor QueryRunner instance Profunctor QueryRunner instance Applicative (QueryRunner c) instance Functor (QueryRunner c) instance QueryRunnerColumnDefault PGTimestamptz UTCTime instance QueryRunnerColumnDefault PGDate Day instance QueryRunnerColumnDefault PGText Text instance QueryRunnerColumnDefault PGText Text instance QueryRunnerColumnDefault PGBytea ByteString instance QueryRunnerColumnDefault PGBytea ByteString instance QueryRunnerColumnDefault PGBool Bool instance QueryRunnerColumnDefault PGFloat8 Double instance QueryRunnerColumnDefault PGText String instance QueryRunnerColumnDefault PGInt8 Int64 instance QueryRunnerColumnDefault PGInt4 Int instance QueryRunnerColumnDefault a b => Default QueryRunner (Column a) b instance QueryRunnerColumnDefault a b => QueryRunnerColumnDefault (Nullable a) (Maybe b) 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.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 Decidable Order instance Divisible Order instance Monoid (Order a) instance Contravariant Order module Opaleye.SQLite.Order -- | 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 -- | Typeclass for Postgres types which support ordering operations. class PGOrd 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 PGOrd PGCitext instance PGOrd PGTimestamp instance PGOrd PGTimestamptz instance PGOrd PGTime instance PGOrd PGText instance PGOrd PGNumeric instance PGOrd PGInt2 instance PGOrd PGInt4 instance PGOrd PGInt8 instance PGOrd PGFloat4 instance PGOrd PGFloat8 instance PGOrd PGDate instance PGOrd PGBool 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 (./=) :: Column a -> Column a -> Column PGBool (.>) :: PGOrd a => Column a -> Column a -> Column PGBool (.<) :: PGOrd a => Column a -> Column a -> Column PGBool (.<=) :: PGOrd a => Column a -> Column a -> Column PGBool (.>=) :: PGOrd a => Column a -> Column a -> Column PGBool case_ :: [(Column PGBool, Column a)] -> Column a -> Column a ifThenElse :: Column PGBool -> Column a -> Column a -> Column a (.&&) :: Column PGBool -> Column PGBool -> Column PGBool (.||) :: Column PGBool -> Column PGBool -> Column PGBool 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.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 ProductProfunctor ColumnMaker instance Profunctor ColumnMaker instance Applicative (ColumnMaker a) instance Functor (ColumnMaker a) instance ProductProfunctor ViewColumnMaker instance Profunctor ViewColumnMaker instance Applicative (ViewColumnMaker a) instance Functor (ViewColumnMaker a) instance Default ColumnMaker (Column a) (Column a) instance Default ViewColumnMaker String (Column a) module Opaleye.SQLite.Internal.Table -- | Define a table as follows, where "id", "color", "location", "quantity" -- and "radius" are the tables columns in Postgres and the types are -- given in the type signature. The id field is an -- autoincrementing field (i.e. optional for writes). -- --
-- data Widget a b c d e = Widget { wid :: a
-- , color :: b
-- , location :: c
-- , quantity :: d
-- , radius :: e }
--
-- $(makeAdaptorAndInstance "pWidget" ''Widget)
--
-- widgetTable :: Table (Widget (Maybe (Column PGInt4)) (Column PGText) (Column PGText)
-- (Column PGInt4) (Column PGFloat8))
-- (Widget (Column PGText) (Column PGText) (Column PGText)
-- (Column PGInt4) (Column PGFloat8))
-- widgetTable = Table "widgetTable"
-- (pWidget Widget { wid = optional "id"
-- , color = required "color"
-- , location = required "location"
-- , quantity = required "quantity"
-- , radius = required "radius" })
--
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 Functor (Table a)
instance ProductProfunctor TableProperties
instance Profunctor TableProperties
instance Applicative (TableProperties a)
instance Functor (TableProperties a)
instance ProductProfunctor Writer
instance Profunctor Writer
instance Applicative (Writer a)
instance Functor (Writer a)
instance Monoid (Zip a)
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 -- | Define a table as follows, where "id", "color", "location", "quantity" -- and "radius" are the tables columns in Postgres and the types are -- given in the type signature. The id field is an -- autoincrementing field (i.e. optional for writes). -- --
-- data Widget a b c d e = Widget { wid :: a
-- , color :: b
-- , location :: c
-- , quantity :: d
-- , radius :: e }
--
-- $(makeAdaptorAndInstance "pWidget" ''Widget)
--
-- widgetTable :: Table (Widget (Maybe (Column PGInt4)) (Column PGText) (Column PGText)
-- (Column PGInt4) (Column PGFloat8))
-- (Widget (Column PGText) (Column PGText) (Column PGText)
-- (Column PGInt4) (Column PGFloat8))
-- widgetTable = Table "widgetTable"
-- (pWidget Widget { wid = optional "id"
-- , color = required "color"
-- , location = required "location"
-- , quantity = required "quantity"
-- , radius = required "radius" })
--
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.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 SumProfunctor Distinctspec instance ProductProfunctor Distinctspec instance Profunctor Distinctspec instance Applicative (Distinctspec a) instance Functor (Distinctspec a) instance Default Distinctspec (Column a) (Column a) 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