-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A database library with a focus on ease of use, type safety and useful error messages -- -- Please see README.md @package data-basic @version 0.2.0.2 module Internal.Data.Basic.TypeLevel class MappableList (l :: [k]) mapTypeList :: (MappableList l, AllSatisfy c l) => proxy1 c -> (forall proxy2 x. c x => proxy2 x -> a) -> proxy3 l -> [a] type CheckWithError (b :: Bool) (err :: ErrorMessage) = EqualOrError b True err type ErrorText = Text class c x => TypeSatisfies (c :: * -> Constraint) (x :: *) (field :: Symbol) class CheckWithError (NotMaybe a) (FieldNullErr field) => NotNull (a :: *) (field :: Symbol) -- | A description of a custom type error. data ErrorMessage :: * -- | Pretty print the type. ShowType :: k -> ErrorMessage [ShowType] :: ErrorMessage -- | Put two pieces of error message next to each other. [:<>:] :: ErrorMessage -- | Stack two pieces of error message on top of each other. [:$$:] :: ErrorMessage -- | The type-level equivalent of error. -- -- The polymorphic kind of this type allows it to be used in several -- settings. For instance, it can be used as a constraint, e.g. to -- provide a better error message for a non-existant instance, -- --
-- -- in a context -- instance TypeError (Text "Cannot Show functions." :$$: -- Text "Perhaps there is a missing argument?") -- => Show (a -> b) where -- showsPrec = error "unreachable" ---- -- It can also be placed on the right-hand side of a type-level function -- to provide an error for an invalid case, -- --
-- type family ByteSize x where -- ByteSize Word16 = 2 -- ByteSize Word8 = 1 -- ByteSize a = TypeError (Text "The type " :<>: ShowType a :<>: -- Text " is not exportable.") --instance Internal.Data.Basic.TypeLevel.MappableList '[] instance forall k (ks :: [k]) (k1 :: k). Internal.Data.Basic.TypeLevel.MappableList ks => Internal.Data.Basic.TypeLevel.MappableList (k1 : ks) instance Internal.Data.Basic.TypeLevel.CheckWithError (Internal.Data.Basic.TypeLevel.NotMaybe a) (Internal.Data.Basic.TypeLevel.FieldNullErr field) => Internal.Data.Basic.TypeLevel.NotNull a field instance c x => Internal.Data.Basic.TypeLevel.TypeSatisfies c x field -- | module Internal. : Data.Basic.TH.Types Description : Data types and -- utility function used during TH generation phase Copyright : (c) -- Nikola Henezi, 2016-2017 Luka Horvat, 2016-2017 License : MIT -- -- This module Internal.defines data types that are used during parsing -- and TH generation stages. They describe structure of the parser and -- define minimal representation that is needed from parser in order to -- generate Template Haskell. module Internal.Data.Basic.TH.Types -- | When something goes wrong, this explains what went wrong - -- hopefully... data ParseError ParseError :: Text -> ParseError -- | List of constraints that can be applied to a Column and affect -- generated datatype Currently, only Null constraint affects it by -- wrapping data type with Maybe data ColumnConstraint NullConstraint :: ColumnConstraint NotNullConstraint :: ColumnConstraint -- | Column information gathered from a parser data ColumnInfo ColumnInfo :: !Text -> !Name -> !Type -> !TypeName -> ![ColumnConstraint] -> ColumnInfo -- | name retrieved from the parser [$sel:_columnInfoText:ColumnInfo] :: ColumnInfo -> !Text -- | generate TH name [$sel:_columnInfoName:ColumnInfo] :: ColumnInfo -> !Name -- | generated TH type [$sel:_columnInfoType:ColumnInfo] :: ColumnInfo -> !Type -- | original sql type [$sel:_columnInfoSqlType:ColumnInfo] :: ColumnInfo -> !TypeName -- | list of constraints that have to be applied [$sel:_columnInfoConstraints:ColumnInfo] :: ColumnInfo -> ![ColumnConstraint] columnInfoType :: Lens' ColumnInfo Type columnInfoText :: Lens' ColumnInfo Text columnInfoSqlType :: Lens' ColumnInfo TypeName columnInfoName :: Lens' ColumnInfo Name columnInfoConstraints :: Lens' ColumnInfo [ColumnConstraint] -- | Entity information gathered from a parser data EntityInfo EntityInfo :: !Text -> !Name -> !Name -> !Type -> ![Constraint] -> [ColumnInfo] -> EntityInfo -- | name retrieved from the parser, basically a computed value of -- Name [$sel:_entityInfoText:EntityInfo] :: EntityInfo -> !Text -- | generated TH name [$sel:_entityInfoName:EntityInfo] :: EntityInfo -> !Name -- | original sql name retrieved by hssqlpp [$sel:_entityInfoSQLName:EntityInfo] :: EntityInfo -> !Name -- | generated datatype [$sel:_entityInfoType:EntityInfo] :: EntityInfo -> !Type -- | list of constraints that have to be applied [$sel:_entityInfoConstraintList:EntityInfo] :: EntityInfo -> ![Constraint] -- | list of all columns [$sel:_entityInfoColumnMap:EntityInfo] :: EntityInfo -> [ColumnInfo] entityInfoType :: Lens' EntityInfo Type entityInfoText :: Lens' EntityInfo Text entityInfoSQLName :: Lens' EntityInfo Name entityInfoName :: Lens' EntityInfo Name entityInfoConstraintList :: Lens' EntityInfo [Constraint] entityInfoColumnMap :: Lens' EntityInfo [ColumnInfo] -- | Minimal context we need to generate a foreign key constraint data ForeignKeyConstraint ForeignKeyConstraint :: !Text -> !EntityInfo -> ![ColumnInfo] -> !EntityInfo -> ![ColumnInfo] -> ForeignKeyConstraint -- | name of the foreign key [$sel:_fkName:ForeignKeyConstraint] :: ForeignKeyConstraint -> !Text [$sel:_fkFromT:ForeignKeyConstraint] :: ForeignKeyConstraint -> !EntityInfo [$sel:_fkFromCols:ForeignKeyConstraint] :: ForeignKeyConstraint -> ![ColumnInfo] -- | referenced entity [$sel:_fkToT:ForeignKeyConstraint] :: ForeignKeyConstraint -> !EntityInfo -- | referenced columns [$sel:_fkToCols:ForeignKeyConstraint] :: ForeignKeyConstraint -> ![ColumnInfo] fkToT :: Lens' ForeignKeyConstraint EntityInfo fkToCols :: Lens' ForeignKeyConstraint [ColumnInfo] fkName :: Lens' ForeignKeyConstraint Text fkFromT :: Lens' ForeignKeyConstraint EntityInfo fkFromCols :: Lens' ForeignKeyConstraint [ColumnInfo] -- | Minimal context we need to generate a unique key constraint data UniqueKeyConstraint UniqueKeyConstraint :: !Text -> !EntityInfo -> ![ColumnInfo] -> UniqueKeyConstraint -- | name of the constraint [$sel:_uqName:UniqueKeyConstraint] :: UniqueKeyConstraint -> !Text -- | referenced entity [$sel:_uqEntity:UniqueKeyConstraint] :: UniqueKeyConstraint -> !EntityInfo -- | referenced columns [$sel:_uqCols:UniqueKeyConstraint] :: UniqueKeyConstraint -> ![ColumnInfo] uqName :: Lens' UniqueKeyConstraint Text uqEntity :: Lens' UniqueKeyConstraint EntityInfo uqCols :: Lens' UniqueKeyConstraint [ColumnInfo] -- | Minimal context we need to generate a primary key constraint data PrimaryKeyConstraint PrimaryKeyConstraint :: !Text -> !EntityInfo -> ![ColumnInfo] -> PrimaryKeyConstraint -- | name of the constraint [$sel:_pkName:PrimaryKeyConstraint] :: PrimaryKeyConstraint -> !Text -- | referenced entity [$sel:_pkEntity:PrimaryKeyConstraint] :: PrimaryKeyConstraint -> !EntityInfo -- | referenced columns [$sel:_pkCols:PrimaryKeyConstraint] :: PrimaryKeyConstraint -> ![ColumnInfo] pkName :: Lens' PrimaryKeyConstraint Text pkEntity :: Lens' PrimaryKeyConstraint EntityInfo pkCols :: Lens' PrimaryKeyConstraint [ColumnInfo] -- | Full parse context. This datatype is filled with information as parser -- goes trough the sql file. After ParseContext is filled, TH -- takes over and code generation starts. data ParseContext ParseContext :: ![EntityInfo] -> ![ForeignKeyConstraint] -> ![PrimaryKeyConstraint] -> ![UniqueKeyConstraint] -> ParseContext -- | list of entities found [$sel:_entities:ParseContext] :: ParseContext -> ![EntityInfo] -- | all foreign keys [$sel:_fks:ParseContext] :: ParseContext -> ![ForeignKeyConstraint] -- | all primary keys [$sel:_pks:ParseContext] :: ParseContext -> ![PrimaryKeyConstraint] -- | all unique constraints [$sel:_uqs:ParseContext] :: ParseContext -> ![UniqueKeyConstraint] uqs :: Lens' ParseContext [UniqueKeyConstraint] pks :: Lens' ParseContext [PrimaryKeyConstraint] fks :: Lens' ParseContext [ForeignKeyConstraint] entities :: Lens' ParseContext [EntityInfo] -- | Defines null values for all datatypes that we support in Basic. This -- is basically a hack to avoid usage of unsafeCoerce, because with -- unsafeCoerce you can hit segmentation faults due to wrong memory -- allocation (e.g. Int and Bool). class NullValue a nullValue :: NullValue a => a instance Data.Semigroup.Semigroup Internal.Data.Basic.TH.Types.ParseContext instance GHC.Base.Monoid Internal.Data.Basic.TH.Types.ParseContext instance Internal.Data.Basic.TH.Types.NullValue GHC.Types.Int instance Internal.Data.Basic.TH.Types.NullValue GHC.Types.Bool instance Internal.Data.Basic.TH.Types.NullValue Data.Time.LocalTime.TimeOfDay.TimeOfDay instance Internal.Data.Basic.TH.Types.NullValue Data.Time.LocalTime.LocalTime.LocalTime instance (Internal.Data.Basic.TH.Types.NullValue a, Internal.Data.Basic.TH.Types.NullValue b) => Internal.Data.Basic.TH.Types.NullValue (a, b) instance Internal.Data.Basic.TH.Types.NullValue GHC.Types.Double instance Internal.Data.Basic.TH.Types.NullValue Data.Text.Internal.Text instance Internal.Data.Basic.TH.Types.NullValue (GHC.Base.Maybe a) instance GHC.Show.Show Internal.Data.Basic.TH.Types.ParseContext instance GHC.Show.Show Internal.Data.Basic.TH.Types.PrimaryKeyConstraint instance GHC.Show.Show Internal.Data.Basic.TH.Types.UniqueKeyConstraint instance GHC.Show.Show Internal.Data.Basic.TH.Types.ForeignKeyConstraint instance GHC.Show.Show Internal.Data.Basic.TH.Types.EntityInfo instance GHC.Classes.Eq Internal.Data.Basic.TH.Types.ColumnInfo instance GHC.Classes.Eq Internal.Data.Basic.TH.Types.EntityInfo instance GHC.Show.Show Internal.Data.Basic.TH.Types.ColumnInfo instance GHC.Classes.Eq Internal.Data.Basic.TH.Types.ColumnConstraint instance GHC.Show.Show Internal.Data.Basic.TH.Types.ColumnConstraint instance GHC.Show.Show Internal.Data.Basic.TH.Types.ParseError instance Data.Semigroup.Semigroup Internal.Data.Basic.TH.Types.ParseError instance GHC.Base.Monoid Internal.Data.Basic.TH.Types.ParseError -- | module Internal. : Data.Basic.TH.Types Description : Data types and -- utility function used during TH generation phase License : MIT -- -- This module Internal.contains helper functions that are used in code -- generation process. module Internal.Data.Basic.TH.Helper liftError :: Throws ParseError m => Either ParseErrorExtra a -> m a -- | lifts a list of types to a type level (i.e. typelevel list) e.g. -- `listToTypeLeve [Int, String, Double] = '[ Int, String, Double ]` listToTypeLevel :: [Type] -> Type -- | Used to append n times `$ field` to the expression addFields :: Exp -> Int -> Exp -- | Used to append `$ field` at the end of the expression addField :: Exp -> Exp standardizeName :: Text -> Text -- | returns a plural of a known noun. Basically just appends s or -- es quasyPlural :: Text -> Text -- | Tries to name multiples constraints nameUnnamedConstraints :: Throws ParseError m => EntityInfo -> m EntityInfo -- | Mechanism for naming unnamed constraints. If a constraint cannot be -- named, an error is trown nameUnnamedConstraint :: Throws ParseError m => EntityInfo -> Constraint -> m Constraint -- | Provides default naming scheme for constraints nameConstraint :: Text -> [NameComponent] -> Text -- | Converts a Name to a plain text @TODO test complex naming -- schemes getName :: Name -> Text -- | Retrieves a list of optional columns in an entity getOptionalColumns :: ParseContext -> EntityInfo -> [ColumnInfo] -- | Tries to retrieve entity information. If an entity with that name -- doesn't exist an error is thrown. getEntityByName :: Throws ParseError m => Name -> [EntityInfo] -> m EntityInfo -- | Tries to retrieve entity information. If an entity with that name -- doesn't exist an error is thrown. getEntityBySQLName :: Throws ParseError m => Name -> [EntityInfo] -> m EntityInfo -- | Tries to retrieve column information from entity. If a column with -- that name doesn't exist an error is thrown. getColumn :: Throws ParseError m => EntityInfo -> Text -> m ColumnInfo lowerFirst :: Text -> Text upperFirst :: Text -> Text -- | Retrieves the primary key for an entity from ParseContext getEntityPrimaryKey :: ParseContext -> EntityInfo -> Maybe PrimaryKeyConstraint -- | Generates name for the column lens (i.e. lowercases first letter) columnNameToLensName :: Text -> Text -- | Conversion between Postgres types and haskell datatypes. As a starting -- point, fromField from Database.PostgreSQL.Simple.FromField is -- used. If you need support for additional datatypes, please open an -- issue (https:/gitlab.comhaskell-hr/basic) or email maintainers module Internal.Data.Basic.TH.SqlToHsTypes -- | Conversion between TypeName to haskell Type. -- TypeName is used internaly by HsSqlPpp toHsType :: Throws ParseError m => TypeName -> m (Type, [ColumnConstraint]) module Internal.Data.Basic.SqlToHsTypes data Point Point :: {-# UNPACK #-} !Double -> {-# UNPACK #-} !Double -> Point instance GHC.Show.Show Internal.Data.Basic.SqlToHsTypes.Point instance GHC.Read.Read Internal.Data.Basic.SqlToHsTypes.Point instance GHC.Classes.Ord Internal.Data.Basic.SqlToHsTypes.Point instance GHC.Classes.Eq Internal.Data.Basic.SqlToHsTypes.Point instance Database.PostgreSQL.Simple.FromField.FromField Internal.Data.Basic.SqlToHsTypes.Point instance Database.PostgreSQL.Simple.ToField.ToField Internal.Data.Basic.SqlToHsTypes.Point module Internal.Data.Basic.Sql.Types data QuerySegment QuerySegment :: Query -> [Action] -> QuerySegment data Comparison LessThan :: Comparison LessOrEqual :: Comparison GreaterThan :: Comparison GreaterOrEqual :: Comparison Equal :: Comparison NotEqual :: Comparison data SortDirection Ascending :: SortDirection Descending :: SortDirection newtype SqlFunctionName SqlFunctionName :: Text -> SqlFunctionName data QualifiedField QualifiedField :: Int -> Text -> QualifiedField data QualifiedTable QualifiedTable :: Text -> Int -> QualifiedTable data Condition SqlAnd :: Condition -> Condition -> Condition SqlOr :: Condition -> Condition -> Condition SqlOperator :: Comparison -> SqlValueExp -> SqlValueExp -> Condition IsNull :: SqlValueExp -> Condition In :: SqlValueExp -> [SqlValueExp] -> Condition data AggregateFunction Avg :: AggregateFunction Max :: AggregateFunction Min :: AggregateFunction Count :: AggregateFunction Sum :: AggregateFunction Only :: AggregateFunction data SqlValueExp SimpleName :: QualifiedField -> SqlValueExp SqlFunctionApplication :: SqlFunctionName -> SqlValueExp -> SqlValueExp SqlLiteral :: Action -> SqlValueExp AggregateFunction :: AggregateFunction -> SqlValueExp -> SqlValueExp newtype Limit Limit :: (Maybe Int) -> Limit data Selection SelectEverything :: Selection SelectExpressions :: [SqlValueExp] -> Selection newtype Grouping Grouping :: [SqlValueExp] -> Grouping data SqlExp Select :: Selection -> (Maybe Condition) -> [QualifiedTable] -> [(SqlValueExp, SortDirection)] -> Limit -> Grouping -> SqlExp Insert :: Text -> [Text] -> [Action] -> SqlExp RawQuery :: Text -> [Action] -> SqlExp Delete :: QualifiedTable -> (Maybe Condition) -> SqlExp Update :: [Text] -> [SqlValueExp] -> (Maybe Condition) -> QualifiedTable -> SqlExp sToQuery :: StringConv a ByteString => a -> QuerySegment actionToQuery :: Action -> QuerySegment tableToQuery :: QualifiedTable -> QuerySegment comparisonToQuery :: Comparison -> QuerySegment fieldToQuery :: QualifiedField -> QuerySegment aggregateFunctionToQuery :: AggregateFunction -> QuerySegment valueToQuery :: SqlValueExp -> QuerySegment conditionToQuery :: Condition -> QuerySegment orderingToQuery :: (SqlValueExp, SortDirection) -> QuerySegment limitToQuery :: Limit -> QuerySegment selectionToQuery :: Selection -> QuerySegment groupToQuery :: Grouping -> QuerySegment listToTuple :: [QuerySegment] -> QuerySegment separateBy :: (Monoid a, Semigroup a, IsString a) => a -> [a] -> a sqlExpToQuery :: SqlExp -> QuerySegment data SqlResult SqlResult :: [a] -> SqlResult data SomeFromRowProxy SomeFromRowProxy :: (Proxy a) -> SomeFromRowProxy instance GHC.Show.Show Internal.Data.Basic.Sql.Types.SqlExp instance GHC.Show.Show Internal.Data.Basic.Sql.Types.Grouping instance GHC.Show.Show Internal.Data.Basic.Sql.Types.Selection instance GHC.Show.Show Internal.Data.Basic.Sql.Types.Limit instance GHC.Read.Read Internal.Data.Basic.Sql.Types.Limit instance GHC.Classes.Ord Internal.Data.Basic.Sql.Types.Limit instance GHC.Classes.Eq Internal.Data.Basic.Sql.Types.Limit instance GHC.Show.Show Internal.Data.Basic.Sql.Types.Condition instance GHC.Show.Show Internal.Data.Basic.Sql.Types.SqlValueExp instance GHC.Show.Show Internal.Data.Basic.Sql.Types.AggregateFunction instance GHC.Show.Show Internal.Data.Basic.Sql.Types.QualifiedTable instance GHC.Read.Read Internal.Data.Basic.Sql.Types.QualifiedTable instance GHC.Classes.Ord Internal.Data.Basic.Sql.Types.QualifiedTable instance GHC.Classes.Eq Internal.Data.Basic.Sql.Types.QualifiedTable instance GHC.Show.Show Internal.Data.Basic.Sql.Types.QualifiedField instance GHC.Read.Read Internal.Data.Basic.Sql.Types.QualifiedField instance GHC.Classes.Ord Internal.Data.Basic.Sql.Types.QualifiedField instance GHC.Classes.Eq Internal.Data.Basic.Sql.Types.QualifiedField instance GHC.Show.Show Internal.Data.Basic.Sql.Types.SqlFunctionName instance GHC.Read.Read Internal.Data.Basic.Sql.Types.SqlFunctionName instance GHC.Classes.Ord Internal.Data.Basic.Sql.Types.SqlFunctionName instance GHC.Classes.Eq Internal.Data.Basic.Sql.Types.SqlFunctionName instance GHC.Show.Show Internal.Data.Basic.Sql.Types.SortDirection instance GHC.Read.Read Internal.Data.Basic.Sql.Types.SortDirection instance GHC.Classes.Ord Internal.Data.Basic.Sql.Types.SortDirection instance GHC.Classes.Eq Internal.Data.Basic.Sql.Types.SortDirection instance GHC.Show.Show Internal.Data.Basic.Sql.Types.Comparison instance GHC.Read.Read Internal.Data.Basic.Sql.Types.Comparison instance GHC.Classes.Ord Internal.Data.Basic.Sql.Types.Comparison instance GHC.Classes.Eq Internal.Data.Basic.Sql.Types.Comparison instance GHC.Show.Show Internal.Data.Basic.Sql.Types.QuerySegment instance Data.Semigroup.Semigroup Database.PostgreSQL.Simple.Types.Query instance GHC.Base.Monoid Internal.Data.Basic.Sql.Types.QuerySegment instance Data.Semigroup.Semigroup Internal.Data.Basic.Sql.Types.QuerySegment instance Data.String.IsString Internal.Data.Basic.Sql.Types.QuerySegment instance Data.Semigroup.Semigroup Internal.Data.Basic.Sql.Types.Condition module Internal.Data.Basic.Types data VarContext Filtering :: VarContext Updating :: VarContext Sorting :: VarContext Grouping :: VarContext Folding :: VarContext Mapping :: VarContext newtype Var (ctx :: VarContext) (a :: *) Var :: Int -> Var newtype Key Key :: Int -> Key -- | Defines MissingField kind. data MissingField Required :: Symbol -> MissingField DynamicDefault :: Symbol -> MissingField data Cached Live :: Cached Cached :: Cached data EntityKind Fresh :: [MissingField] -> EntityKind FromDb :: Cached -> EntityKind newtype Entity (entKind :: EntityKind) a Entity :: a -> Entity a [$sel:_getEntity:Entity] :: Entity a -> a getEntity :: forall entKind_a1ILg a_a1ILh entKind_a1LOP a_a1LOQ. Iso (Entity entKind_a1ILg a_a1ILh) (Entity entKind_a1LOP a_a1LOQ) a_a1ILh a_a1LOQ toFreshEntity :: forall fs c a. Entity (FromDb c) a -> Entity (Fresh fs) a data FieldConstraint Unique :: Symbol -> FieldConstraint ForeignKey :: Symbol -> FieldConstraint type SetFields (missing :: [MissingField]) (table :: *) = TableFields table `Without` MissingFieldsNames missing class (AllSatisfy (TableField table) fields) => AllTypesSatisfy (c :: * -> Symbol -> Constraint) (table :: *) (fields :: [Symbol]) mapFields :: (AllTypesSatisfy c table fields, fields `IsSubset` SetFields (MissingFields entKind) table) => (forall proxy n x. c x n => proxy n -> x -> a) -> Entity entKind table -> [a] class (KnownSymbol n, ToJSON a) => JSONableField a (n :: Symbol) class GetEntityFromValue (fs :: [Symbol]) a (miss :: [MissingField]) getEntityFromObject :: GetEntityFromValue fs a miss => Value -> Parser (Entity (Fresh miss) a) class (KnownSymbol (TableName table), AllSatisfy (TableField table) (TableFields table), AllSatisfy KnownSymbol (TableFields table), AllSatisfy (ValidConstraint table) (TableConstraints table), AllTypesSatisfy (TypeSatisfies ToField) table (TableFields table), OnMaybe (() :: Constraint) PrimaryKeyConstraint (TablePrimaryKey table), FromRow table) => Table table where type TableName table = (name :: Symbol) | name -> table type TableFields table :: [Symbol] type TableConstraints table :: [FieldConstraint] type TablePrimaryKey table :: Maybe Symbol type TableRequiredFields table :: [MissingField] where { type family TableName table = (name :: Symbol) | name -> table; type family TableFields table :: [Symbol]; type family TableConstraints table :: [FieldConstraint]; type family TablePrimaryKey table :: Maybe Symbol; type family TableRequiredFields table :: [MissingField]; } newEntity :: Table table => Entity (Fresh (TableRequiredFields table)) table class ValidConstraint (table :: *) (constr :: FieldConstraint) getDbFields :: forall table. (MappableList (TableFields table), Table table) => [Text] class ValueAsDbExp' (IsDbExp a) a b => ValueAsDbExp a b valueAsDbExp :: ValueAsDbExp a b => a -> DbExp (KindOfDbExp a) b class ValueAsDbExp' (isDbExp :: Bool) a b valueAsDbExp' :: ValueAsDbExp' isDbExp a b => a -> DbExp (KindOfDbExp a) b class (KnownSymbol name, IsDbExp (TableFieldType table name) ~ False) => TableField (table :: *) (name :: Symbol) where type TableFieldType table name :: * where { type family TableFieldType table name :: *; } tableFieldLens :: TableField table name => Lens' table (TableFieldType table name) class (UniqueConstraint name, AllTypesSatisfy NotNull (UniqueTable name) (UniqueFields name)) => PrimaryKeyConstraint (name :: Symbol) class (AllSatisfy (TableField (UniqueTable name)) (UniqueFields name), KnownSymbol name) => UniqueConstraint (name :: Symbol) where type UniqueTable name :: * type UniqueFields name :: [Symbol] where { type family UniqueTable name :: *; type family UniqueFields name :: [Symbol]; } class (KnownSymbol name, AllSatisfy (TableField (ForeignKeyFrom name)) (ForeignKeyFromFields name), AllSatisfy (TableField (ForeignKeyTo name)) (ForeignKeyToFields name), SameTypes (ForeignKeyTo name) (ForeignKeyToFields name) (ForeignKeyFrom name) (ForeignKeyFromFields name)) => ForeignKeyConstraint (name :: Symbol) where type ForeignKeyFrom name :: * type ForeignKeyTo name :: * type ForeignKeyFromFields name :: [Symbol] type ForeignKeyToFields name :: [Symbol] where { type family ForeignKeyFrom name :: *; type family ForeignKeyTo name :: *; type family ForeignKeyFromFields name :: [Symbol]; type family ForeignKeyToFields name :: [Symbol]; } type CanInsert entKind table = (Table table, CanInsertFresh (MissingFields entKind) table) type CanInsertFresh (missing :: [MissingField]) (table :: *) = (CanInsertMissing missing, SetFields missing table `IsSubset` SetFields missing table, AllSatisfy KnownSymbol (SetFields missing table), MappableList (SetFields missing table), AllTypesSatisfy (TypeSatisfies ToField) table (SetFields missing table)) type CanUpdate table pk = (KnownSymbol pk, Table table, SetFields '[] table `IsSubset` SetFields '[] table, MappableList (TableFields table)) type DbResult list = ListToTuple (Entity (FromDb Live)) list type Variables ctx list = ListToTuple (Var ctx) list class TableSetVars ctx (tables :: [*]) makeVars :: TableSetVars ctx tables => Variables ctx tables data BoolOp And :: BoolOp Or :: BoolOp data ResultType Filtered :: ResultType Unfiltered :: ResultType Inserted :: ResultType Deleted :: ResultType Updated :: ResultType Sorted :: ResultType Limited :: ResultType Grouped :: ResultType Mapped :: ResultType Folded :: ResultType type FieldIsGettableBool field missing = Not (field `Elem` MissingFieldsNames missing) type FieldIsGettable field missing = CheckWithError (FieldIsGettableBool field missing) ((ErrorText "Field " :<>: ShowType field) :<>: ErrorText " is not set") type FieldIsNotSet field setFields = CheckWithError (Not (Elem field setFields)) ((ErrorText "Cannot update the field " :<>: ShowType field) :<>: ErrorText " because it's already updated in this expression") varFromUpdateExp :: UpdateExp fields t -> Var Updating t type FlattenTuple t = ListToSimpleTuple (TupleToList t) data DbStatement (resultType :: ResultType) (ts :: [*]) [Table] :: Table table => proxy (TableName table) -> DbStatement Unfiltered '[table] [Filter] :: (TableSetVars Filtering tables, Selection f) => (Variables Filtering tables -> ConditionExp) -> DbStatement f tables -> DbStatement Filtered tables [Join] :: DbStatement Unfiltered tables1 -> DbStatement Unfiltered tables2 -> DbStatement Unfiltered (tables1 ++ tables2) [Raw] :: ToRow r => Text -> r -> DbStatement f a [Insert] :: CanInsert missing table => Entity missing table -> DbStatement Inserted '[table] [Delete] :: (Selection f, Table table) => DbStatement f '[table] -> DbStatement Deleted '[table] [Update] :: (Selection f) => (Var Updating table -> UpdateExp fields table) -> DbStatement f '[table] -> DbStatement Updated '[a] [SortOn] :: (Selection f, TableSetVars Sorting tables, Sortable ord) => (Variables Sorting tables -> ord) -> DbStatement f tables -> DbStatement Sorted tables [Take] :: SelectionOrSortedSelection f => Int -> DbStatement f tables -> DbStatement Limited tables [Map] :: (Mappable map, CanMap f, TableSetVars Mapping tables) => (Variables Mapping tables -> map) -> DbStatement f tables -> DbStatement Mapped '[MapResult map] [AsGroup] :: TableSetVars Grouping tables => DbStatement f tables -> DbStatement Grouped tables [GroupMap] :: GroupMappable map => ((AsAggregate group, DbStatement Grouped tables) -> map) -> GroupStatement group tables -> DbStatement Folded '[GroupMapResult map] data GroupStatement group tables [GroupOn] :: (Selection f, TableSetVars Grouping tables, Groupable group) => (Variables Grouping tables -> group) -> DbStatement f tables -> GroupStatement group tables -- | A kind and type used so LiftAggregation can differentiate types like -- `m a` from AggregateStatement by their kind. data AM AM :: AM data AggregateStatement aggr (marker :: AM) [Aggregate] :: (Aggregatable aggr, CanAggregate f, TableSetVars Folding tables) => (Variables Folding tables -> aggr) -> DbStatement f tables -> AggregateStatement aggr AM data UpdateExp (fields :: [Symbol]) (table :: *) [NoUpdate] :: Var Updating table -> UpdateExp '[] table [SetField] :: (TableField table fieldName, FieldIsNotSet fieldName fields) => proxy fieldName -> UpdateExp fields table -> DbExp k (TableFieldType table fieldName) -> UpdateExp (fieldName : fields) table data ConditionExp [Compare] :: Ord a => Comparison -> DbExp k1 a -> DbExp k2 a -> ConditionExp [BoolOp] :: BoolOp -> ConditionExp -> ConditionExp -> ConditionExp [IsNull] :: DbExp FieldExp (Maybe a) -> ConditionExp [In] :: LiteralCollection collection a => DbExp k a -> collection -> ConditionExp data ExpressionKind FieldExp :: ExpressionKind LiteralExp :: ExpressionKind data DbExp (kind :: ExpressionKind) a [Field] :: TableField table fieldName => proxy fieldName -> Var anyCtx table -> DbExp FieldExp (TableFieldType table fieldName) [Literal] :: ToField a => a -> DbExp LiteralExp a data SomeDbExp SomeDbExp :: (DbExp k a) -> SomeDbExp class Sortable ord getOrdering :: Sortable ord => ord -> [(SomeDbExp, SortDirection)] class LiteralCollection collection a | collection -> a getLiteralCollection :: LiteralCollection collection a => collection -> [SomeDbExp] class Groupable group where type AsAggregate group :: * where { type family AsAggregate group :: *; } getGrouping :: Groupable group => group -> [SomeDbExp] asAggregate :: Groupable group => group -> AsAggregate group data GroupMappableThing res (am :: AM) [GroupMappableDbExp] :: DbExp k a -> GroupMappableThing a AM [GroupMappableAggr] :: Aggregatable aggr => AggregateStatement aggr AM -> GroupMappableThing (AggregationResult aggr) AM class GroupMappableBase map getGroupMappingBase :: GroupMappableBase map => map -> [(AggregateFunction, SomeDbExp)] class GroupMappable map getGroupMapping :: GroupMappable map => map -> [(AggregateFunction, SomeDbExp)] -- | So dfoldMap knows to behave like an expression when used inside of a -- dmap class MappableBase map where type MapResultBase map :: * where { type family MapResultBase map :: *; } getMappingBase :: MappableBase map => map -> [SomeDbExp] class Mappable map getMapping :: Mappable map => map -> [SomeDbExp] getAggr :: AggregateStatement aggr AM -> aggr newtype Avg a Avg :: a -> Avg a newtype Count a Count :: a -> Count a newtype Only a Only :: a -> Only a class AggregatableBase aggr where type AggregationBaseResult aggr :: * where { type family AggregationBaseResult aggr :: *; } getAggregatingBase :: AggregatableBase aggr => aggr -> (AggregateFunction, SomeDbExp) class Aggregatable aggr getAggregating :: Aggregatable aggr => aggr -> [(AggregateFunction, SomeDbExp)] nameText :: forall name. KnownSymbol name => Text newtype Max a :: * -> * Max :: a -> Max a [getMax] :: Max a -> a newtype Min a :: * -> * Min :: a -> Min a [getMin] :: Min a -> a -- | Monoid under addition. newtype Sum a :: * -> * Sum :: a -> Sum a [getSum] :: Sum a -> a instance GHC.Show.Show Internal.Data.Basic.Types.BoolOp instance GHC.Read.Read Internal.Data.Basic.Types.BoolOp instance GHC.Classes.Ord Internal.Data.Basic.Types.BoolOp instance GHC.Classes.Eq Internal.Data.Basic.Types.BoolOp instance Database.PostgreSQL.Simple.FromRow.FromRow a => Database.PostgreSQL.Simple.FromRow.FromRow (Internal.Data.Basic.Types.Entity l a) instance Internal.Data.Basic.Types.AllTypesSatisfy c table '[] instance (Internal.Data.Basic.Types.TableField table x, c (Internal.Data.Basic.Types.TableFieldType table x) x, Internal.Data.Basic.Types.AllTypesSatisfy c table xs) => Internal.Data.Basic.Types.AllTypesSatisfy c table (x : xs) instance (Internal.Data.Basic.TypeLevel.IsSubset (Internal.Data.Basic.Types.TableFields a) (Internal.Data.Basic.Types.TableFields a), Internal.Data.Basic.Types.AllTypesSatisfy Internal.Data.Basic.Types.JSONableField a (Internal.Data.Basic.Types.TableFields a)) => Data.Aeson.Types.ToJSON.ToJSON (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) a) instance (GHC.TypeLits.KnownSymbol n, Data.Aeson.Types.ToJSON.ToJSON a) => Internal.Data.Basic.Types.JSONableField a n instance (Internal.Data.Basic.TypeLevel.IsSubset (Internal.Data.Basic.Types.SetFields fs a) (Internal.Data.Basic.Types.SetFields fs a), Internal.Data.Basic.Types.AllTypesSatisfy Internal.Data.Basic.Types.JSONableField a (Internal.Data.Basic.Types.SetFields fs a)) => Data.Aeson.Types.ToJSON.ToJSON (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.Fresh fs) a) instance (Internal.Data.Basic.Types.Table a, miss ~ Internal.Data.Basic.Types.TableRequiredFields a) => Internal.Data.Basic.Types.GetEntityFromValue '[] a miss instance (Internal.Data.Basic.Types.GetEntityFromValue fs a miss, miss' ~ Internal.Data.Basic.Types.WithoutMissingField f miss, Data.Aeson.Types.FromJSON.FromJSON (Internal.Data.Basic.Types.TableFieldType a f), Internal.Data.Basic.Types.TableField a f) => Internal.Data.Basic.Types.GetEntityFromValue (f : fs) a miss' instance Internal.Data.Basic.Types.GetEntityFromValue (Internal.Data.Basic.Types.SetFields miss a) a miss => Data.Aeson.Types.FromJSON.FromJSON (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.Fresh miss) a) instance (Internal.Data.Basic.Types.UniqueConstraint name, table ~ Internal.Data.Basic.Types.UniqueTable name) => Internal.Data.Basic.Types.ValidConstraint table ('Internal.Data.Basic.Types.Unique name) instance (Internal.Data.Basic.Types.ForeignKeyConstraint name, table ~ Internal.Data.Basic.Types.ForeignKeyFrom name) => Internal.Data.Basic.Types.ValidConstraint table ('Internal.Data.Basic.Types.ForeignKey name) instance Internal.Data.Basic.Types.ValueAsDbExp' (Internal.Data.Basic.Types.IsDbExp a) a b => Internal.Data.Basic.Types.ValueAsDbExp a b instance Internal.Data.Basic.Types.DbExp k b ~ a => Internal.Data.Basic.Types.ValueAsDbExp' 'GHC.Types.True a b instance (a ~ b, Database.PostgreSQL.Simple.ToField.ToField a, Internal.Data.Basic.Types.KindOfDbExp a ~ 'Internal.Data.Basic.Types.LiteralExp) => Internal.Data.Basic.Types.ValueAsDbExp' 'GHC.Types.False a b instance Internal.Data.Basic.Types.TableSetVars ctx '[] instance Internal.Data.Basic.Types.TableSetVars ctx '[a] instance Internal.Data.Basic.Types.TableSetVars ctx '[a, b] instance Internal.Data.Basic.Types.TableSetVars ctx '[a, b, c] instance k ~ 'Internal.Data.Basic.Types.LiteralExp => GHC.Num.Num (Internal.Data.Basic.Types.DbExp k Internal.Data.Basic.Types.Key) instance k ~ 'Internal.Data.Basic.Types.LiteralExp => Data.String.IsString (Internal.Data.Basic.Types.DbExp k Data.Text.Internal.Text) instance GHC.Classes.Ord a => Internal.Data.Basic.Types.Sortable (Internal.Data.Basic.Types.DbExp k a) instance Internal.Data.Basic.Types.Sortable a => Internal.Data.Basic.Types.Sortable (Data.Ord.Down a) instance (Internal.Data.Basic.Types.Sortable a, Internal.Data.Basic.Types.Sortable b) => Internal.Data.Basic.Types.Sortable (a, b) instance (Internal.Data.Basic.Types.Sortable a, Internal.Data.Basic.Types.Sortable b, Internal.Data.Basic.Types.Sortable c) => Internal.Data.Basic.Types.Sortable (a, b, c) instance a ~ b => Internal.Data.Basic.Types.LiteralCollection (Internal.Data.Basic.Types.DbExp k a) a instance forall k a (x :: k) b. (Internal.Data.Basic.Types.LiteralCollection a x, Internal.Data.Basic.Types.LiteralCollection b x) => Internal.Data.Basic.Types.LiteralCollection (a, b) x instance forall k a (x :: k) b c. (Internal.Data.Basic.Types.LiteralCollection a x, Internal.Data.Basic.Types.LiteralCollection b x, Internal.Data.Basic.Types.LiteralCollection c x) => Internal.Data.Basic.Types.LiteralCollection (a, b, c) x instance Internal.Data.Basic.Types.DbExp b x ~ a => Internal.Data.Basic.Types.LiteralCollection [a] x instance Internal.Data.Basic.Types.Groupable (Internal.Data.Basic.Types.DbExp k a) instance (Internal.Data.Basic.Types.Groupable a, Internal.Data.Basic.Types.Groupable b) => Internal.Data.Basic.Types.Groupable (a, b) instance (Internal.Data.Basic.Types.Groupable a, Internal.Data.Basic.Types.Groupable b, Internal.Data.Basic.Types.Groupable c) => Internal.Data.Basic.Types.Groupable (a, b, c) instance (Internal.Data.Basic.Types.Groupable a, Internal.Data.Basic.Types.Groupable b, Internal.Data.Basic.Types.Groupable c, Internal.Data.Basic.Types.Groupable d) => Internal.Data.Basic.Types.Groupable (a, b, c, d) instance Internal.Data.Basic.Types.GroupMappableThing res 'Internal.Data.Basic.Types.AM ~ a => Internal.Data.Basic.Types.GroupMappableBase a instance (Internal.Data.Basic.Types.GroupMappableBase a, Internal.Data.Basic.Types.GroupMappableBase b) => Internal.Data.Basic.Types.GroupMappable (a, b) instance (Internal.Data.Basic.Types.GroupMappableBase a, Internal.Data.Basic.Types.GroupMappableBase b, Internal.Data.Basic.Types.GroupMappableBase c) => Internal.Data.Basic.Types.GroupMappable (a, b, c) instance (Internal.Data.Basic.Types.GroupMappableBase a, Internal.Data.Basic.Types.GroupMappableBase b, Internal.Data.Basic.Types.GroupMappableBase c, Internal.Data.Basic.Types.GroupMappableBase d) => Internal.Data.Basic.Types.GroupMappable (a, b, c, d) instance (Internal.Data.Basic.Types.GroupMappableBase a, Internal.Data.Basic.Types.GroupMappableBase b, Internal.Data.Basic.Types.GroupMappableBase c, Internal.Data.Basic.Types.GroupMappableBase d, Internal.Data.Basic.Types.GroupMappableBase e) => Internal.Data.Basic.Types.GroupMappable (a, b, c, d, e) instance Internal.Data.Basic.Types.GroupMappableBase (m a) => Internal.Data.Basic.Types.GroupMappable (m a) instance Internal.Data.Basic.Types.MappableBase (Internal.Data.Basic.Types.DbExp k a) instance (Internal.Data.Basic.Types.MappableBase a, Internal.Data.Basic.Types.MappableBase b) => Internal.Data.Basic.Types.Mappable (a, b) instance (Internal.Data.Basic.Types.MappableBase a, Internal.Data.Basic.Types.MappableBase b, Internal.Data.Basic.Types.MappableBase c) => Internal.Data.Basic.Types.Mappable (a, b, c) instance (Internal.Data.Basic.Types.MappableBase a, Internal.Data.Basic.Types.MappableBase b, Internal.Data.Basic.Types.MappableBase c, Internal.Data.Basic.Types.MappableBase d) => Internal.Data.Basic.Types.Mappable (a, b, c, d) instance (Internal.Data.Basic.Types.MappableBase a, Internal.Data.Basic.Types.MappableBase b, Internal.Data.Basic.Types.MappableBase c, Internal.Data.Basic.Types.MappableBase d, Internal.Data.Basic.Types.MappableBase e) => Internal.Data.Basic.Types.Mappable (a, b, c, d, e) instance Internal.Data.Basic.Types.MappableBase a => Internal.Data.Basic.Types.Mappable a instance GHC.Classes.Ord a => Internal.Data.Basic.Types.AggregatableBase (Data.Semigroup.Max (Internal.Data.Basic.Types.DbExp f a)) instance GHC.Classes.Ord a => Internal.Data.Basic.Types.AggregatableBase (Data.Semigroup.Min (Internal.Data.Basic.Types.DbExp f a)) instance GHC.Num.Num a => Internal.Data.Basic.Types.AggregatableBase (Internal.Data.Basic.Types.Avg (Internal.Data.Basic.Types.DbExp f a)) instance Internal.Data.Basic.Types.AggregatableBase (Internal.Data.Basic.Types.Count (Internal.Data.Basic.Types.DbExp f a)) instance GHC.Num.Num a => Internal.Data.Basic.Types.AggregatableBase (Data.Monoid.Sum (Internal.Data.Basic.Types.DbExp f a)) instance Internal.Data.Basic.Types.AggregatableBase (Internal.Data.Basic.Types.Only (Internal.Data.Basic.Types.DbExp f a)) instance Internal.Data.Basic.Types.BadAggregateBaseError => Internal.Data.Basic.Types.AggregatableBase a instance (Internal.Data.Basic.Types.AggregatableBase a, Internal.Data.Basic.Types.AggregatableBase b) => Internal.Data.Basic.Types.Aggregatable (a, b) instance (Internal.Data.Basic.Types.AggregatableBase a, Internal.Data.Basic.Types.AggregatableBase b, Internal.Data.Basic.Types.AggregatableBase c) => Internal.Data.Basic.Types.Aggregatable (a, b, c) instance Internal.Data.Basic.Types.AggregatableBase a => Internal.Data.Basic.Types.Aggregatable a instance GHC.Show.Show a => GHC.Show.Show (Internal.Data.Basic.Types.Entity entKind a) instance GHC.Read.Read a => GHC.Read.Read (Internal.Data.Basic.Types.Entity entKind a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Internal.Data.Basic.Types.Entity entKind a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Internal.Data.Basic.Types.Entity entKind a) instance Database.PostgreSQL.Simple.ToField.ToField Internal.Data.Basic.Types.Key instance Database.PostgreSQL.Simple.FromField.FromField Internal.Data.Basic.Types.Key instance GHC.Num.Num Internal.Data.Basic.Types.Key instance GHC.Show.Show Internal.Data.Basic.Types.Key instance GHC.Read.Read Internal.Data.Basic.Types.Key instance GHC.Classes.Ord Internal.Data.Basic.Types.Key instance GHC.Classes.Eq Internal.Data.Basic.Types.Key instance GHC.Show.Show (Internal.Data.Basic.Types.Var ctx a) instance GHC.Read.Read (Internal.Data.Basic.Types.Var ctx a) instance GHC.Classes.Ord (Internal.Data.Basic.Types.Var ctx a) instance GHC.Classes.Eq (Internal.Data.Basic.Types.Var ctx a) instance Data.Aeson.Types.FromJSON.FromJSON Internal.Data.Basic.Types.Key instance Data.Aeson.Types.ToJSON.ToJSON Internal.Data.Basic.Types.Key module Internal.Data.Basic.Lens type PolyOptic fun inType outType inVal outVal = (inVal -> fun outVal) -> inType -> fun outType type Getter' s a = PolyOptic (Const a) s s a a fieldOpticVarExp :: forall name t anyCtx proxy. TableField t name => proxy name -> PolyOptic (Const (DbExp FieldExp (TableFieldType t name))) (Var anyCtx t) (Var anyCtx t) (DbExp FieldExp (TableFieldType t name)) (DbExp FieldExp (TableFieldType t name)) fieldOpticEntityGet :: forall name t entKind proxy. (TableField t name, FieldIsGettable name (MissingFields entKind)) => proxy name -> PolyOptic (Const (TableFieldType t name)) (Entity entKind t) (Entity entKind t) (TableFieldType t name) (TableFieldType t name) class SupportedModifyAccess isSet existingValue outVal | isSet outVal -> existingValue transformModifyFunction :: SupportedModifyAccess isSet existingValue outVal => (existingValue -> f outVal) -> outVal -> f outVal fieldOpticEntityModify :: forall name t entKind existingValue proxy. (TableField t name, SupportedModifyAccess (FieldIsGettableBool name (MissingFields entKind)) existingValue (TableFieldType t name)) => proxy name -> PolyOptic Identity (Entity entKind t) (Entity (WithFieldSet name entKind) t) existingValue (TableFieldType t name) fieldOpticUpdateVarSet :: forall name t val proxy. (ValueAsDbExp val (TableFieldType t name), TableField t name) => proxy name -> PolyOptic Identity (Var Updating t) (UpdateExp '[name] t) (DbExp FieldExp (TableFieldType t name)) val fieldOpticUpdatedSet :: forall name t fields val proxy. (TableField t name, FieldIsNotSet name fields, ValueAsDbExp val (TableFieldType t name)) => proxy name -> PolyOptic Identity (UpdateExp fields t) (UpdateExp (name : fields) t) (DbExp FieldExp (TableFieldType t name)) val class FieldOpticProxy t fieldOpticProxy :: FieldOpticProxy t => t fieldOptic :: forall name o. FieldOpticProxy (Proxy name -> o) => o fieldOpticEntitySet :: forall name t missing. TableField t name => PolyOptic Identity (Entity missing t) (Entity (WithFieldSet name missing) t) () (TableFieldType t name) instance (Internal.Data.Basic.Types.TableField t0 name0, t5 ~ t0, t4 ~ anyCtx0, t3 ~ Data.Functor.Const.Const (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0)), t2 ~ (->) (Internal.Data.Basic.Types.Var anyCtx0 t0), t1 ~ (->) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0) -> Data.Functor.Const.Const (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0)) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0))), t7 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t7 (t1 (t2 (t3 (Internal.Data.Basic.Types.Var t4 t5))))) instance (Internal.Data.Basic.Types.TableField t0 name0, t7 ~ Internal.Data.Basic.Types.Var anyCtx0 t0, t6 ~ Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0), t5 ~ Data.Functor.Const.Const, t4 ~ t0, t3 ~ anyCtx0, t2 ~ (->), t1 ~ (->) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0) -> Data.Functor.Const.Const (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0)) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0))), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (Internal.Data.Basic.Types.Var t3 t4) (t5 t6 t7)))) instance (Internal.Data.Basic.Types.TableField t0 name0, t9 ~ Data.Functor.Const.Const (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0)) (Internal.Data.Basic.Types.Var anyCtx0 t0), t8 ~ t0, t7 ~ anyCtx0, t6 ~ (->), t5 ~ Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0), t4 ~ Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0), t3 ~ Data.Functor.Const.Const, t2 ~ (->) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0)), t1 ~ (->), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (t3 t4 t5)) (t6 (Internal.Data.Basic.Types.Var t7 t8) t9))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.TypeLevel.EqualOrError (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 (Internal.Data.Basic.Types.MissingFieldsNames (Internal.Data.Basic.Types.MissingFields entKind0)))) 'GHC.Types.True (('GHC.TypeLits.Text "Field " 'GHC.TypeLits.:<>: 'GHC.TypeLits.ShowType name0) 'GHC.TypeLits.:<>: 'GHC.TypeLits.Text " is not set"), t6 ~ t0, t5 ~ entKind0, t4 ~ Internal.Data.Basic.Types.TableFieldType t0 name0, t3 ~ Data.Functor.Const.Const, t2 ~ (->) (Internal.Data.Basic.Types.Entity entKind0 t0), t1 ~ (->) (Internal.Data.Basic.Types.TableFieldType t0 name0 -> Data.Functor.Const.Const (Internal.Data.Basic.Types.TableFieldType t0 name0) (Internal.Data.Basic.Types.TableFieldType t0 name0)), t7 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t7 (t1 (t2 (t3 t4 (Internal.Data.Basic.Types.Entity t5 t6))))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.TypeLevel.EqualOrError (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 (Internal.Data.Basic.Types.MissingFieldsNames (Internal.Data.Basic.Types.MissingFields entKind0)))) 'GHC.Types.True (('GHC.TypeLits.Text "Field " 'GHC.TypeLits.:<>: 'GHC.TypeLits.ShowType name0) 'GHC.TypeLits.:<>: 'GHC.TypeLits.Text " is not set"), t9 ~ t0, t8 ~ entKind0, t7 ~ Data.Functor.Const.Const (Internal.Data.Basic.Types.TableFieldType t0 name0), t6 ~ (->) (Internal.Data.Basic.Types.Entity entKind0 t0), t5 ~ Internal.Data.Basic.Types.TableFieldType t0 name0, t4 ~ Internal.Data.Basic.Types.TableFieldType t0 name0, t3 ~ Data.Functor.Const.Const, t2 ~ (->) (Internal.Data.Basic.Types.TableFieldType t0 name0), t1 ~ (->), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (t3 t4 t5)) (t6 (t7 (Internal.Data.Basic.Types.Entity t8 t9))))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.TypeLevel.EqualOrError (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 (Internal.Data.Basic.Types.MissingFieldsNames (Internal.Data.Basic.Types.MissingFields entKind0)))) 'GHC.Types.True (('GHC.TypeLits.Text "Field " 'GHC.TypeLits.:<>: 'GHC.TypeLits.ShowType name0) 'GHC.TypeLits.:<>: 'GHC.TypeLits.Text " is not set"), t7 ~ Internal.Data.Basic.Types.Entity entKind0 t0, t6 ~ Internal.Data.Basic.Types.TableFieldType t0 name0, t5 ~ Data.Functor.Const.Const, t4 ~ t0, t3 ~ entKind0, t2 ~ (->), t1 ~ (->) (Internal.Data.Basic.Types.TableFieldType t0 name0 -> Data.Functor.Const.Const (Internal.Data.Basic.Types.TableFieldType t0 name0) (Internal.Data.Basic.Types.TableFieldType t0 name0)), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (Internal.Data.Basic.Types.Entity t3 t4) (t5 t6 t7)))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.TypeLevel.EqualOrError (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 (Internal.Data.Basic.Types.MissingFieldsNames (Internal.Data.Basic.Types.MissingFields entKind0)))) 'GHC.Types.True (('GHC.TypeLits.Text "Field " 'GHC.TypeLits.:<>: 'GHC.TypeLits.ShowType name0) 'GHC.TypeLits.:<>: 'GHC.TypeLits.Text " is not set"), t9 ~ Data.Functor.Const.Const (Internal.Data.Basic.Types.TableFieldType t0 name0) (Internal.Data.Basic.Types.Entity entKind0 t0), t8 ~ t0, t7 ~ entKind0, t6 ~ (->), t5 ~ Internal.Data.Basic.Types.TableFieldType t0 name0, t4 ~ Internal.Data.Basic.Types.TableFieldType t0 name0, t3 ~ Data.Functor.Const.Const, t2 ~ (->) (Internal.Data.Basic.Types.TableFieldType t0 name0), t1 ~ (->), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (t3 t4 t5)) (t6 (Internal.Data.Basic.Types.Entity t7 t8) t9))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.Lens.SupportedModifyAccess (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 (Internal.Data.Basic.Types.MissingFieldsNames (Internal.Data.Basic.Types.MissingFields entKind0)))) existingValue0 (Internal.Data.Basic.Types.TableFieldType t0 name0), t4 ~ t0, t3 ~ Internal.Data.Basic.Types.WithFieldSet name0 entKind0, t2 ~ (->) (Internal.Data.Basic.Types.Entity entKind0 t0), t1 ~ (->) (existingValue0 -> Data.Functor.Identity.Identity (Internal.Data.Basic.Types.TableFieldType t0 name0)), t7 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t7 (t1 (t2 (Data.Functor.Identity.Identity (Internal.Data.Basic.Types.Entity t3 t4))))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.Lens.SupportedModifyAccess (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 (Internal.Data.Basic.Types.MissingFieldsNames (Internal.Data.Basic.Types.MissingFields entKind0)))) existingValue0 (Internal.Data.Basic.Types.TableFieldType t0 name0), t5 ~ Internal.Data.Basic.Types.Entity (Internal.Data.Basic.Types.WithFieldSet name0 entKind0) t0, t4 ~ t0, t3 ~ entKind0, t2 ~ (->), t1 ~ (->) (existingValue0 -> Data.Functor.Identity.Identity (Internal.Data.Basic.Types.TableFieldType t0 name0)), t7 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t7 (t1 (t2 (Internal.Data.Basic.Types.Entity t3 t4) (Data.Functor.Identity.Identity t5)))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.Lens.SupportedModifyAccess (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 (Internal.Data.Basic.Types.MissingFieldsNames (Internal.Data.Basic.Types.MissingFields entKind0)))) existingValue0 (Internal.Data.Basic.Types.TableFieldType t0 name0), t7 ~ t0, t6 ~ Internal.Data.Basic.Types.WithFieldSet name0 entKind0, t5 ~ Data.Functor.Identity.Identity, t4 ~ (->) (Internal.Data.Basic.Types.Entity entKind0 t0), t3 ~ Internal.Data.Basic.Types.TableFieldType t0 name0, t2 ~ (->) existingValue0, t1 ~ (->), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (Data.Functor.Identity.Identity t3)) (t4 (t5 (Internal.Data.Basic.Types.Entity t6 t7))))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.Lens.SupportedModifyAccess (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 (Internal.Data.Basic.Types.MissingFieldsNames (Internal.Data.Basic.Types.MissingFields entKind0)))) existingValue0 (Internal.Data.Basic.Types.TableFieldType t0 name0), t7 ~ Data.Functor.Identity.Identity (Internal.Data.Basic.Types.Entity (Internal.Data.Basic.Types.WithFieldSet name0 entKind0) t0), t6 ~ t0, t5 ~ entKind0, t4 ~ (->), t3 ~ Internal.Data.Basic.Types.TableFieldType t0 name0, t2 ~ (->) existingValue0, t1 ~ (->), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (Data.Functor.Identity.Identity t3)) (t4 (Internal.Data.Basic.Types.Entity t5 t6) t7))) instance (Internal.Data.Basic.Types.ValueAsDbExp val0 (Internal.Data.Basic.Types.TableFieldType t0 name0), Internal.Data.Basic.Types.TableField t0 name0, t7 ~ t0, t6 ~ '[name0], t5 ~ Data.Functor.Identity.Identity, t4 ~ t0, t3 ~ 'Internal.Data.Basic.Types.Updating, t2 ~ (->), t1 ~ (->) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0) -> Data.Functor.Identity.Identity val0), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (Internal.Data.Basic.Types.Var t3 t4) (t5 (Internal.Data.Basic.Types.UpdateExp t6 t7))))) instance (Internal.Data.Basic.Types.ValueAsDbExp val0 (Internal.Data.Basic.Types.TableFieldType t0 name0), Internal.Data.Basic.Types.TableField t0 name0, t5 ~ Internal.Data.Basic.Types.UpdateExp '[name0] t0, t4 ~ t0, t3 ~ 'Internal.Data.Basic.Types.Updating, t2 ~ (->), t1 ~ (->) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0) -> Data.Functor.Identity.Identity val0), t7 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t7 (t1 (t2 (Internal.Data.Basic.Types.Var t3 t4) (Data.Functor.Identity.Identity t5)))) instance (Internal.Data.Basic.Types.ValueAsDbExp val0 (Internal.Data.Basic.Types.TableFieldType t0 name0), Internal.Data.Basic.Types.TableField t0 name0, t7 ~ Data.Functor.Identity.Identity (Internal.Data.Basic.Types.UpdateExp '[name0] t0), t6 ~ t0, t5 ~ 'Internal.Data.Basic.Types.Updating, t4 ~ (->), t3 ~ val0, t2 ~ (->) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0)), t1 ~ (->), t11 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t11 (t1 (t2 (Data.Functor.Identity.Identity t3)) (t4 (Internal.Data.Basic.Types.Var t5 t6) t7))) instance (Internal.Data.Basic.Types.TableField t0 name0, Internal.Data.Basic.TypeLevel.EqualOrError (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem name0 fields0)) 'GHC.Types.True (('GHC.TypeLits.Text "Cannot update the field " 'GHC.TypeLits.:<>: 'GHC.TypeLits.ShowType name0) 'GHC.TypeLits.:<>: 'GHC.TypeLits.Text " because it's already updated in this expression"), Internal.Data.Basic.Types.ValueAsDbExp val0 (Internal.Data.Basic.Types.TableFieldType t0 name0), t5 ~ Data.Functor.Identity.Identity (Internal.Data.Basic.Types.UpdateExp (name0 : fields0) t0), t4 ~ t0, t3 ~ fields0, t2 ~ (->), t1 ~ (->) (Internal.Data.Basic.Types.DbExp 'Internal.Data.Basic.Types.FieldExp (Internal.Data.Basic.Types.TableFieldType t0 name0) -> Data.Functor.Identity.Identity val0), t7 ~ (->) (proxy0 name0)) => Internal.Data.Basic.Lens.FieldOpticProxy (t7 (t1 (t2 (Internal.Data.Basic.Types.UpdateExp t3 t4) t5))) instance Internal.Data.Basic.Lens.SupportedModifyAccess 'GHC.Types.True outVal outVal instance Internal.Data.Basic.Lens.SupportedModifyAccess 'GHC.Types.False () outVal module Internal.Data.Basic.Compiler expToSql :: DbExp k a -> SqlValueExp literalCollectionToSql :: LiteralCollection collection a => collection -> [SqlValueExp] boolExpToSql :: ConditionExp -> Condition conditionToSql :: forall tables. TableSetVars Filtering tables => (Variables Filtering tables -> ConditionExp) -> Condition uniqueNames :: [QualifiedTable] -> [QualifiedTable] compileTable :: forall name proxy. KnownSymbol name => proxy (name :: Symbol) -> SqlExp updatedExpToSql :: UpdateExp fields table -> ([Text], [SqlValueExp]) updateToSql :: forall table fields. (Var Updating table -> UpdateExp fields table) -> ([Text], [SqlValueExp]) orderingToSql :: forall tables ord. (Sortable ord, TableSetVars Sorting tables) => (Variables Sorting tables -> ord) -> [(SqlValueExp, SortDirection)] mappingToSql :: forall tables map. (Mappable map, TableSetVars Mapping tables) => (Variables Mapping tables -> map) -> [SqlValueExp] mapToSql :: Mappable map => map -> [SqlValueExp] groupMapToSql :: GroupMappable map => map -> [SqlValueExp] grouppingToSql :: forall tables group. (Groupable group, TableSetVars Grouping tables) => (Variables Grouping tables -> group) -> [SqlValueExp] groupStatementToSql :: forall tables group. GroupStatement group tables -> SqlExp foldingToSql :: forall tables aggr. (Aggregatable aggr, TableSetVars Folding tables) => (Variables Folding tables -> aggr) -> [SqlValueExp] aggregateStatementToSql :: AggregateStatement aggr AM -> SqlExp compileToSql :: DbStatement f ts -> SqlExp module Internal.Data.Basic.Compare class ComparableInDbExp (a :: *) (b :: *) compareInDbExp :: ComparableInDbExp a b => Comparison -> a -> b -> ConditionExp (>.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 >. (==.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 ==. (/=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 /=. (<.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 <. (<=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 <=. (>=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 >=. (&&.) :: ConditionExp -> ConditionExp -> ConditionExp infix 3 &&. (||.) :: ConditionExp -> ConditionExp -> ConditionExp infix 2 ||. instance (Internal.Data.Basic.Types.ValueAsDbExp b a, GHC.Classes.Ord a) => Internal.Data.Basic.Compare.ComparableInDbExp (Internal.Data.Basic.Types.DbExp k a) b instance (Internal.Data.Basic.Types.ValueAsDbExp a b, GHC.Classes.Ord b) => Internal.Data.Basic.Compare.ComparableInDbExp a (Internal.Data.Basic.Types.DbExp k b) module Internal.Control.Effects.Basic newtype Basic RunSql :: Type -> Basic newtype SqlRequest a SqlRequest :: SqlExp -> SqlRequest a [$sel:getSqlRequest:SqlRequest] :: SqlRequest a -> SqlExp effectBasic :: (MonadEffect Basic m, FromRow a) => SqlRequest a -> m [a] handleBasic :: Functor m => (forall b. FromRow b => SqlRequest b -> m [b]) -> EffectHandler Basic m a -> m a -- | Handles SQL by querying a PostgreSQL database. handleBasicPsql :: MonadIO m => Connection -> EffectHandler Basic m a -> m a class (FromRow (AllTables ts)) => AllHaveFromRowInstance ts compositeToTuple :: AllHaveFromRowInstance ts => proxy ts -> AllTables ts -> DbResult ts runDbStatement :: forall ts m f. (AllHaveFromRowInstance ts, MonadEffect Basic m) => DbStatement f ts -> m [DbResult ts] runAggregateStatement :: forall aggr m. (MonadEffect Basic m, FromRow (AggregationResult aggr)) => AggregateStatement aggr AM -> m (AggregationResult aggr) class NoOnly a noOnly :: NoOnly a => a -> WithoutOnly a runMapStatement :: forall res m f. (MonadEffect Basic m, FromRow res, NoOnly res) => DbStatement f '[res] -> m [WithoutOnly res] instance forall k (a :: k). GHC.Show.Show (Internal.Control.Effects.Basic.SqlRequest a) instance Database.PostgreSQL.Simple.FromRow.FromRow a => Internal.Control.Effects.Basic.AllHaveFromRowInstance '[a] instance (Database.PostgreSQL.Simple.FromRow.FromRow a, Database.PostgreSQL.Simple.FromRow.FromRow b) => Internal.Control.Effects.Basic.AllHaveFromRowInstance '[a, b] instance (Database.PostgreSQL.Simple.FromRow.FromRow a, Database.PostgreSQL.Simple.FromRow.FromRow b, Database.PostgreSQL.Simple.FromRow.FromRow c) => Internal.Control.Effects.Basic.AllHaveFromRowInstance '[a, b, c] instance Internal.Control.Effects.Basic.NoOnly (Database.PostgreSQL.Simple.Types.Only a) instance Internal.Control.Effects.Basic.WithoutOnly a ~ a => Internal.Control.Effects.Basic.NoOnly a module Internal.Data.Basic.Common class LiftedStatement fs t res liftDbExp :: LiftedStatement fs t res => DbStatement fs t -> res djoin :: LiftedStatement Unfiltered (tables1 ++ tables2) res => DbStatement Unfiltered tables1 -> DbStatement Unfiltered tables2 -> res dfilter :: (LiftedStatement Filtered tables res, TableSetVars Filtering tables, Selection f) => (Variables Filtering tables -> ConditionExp) -> DbStatement f tables -> res ddelete :: (LiftedStatement Deleted '[table] res, Selection f, Table table) => DbStatement f '[table] -> res type AllRows table res = (Table table, LiftedStatement Unfiltered '[table] res) allRows :: forall tableName table res. (TableName table ~ tableName, AllRows table res) => res allRowsProxy :: forall table res proxy. (Table table, LiftedStatement Unfiltered '[table] res) => proxy table -> res rawQuery :: forall a r m. (MonadEffect Basic m, FromRow a, ToRow r) => Text -> r -> m [Entity (FromDb Live) a] insert :: (CanInsert entKind table, MonadEffect Basic m, FromRow table) => Entity entKind table -> m (Entity (FromDb Live) table) dupdate :: (MonadEffect Basic m, FromRow table, Selection f) => (Var Updating table -> UpdateExp fields table) -> DbStatement f '[table] -> m [Entity (FromDb Live) table] dsortOn :: (LiftedStatement Sorted tables res, TableSetVars Sorting tables, Sortable ord, Selection f) => (Variables Sorting tables -> ord) -> DbStatement f tables -> res dtake :: (LiftedStatement Limited tables res, SelectionOrSortedSelection f) => Int -> DbStatement f tables -> res dgroupOn :: (Groupable group, TableSetVars Grouping tables, Selection f) => (Variables Grouping tables -> group) -> DbStatement f tables -> GroupStatement group tables dmapAll :: (Mappable map, CanMap f, TableSetVars Mapping tables) => (Variables Mapping tables -> map) -> DbStatement f tables -> DbStatement Mapped '[MapResult map] dgroupMap :: (GroupMappable map, InterpretAsGroupMap map ~ True) => ((AsAggregate group, DbStatement Grouped tables) -> map) -> GroupStatement group tables -> DbStatement Folded '[GroupMapResult map] class Dmap' t dmap' :: Dmap' t => t class LiftedMapStatement fs t res liftMapStatement :: LiftedMapStatement fs t res => DbStatement fs '[t] -> res dmap :: forall f res a b m (ts :: [*]) t. (Dmap' ((a -> b) -> m ts -> DbStatement f '[t]), LiftedMapStatement f t res) => (a -> b) -> m ts -> res class interpretAsGroupMap ~ InterpretAsGroupMap res => LiftedAggregation (interpretAsGroupMap :: Bool) aggr res liftAggregation :: LiftedAggregation interpretAsGroupMap aggr res => AggregateStatement aggr AM -> res dfoldMap :: forall tables aggr f res. (Aggregatable aggr, CanAggregate f, TableSetVars Folding tables, LiftedAggregation (InterpretAsGroupMap res) aggr res) => (Variables Folding tables -> aggr) -> DbStatement f tables -> res dfoldMapInner :: (AsAggregate group ~ GroupMappableThing t AM, LiftedMapStatement Folded (ListToSimpleTuple (TupleToList t ++ TupleToList (AggregationResult aggr))) res, Aggregatable aggr, TableSetVars Folding tables) => (Variables Folding tables -> aggr) -> GroupStatement group tables -> res instance (Internal.Data.Basic.Types.Mappable map0, Internal.Data.Basic.Types.CanMap f0, Internal.Data.Basic.Types.TableSetVars 'Internal.Data.Basic.Types.Mapping tables0, t3 ~ '[Internal.Data.Basic.Types.MapResult map0], t2 ~ Internal.Data.Basic.Types.DbStatement, t1 ~ (->) (Internal.Data.Basic.Types.DbStatement f0 tables0), t0 ~ (->) (Internal.Data.Basic.TypeLevel.ListToTuple (Internal.Data.Basic.Types.Var 'Internal.Data.Basic.Types.Mapping) tables0 -> map0)) => Internal.Data.Basic.Common.Dmap' (t0 (t1 (t2 'Internal.Data.Basic.Types.Mapped t3))) instance (Internal.Data.Basic.Types.Mappable map0, Internal.Data.Basic.Types.CanMap f0, Internal.Data.Basic.Types.TableSetVars 'Internal.Data.Basic.Types.Mapping tables0, t4 ~ Internal.Data.Basic.Types.DbStatement 'Internal.Data.Basic.Types.Mapped '[Internal.Data.Basic.Types.MapResult map0], t3 ~ tables0, t2 ~ f0, t1 ~ (->), t0 ~ (->) (Internal.Data.Basic.TypeLevel.ListToTuple (Internal.Data.Basic.Types.Var 'Internal.Data.Basic.Types.Mapping) tables0 -> map0)) => Internal.Data.Basic.Common.Dmap' (t0 (t1 (Internal.Data.Basic.Types.DbStatement t2 t3) t4)) instance (Internal.Data.Basic.Types.GroupMappable map0, Internal.Data.Basic.Types.InterpretAsGroupMap map0 ~ 'GHC.Types.True, t3 ~ '[Internal.Data.Basic.Types.GroupMapResult map0], t2 ~ Internal.Data.Basic.Types.DbStatement, t1 ~ (->) (Internal.Data.Basic.Types.GroupStatement group0 tables0), t0 ~ (->) ((Internal.Data.Basic.Types.AsAggregate group0, Internal.Data.Basic.Types.DbStatement 'Internal.Data.Basic.Types.Grouped tables0) -> map0)) => Internal.Data.Basic.Common.Dmap' (t0 (t1 (t2 'Internal.Data.Basic.Types.Folded t3))) instance (Internal.Data.Basic.Types.GroupMappable map0, Internal.Data.Basic.Types.InterpretAsGroupMap map0 ~ 'GHC.Types.True, t4 ~ Internal.Data.Basic.Types.DbStatement 'Internal.Data.Basic.Types.Folded '[Internal.Data.Basic.Types.GroupMapResult map0], t3 ~ tables0, t2 ~ group0, t1 ~ (->), t0 ~ (->) ((Internal.Data.Basic.Types.AsAggregate group0, Internal.Data.Basic.Types.DbStatement 'Internal.Data.Basic.Types.Grouped tables0) -> map0)) => Internal.Data.Basic.Common.Dmap' (t0 (t1 (Internal.Data.Basic.Types.GroupStatement t2 t3) t4)) instance (Internal.Data.Basic.Types.DbStatement fs ~ dbs, '[ts1] ~ ts2) => Internal.Data.Basic.Common.LiftedMapStatement fs ts1 (dbs ts2) instance (res ~ [Internal.Control.Effects.Basic.WithoutOnly ts], Control.Effects.MonadEffect Internal.Control.Effects.Basic.Basic m, Database.PostgreSQL.Simple.FromRow.FromRow ts, Internal.Control.Effects.Basic.NoOnly ts) => Internal.Data.Basic.Common.LiftedMapStatement fs ts (m res) instance (Internal.Data.Basic.Types.GroupMappableThing (Internal.Data.Basic.Types.AggregationResult aggr) 'Internal.Data.Basic.Types.AM ~ aggStat, Internal.Data.Basic.Types.Aggregatable aggr, Internal.Data.Basic.Types.InterpretAsGroupMap aggStat ~ 'GHC.Types.True) => Internal.Data.Basic.Common.LiftedAggregation 'GHC.Types.True aggr aggStat instance (Internal.Data.Basic.Types.GroupMappableThing (Internal.Data.Basic.Types.AggregationResult aggr) ~ aggStat, m ~ 'Internal.Data.Basic.Types.AM, Internal.Data.Basic.Types.Aggregatable aggr, Internal.Data.Basic.Types.InterpretAsGroupMap (aggStat m) ~ i) => Internal.Data.Basic.Common.LiftedAggregation i aggr (aggStat m) instance (res ~ Internal.Data.Basic.Types.AggregationResult aggr, Control.Effects.MonadEffect Internal.Control.Effects.Basic.Basic m, Database.PostgreSQL.Simple.FromRow.FromRow res, Internal.Data.Basic.Types.InterpretAsGroupMap (m res) ~ i) => Internal.Data.Basic.Common.LiftedAggregation i aggr (m res) instance (Internal.Data.Basic.Types.DbStatement fs ~ dbs, ts1 ~ ts2) => Internal.Data.Basic.Common.LiftedStatement fs ts1 (dbs ts2) instance (res ~ [Internal.Data.Basic.Types.DbResult ts], Internal.Control.Effects.Basic.AllHaveFromRowInstance ts, Control.Effects.MonadEffect Internal.Control.Effects.Basic.Basic m) => Internal.Data.Basic.Common.LiftedStatement fs ts (m res) module Internal.Data.Basic.Virtual fieldMatch :: forall (toField :: Symbol) (fromField :: Symbol) toTable fromTable c. (TableField toTable toField, TableField fromTable fromField, TableFieldType toTable toField ~ TableFieldType fromTable fromField, Ord (TableFieldType toTable toField), ToField (TableFieldType toTable toField)) => Entity (FromDb c) toTable -> Var Filtering fromTable -> ConditionExp class (Table fromTable, Table toTable, AllSatisfy (TableField fromTable) fromFields, AllSatisfy (TableField toTable) toFields, SameTypes toTable toFields fromTable fromFields, AllTypesSatisfy (TypeSatisfies Ord) fromTable fromFields, AllTypesSatisfy (TypeSatisfies ToField) fromTable fromFields) => AllFieldsMatch (toFields :: [Symbol]) (fromFields :: [Symbol]) toTable fromTable allFieldsMatch :: AllFieldsMatch toFields fromFields toTable fromTable => Entity (FromDb c) toTable -> Var Filtering fromTable -> ConditionExp virtualTableDbExpLens :: forall foreignKeyName c. (ForeignKeyConstraint foreignKeyName, AllFieldsMatch (ForeignKeyToFields foreignKeyName) (ForeignKeyFromFields foreignKeyName) (ForeignKeyTo foreignKeyName) (ForeignKeyFrom foreignKeyName)) => Getter' (Entity (FromDb c) (ForeignKeyTo foreignKeyName)) (DbStatement Filtered '[ForeignKeyFrom foreignKeyName]) type VirtualTable foreignKeyName res = (ForeignKeyConstraint foreignKeyName, AllFieldsMatch (ForeignKeyToFields foreignKeyName) (ForeignKeyFromFields foreignKeyName) (ForeignKeyTo foreignKeyName) (ForeignKeyFrom foreignKeyName), LiftedStatement Filtered '[ForeignKeyFrom foreignKeyName] res) virtualTableLens :: forall foreignKeyName c res. VirtualTable foreignKeyName res => Getter' (Entity (FromDb c) (ForeignKeyTo foreignKeyName)) (res) virtualTableLensProxy :: forall foreignKeyName res c proxy. VirtualTable foreignKeyName res => proxy foreignKeyName -> Getter' (Entity (FromDb c) (ForeignKeyTo foreignKeyName)) (res) instance (Internal.Data.Basic.Types.Table fromTable, Internal.Data.Basic.Types.Table toTable, Internal.Data.Basic.Types.TableField fromTable fromField, Internal.Data.Basic.Types.TableField toTable toField, Internal.Data.Basic.Types.TableFieldType fromTable fromField ~ Internal.Data.Basic.Types.TableFieldType toTable toField, GHC.Classes.Ord (Internal.Data.Basic.Types.TableFieldType toTable toField), Database.PostgreSQL.Simple.ToField.ToField (Internal.Data.Basic.Types.TableFieldType fromTable fromField)) => Internal.Data.Basic.Virtual.AllFieldsMatch '[toField] '[fromField] toTable fromTable instance (Internal.Data.Basic.Types.Table fromTable, Internal.Data.Basic.Types.Table toTable, Internal.Data.Basic.Types.TableField fromTable fromField, Internal.Data.Basic.Types.TableField toTable toField, Internal.Data.Basic.Types.TableFieldType fromTable fromField ~ Internal.Data.Basic.Types.TableFieldType toTable toField, GHC.Classes.Ord (Internal.Data.Basic.Types.TableFieldType toTable toField), Database.PostgreSQL.Simple.ToField.ToField (Internal.Data.Basic.Types.TableFieldType fromTable fromField), Internal.Data.Basic.Virtual.AllFieldsMatch toFields fromFields toTable fromTable) => Internal.Data.Basic.Virtual.AllFieldsMatch (toField : toFields) (fromField : fromFields) toTable fromTable module Internal.Data.Basic.Foreign class ForeignKeyConstraint fk => ForeignKeyFieldsMatch (fk :: Symbol) (fromFields :: [Symbol]) (toFields :: [Symbol]) foreignKeyFieldsMatch :: ForeignKeyFieldsMatch fk fromFields toFields => Entity (FromDb c) (ForeignKeyFrom fk) -> Var Filtering (ForeignKeyTo fk) -> ConditionExp foreignKeyFieldsSet :: ForeignKeyFieldsMatch fk fromFields toFields => Entity entKind (ForeignKeyFrom fk) -> Entity (FromDb c) (ForeignKeyTo fk) -> Entity (WithFieldsSet fromFields entKind) (ForeignKeyFrom fk) type ForeignKeyLensGet fk m = (ForeignKeyConstraint fk, MonadEffect Basic m, Table (ForeignKeyFrom fk), Table (ForeignKeyTo fk), ForeignKeyFieldsMatch fk (ForeignKeyFromFields fk) (ForeignKeyToFields fk)) foreignKeyLensGet :: forall fk m proxy. ForeignKeyLensGet fk m => proxy fk -> Getter' (Entity (FromDb Live) (ForeignKeyFrom fk)) (m (Entity (FromDb Live) (ForeignKeyTo fk))) type ForeignKeyLensSet fk = (ForeignKeyConstraint fk, ForeignKeyFieldsMatch fk (ForeignKeyFromFields fk) (ForeignKeyToFields fk)) foreignKeyLensSet :: forall fk entKind c proxy. ForeignKeyLensSet fk => proxy fk -> PolyOptic Identity (Entity entKind (ForeignKeyFrom fk)) (Entity (WithFieldsSet (ForeignKeyFromFields fk) entKind) (ForeignKeyFrom fk)) () (Entity (FromDb c) (ForeignKeyTo fk)) class ForeignKeyLensProxy t foreignKeyLensProxy :: ForeignKeyLensProxy t => t foreignKeyLens :: forall name o. ForeignKeyLensProxy (Proxy name -> o) => o instance ((Internal.Data.Basic.Types.ForeignKeyConstraint fk0, Control.Effects.MonadEffect Internal.Control.Effects.Basic.Basic m0, Internal.Data.Basic.Types.Table (Internal.Data.Basic.Types.ForeignKeyFrom fk0), Internal.Data.Basic.Types.Table (Internal.Data.Basic.Types.ForeignKeyTo fk0), Internal.Data.Basic.Foreign.ForeignKeyFieldsMatch fk0 (Internal.Data.Basic.Types.ForeignKeyFromFields fk0) (Internal.Data.Basic.Types.ForeignKeyToFields fk0)), t5 ~ Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyFrom fk0), t4 ~ m0 (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyTo fk0)), t3 ~ Data.Functor.Const.Const, t2 ~ (->) (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyFrom fk0)), t1 ~ (->) (m0 (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyTo fk0)) -> Data.Functor.Const.Const (m0 (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyTo fk0))) (m0 (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyTo fk0)))), t0 ~ (->) (proxy0 fk0)) => Internal.Data.Basic.Foreign.ForeignKeyLensProxy (t0 (t1 (t2 (t3 t4 t5)))) instance ((Internal.Data.Basic.Types.ForeignKeyConstraint fk0, Control.Effects.MonadEffect Internal.Control.Effects.Basic.Basic m0, Internal.Data.Basic.Types.Table (Internal.Data.Basic.Types.ForeignKeyFrom fk0), Internal.Data.Basic.Types.Table (Internal.Data.Basic.Types.ForeignKeyTo fk0), Internal.Data.Basic.Foreign.ForeignKeyFieldsMatch fk0 (Internal.Data.Basic.Types.ForeignKeyFromFields fk0) (Internal.Data.Basic.Types.ForeignKeyToFields fk0)), t6 ~ (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyFrom fk0) -> Data.Functor.Const.Const (m0 (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyTo fk0))) (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyFrom fk0))), t5 ~ m0 (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyTo fk0)), t4 ~ m0 (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyTo fk0)), t3 ~ Data.Functor.Const.Const, t2 ~ (->) (m0 (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb 'Internal.Data.Basic.Types.Live) (Internal.Data.Basic.Types.ForeignKeyTo fk0))), t1 ~ (->), t0 ~ (->) (proxy0 fk0)) => Internal.Data.Basic.Foreign.ForeignKeyLensProxy (t0 (t1 (t2 (t3 t4 t5)) t6)) instance ((Internal.Data.Basic.Types.ForeignKeyConstraint fk0, Internal.Data.Basic.Foreign.ForeignKeyFieldsMatch fk0 (Internal.Data.Basic.Types.ForeignKeyFromFields fk0) (Internal.Data.Basic.Types.ForeignKeyToFields fk0)), t3 ~ Internal.Data.Basic.Types.Entity (Internal.Data.Basic.Types.WithFieldsSet (Internal.Data.Basic.Types.ForeignKeyFromFields fk0) entKind0) (Internal.Data.Basic.Types.ForeignKeyFrom fk0), t2 ~ (->) (Internal.Data.Basic.Types.Entity entKind0 (Internal.Data.Basic.Types.ForeignKeyFrom fk0)), t1 ~ (->) (() -> Data.Functor.Identity.Identity (Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb c0) (Internal.Data.Basic.Types.ForeignKeyTo fk0))), t0 ~ (->) (proxy0 fk0)) => Internal.Data.Basic.Foreign.ForeignKeyLensProxy (t0 (t1 (t2 (Data.Functor.Identity.Identity t3)))) instance ((Internal.Data.Basic.Types.ForeignKeyConstraint fk0, Internal.Data.Basic.Foreign.ForeignKeyFieldsMatch fk0 (Internal.Data.Basic.Types.ForeignKeyFromFields fk0) (Internal.Data.Basic.Types.ForeignKeyToFields fk0)), t4 ~ (Internal.Data.Basic.Types.Entity entKind0 (Internal.Data.Basic.Types.ForeignKeyFrom fk0) -> Data.Functor.Identity.Identity (Internal.Data.Basic.Types.Entity (Internal.Data.Basic.Types.WithFieldsSet (Internal.Data.Basic.Types.ForeignKeyFromFields fk0) entKind0) (Internal.Data.Basic.Types.ForeignKeyFrom fk0))), t3 ~ Internal.Data.Basic.Types.Entity ('Internal.Data.Basic.Types.FromDb c0) (Internal.Data.Basic.Types.ForeignKeyTo fk0), t2 ~ (->) (), t1 ~ (->), t0 ~ (->) (proxy0 fk0)) => Internal.Data.Basic.Foreign.ForeignKeyLensProxy (t0 (t1 (t2 (Data.Functor.Identity.Identity t3)) t4)) instance (Internal.Data.Basic.Types.ForeignKeyConstraint fk, from ~ Internal.Data.Basic.Types.ForeignKeyFrom fk, to ~ Internal.Data.Basic.Types.ForeignKeyTo fk, Internal.Data.Basic.Types.TableField to toField, Internal.Data.Basic.Types.TableField from fromField, Internal.Data.Basic.Types.TableFieldType to toField ~ Internal.Data.Basic.Types.TableFieldType from fromField, Database.PostgreSQL.Simple.ToField.ToField (Internal.Data.Basic.Types.TableFieldType from fromField), GHC.Classes.Ord (Internal.Data.Basic.Types.TableFieldType to toField), Internal.Data.Basic.Types.KindOfDbExp (Internal.Data.Basic.Types.TableFieldType from fromField) ~ 'Internal.Data.Basic.Types.LiteralExp) => Internal.Data.Basic.Foreign.ForeignKeyFieldsMatch fk '[fromField] '[toField] instance (from ~ Internal.Data.Basic.Types.ForeignKeyFrom fk, to ~ Internal.Data.Basic.Types.ForeignKeyTo fk, Internal.Data.Basic.Types.TableField to toField, Internal.Data.Basic.Types.TableField from fromField, Internal.Data.Basic.Types.TableFieldType to toField ~ Internal.Data.Basic.Types.TableFieldType from fromField, Database.PostgreSQL.Simple.ToField.ToField (Internal.Data.Basic.Types.TableFieldType from fromField), GHC.Classes.Ord (Internal.Data.Basic.Types.TableFieldType to toField), Internal.Data.Basic.Foreign.ForeignKeyFieldsMatch fk (f1 : f1s) (f2 : f2s), Internal.Data.Basic.Types.KindOfDbExp (Internal.Data.Basic.Types.TableFieldType from fromField) ~ 'Internal.Data.Basic.Types.LiteralExp) => Internal.Data.Basic.Foreign.ForeignKeyFieldsMatch fk (fromField : f1 : f1s) (toField : f2 : f2s) module Internal.Data.Basic.Replace class PrimaryKeyMatch (fields :: [Symbol]) table primaryKeyMatch :: PrimaryKeyMatch fields table => Entity (FromDb c) table -> Var Filtering table -> ConditionExp class SetAllFields fields table setAllFields :: SetAllFields fields table => Entity (FromDb c) table -> Var Updating table -> UpdateExp fields table save :: forall table pk fields c m. (Table table, Just pk ~ TablePrimaryKey table, fields ~ UniqueFields pk, PrimaryKeyMatch fields table, SetAllFields (TableFields table) table, MonadEffect Basic m) => Entity (FromDb c) table -> m (Entity (FromDb Live) table) instance (GHC.Classes.Ord (Internal.Data.Basic.Types.TableFieldType table field), Internal.Data.Basic.Types.TableField table field, Database.PostgreSQL.Simple.ToField.ToField (Internal.Data.Basic.Types.TableFieldType table field), Internal.Data.Basic.Types.KindOfDbExp (Internal.Data.Basic.Types.TableFieldType table field) ~ 'Internal.Data.Basic.Types.LiteralExp) => Internal.Data.Basic.Replace.PrimaryKeyMatch '[field] table instance (GHC.Classes.Ord (Internal.Data.Basic.Types.TableFieldType table field), Internal.Data.Basic.Types.TableField table field, Database.PostgreSQL.Simple.ToField.ToField (Internal.Data.Basic.Types.TableFieldType table field), fields ~ (f : fs), Internal.Data.Basic.Replace.PrimaryKeyMatch fields table, Internal.Data.Basic.Types.KindOfDbExp (Internal.Data.Basic.Types.TableFieldType table field) ~ 'Internal.Data.Basic.Types.LiteralExp) => Internal.Data.Basic.Replace.PrimaryKeyMatch (field : f : fs) table instance Internal.Data.Basic.Replace.SetAllFields '[] table instance (Internal.Data.Basic.Replace.SetAllFields fields table, Internal.Data.Basic.TypeLevel.CheckWithError (Internal.Data.Basic.TypeLevel.Not (Internal.Data.Basic.TypeLevel.Elem field fields)) (('GHC.TypeLits.Text "Cannot update the field " 'GHC.TypeLits.:<>: 'GHC.TypeLits.ShowType field) 'GHC.TypeLits.:<>: 'GHC.TypeLits.Text " because it's already updated in this expression"), Internal.Data.Basic.Types.TableField table field, Database.PostgreSQL.Simple.ToField.ToField (Internal.Data.Basic.Types.TableFieldType table field), Internal.Data.Basic.Types.KindOfDbExp (Internal.Data.Basic.Types.TableFieldType table field) ~ 'Internal.Data.Basic.Types.LiteralExp) => Internal.Data.Basic.Replace.SetAllFields (field : fields) table module Internal.Data.Basic -- | module Internal. : Data.Basic.TH.Types Description : Data types and -- utility function used during TH generation phase License : MIT -- -- This module Internal.defines functions that are used to generate -- Template Haskell code from AST. For AST description take a look at -- Types. module Internal.Data.Basic.TH.Generator -- | Generates a data constructor for an entity -- --
-- data Post = Post { _ostId :: Key
-- , _ostName :: Text
-- , _ostUserId :: Key } deriving (Show, Read, Generic)
--
dataConstructor :: EntityInfo -> Dec
-- | Generates a fromRow instance for a entity.
--
-- -- instance FromRow Post where -- fromRow = Post <$> field <*> field <*> field ---- -- fromRowInstance takes a name of the entity and a list of [a], which is -- just used to count how many fields does the entity have - nothing -- else. It generates something similar shown in a code snippet above - a -- working FromRow instance for that datatype. fromRowInstance :: Name -> [a] -> Dec -- | Generates field optics for all entities fieldOptics :: [EntityInfo] -> [Dec] -- | Generates field optics for a column -- --
-- name :: (FieldOptic "username" fun inType outType inVal outVal) => PolyOptic fun inType outType inVal outVal -- name = fieldOpticProxy (Proxy :: Proxy "username") --fieldOptic :: Text -> [Dec] -- | Applies basic constraint depending on sql constraint If columns is -- marked as primary or unique, add the Unique haskell datatype fieldConstraint :: Constraint -> Maybe [Type] -- | Generates a table field instance for a column -- --
-- instance TableField Post "user_id" where -- type TableFieldType Post "user_id" = Key -- tableFieldLens = ostUserId --tableField :: EntityInfo -> ColumnInfo -> Dec -- | Generates required table field instances for all entities tableFields :: [EntityInfo] -> [Dec] -- | Generates final type for the sql column finalType :: ColumnInfo -> Type -- | Generates initial accessor for the table -- --
-- allPosts = allRows (Proxy :: Proxy "post") --initialAccessor :: EntityInfo -> [Dec] -- | Generates foreign key optics fkOptics :: [ForeignKeyConstraint] -> [Dec] -- | Generates foreign key optic -- --
-- author :: ForeignKeyLensProxy (Proxy "blog_post_author_fkey" -> o) => o -- author = foreignKeyLens @"blog_post_author_fkey" --fkOptic :: ForeignKeyConstraint -> [Dec] -- | Generates virtual table optics virtualTables :: [ForeignKeyConstraint] -> [Dec] -- | Generates virtual table optic -- --
-- posts :: VirtualTable "blog_post_author_fkey" res
-- => Getter' (Entity ('FromDb c) (ForeignKeyTo "blog_post_author_fkey")) res
-- posts = virtualTableLensProxy (Proxy :: Proxy "blog_post_author_fkey")
--
virtualTable :: ForeignKeyConstraint -> [Dec]
-- | Generates all constraint declarations from the ParseContext
allConstraints :: ParseContext -> [Dec]
-- | Generates unique key constraint instance
--
-- -- instance UniqueConstraint "blog_user_pkey" where -- type UniqueTable "blog_user_pkey" = User -- type UniqueFields "blog_user_pkey" = '["id"] --uniqueConstraintInstance :: UniqueKeyConstraint -> [Dec] -- | Generates primary key instance -- --
-- instance PrimaryKeyConstraint "blog_user_pkey" --primaryKeyInstance :: PrimaryKeyConstraint -> [Dec] -- | Generates foreign key instance -- --
-- instance ForeignKeyConstraint "blog_post_author_fkey" where -- type ForeignKeyFrom "blog_post_author_fkey" = Post -- type ForeignKeyFromFields "blog_post_author_fkey" = '["author"] -- type ForeignKeyTo "blog_post_author_fkey" = User -- type ForeignKeyToFields "blog_post_author_fkey" = '["id"] --foreignKeyConstraint :: ForeignKeyConstraint -> Dec -- | Generates a table instance for an entity from a ParseContext -- --
-- instance Table Post where -- type TableName Post = "blog_post" -- type TableFields Post = ["id", "name", "author"] -- type TableConstraints Post = '[] -- type TablePrimaryKey Post = 'Nothing -- type TableRequiredFields Post = ['DynamicDefault 'id, 'Required "name", 'Required "author"] --tableInstance :: ParseContext -> EntityInfo -> [Dec] -- | Generates a empty entity -- --
-- newPost = Entity ('Fresh ['DynamicDefault "id", 'Required "name", 'Required "author"])
-- newPost = Entity (Post 1 "" 1)
--
emptyEntity :: ParseContext -> EntityInfo -> [Dec]
-- | Applies Required constraint to list of columns
required :: [ColumnInfo] -> [Type]
-- | Applies DynamicDefault constraint to a list of columns
dynamicDefault :: [ColumnInfo] -> [Type]
-- | Modifies column type depending on column constraints
applyConstraint :: ColumnInfo -> ColumnConstraint -> Type -> Type
-- | Generates coerce body. See NullValue why this is needed
coerceBody :: EntityInfo -> Body
nullValue' :: Int -> Exp -> Exp
module Internal.Data.Basic.TH.Compiler
compileSQL :: Text -> Q (Either ParseError [Statement])
compileContext :: ParseContext -> Q [Dec]
compileEntity :: ParseContext -> EntityInfo -> [Dec]
compileSQLStatements :: (Throws ParseError m, MonadIO m) => ParseContext -> [Statement] -> m ParseContext
-- | Updates CompileContext with data. The kind of data that is
-- being added depends on the statement being processed.
compileSQLStatement :: (Throws ParseError m, MonadIO m) => ParseContext -> Statement -> m ParseContext
-- | Updates CompileContext with constraints that have been added
-- using alter table
handleAlterTableOperations :: Throws ParseError m => ParseContext -> Name -> AlterTableAction -> m ParseContext
-- | Updates compile context from CREATE TABLE statement. Used when CREATE
-- TABLE statement is used. Adds to CompileContext any
-- constraints that are found and returns updated EntityInfo and
-- CompileContext
updateContext :: Throws ParseError m => ParseContext -> Name -> EntityInfo -> AttributeDef -> m (ParseContext, EntityInfo)
-- | Adds sql row constraints to compile context
compileRowConstraint :: Throws ParseError m => ParseContext -> EntityInfo -> ColumnInfo -> RowConstraint -> m (ParseContext, ColumnInfo)
-- | Adds sql constraint to compile context. If a sql constraint is
-- unnamed, it will be named.
compileConstraint :: Throws ParseError m => ParseContext -> EntityInfo -> Constraint -> m ParseContext
-- | Adds sql constraint to compile context.
compileConstraint' :: Throws ParseError m => ParseContext -> EntityInfo -> Constraint -> m ParseContext
module Internal.Data.Basic.TH
-- | Generates haskell code from an SQL file.
mkFromFile :: FilePath -> Q [Dec]
-- | Generates haskell code from multiple SQL files.
mkFromFiles :: [FilePath] -> Q [Dec]
-- | Allows you to print generated template haskell code to a file
printToFile :: [FilePath] -> FilePath -> Q [Dec]
-- | This tutorial describes how to use the basic library. Usually you
-- would use the functions provided in the Internal.Data.Basic.TH module
-- (re-exported by Data.Basic) to generate all of the declarations in
-- this tutorial from your database schema.
--
-- Basic is a database-first library meaning the schema comes from the
-- database instead of your code. The library provides mechanisms for
-- "explaining" your schema to the compiler. It can then use this
-- information to provide a typesafe and convenient access and control of
-- your data.
--
-- We start by defining a data type.
--
--
-- data User = User { _serId :: Key
-- , _serName :: Text } deriving (Eq, Ord, Read, Show)
--
--
--
-- Most of the functionality is implemented through lenses so we need to
-- generate them for our datatype.
--
-- -- makeLenses ''User -- ---- -- Next we provide a set of instances for our type. These describe how -- our type maps to a database table. We use type level strings to -- represent database names of the fields. Instances are needed for each -- field and for each constraint on the table. We also need a -- FromRow instance so the type can actually be deserialized from -- the query result. -- --
-- instance Table User where -- -- the database name for this table -- type TableName User = "blog_user" -- -- -- a type level list of all the fields in this table -- type TableFields User = ["id", "name"] -- -- -- a type level list of constraints on this table; each of these will need a corresponding -- -- instance that provides additional info -- type TableConstraints User = '[ 'Unique "blog_user_pkey"] -- -- -- the table can optionally have a primary key; for this we use a type level Maybe value -- type TablePrimaryKey User = 'Just "blog_user_pkey" -- -- -- a type level list of fields that are either Required or DynamicDefault -- type TableRequiredFields User = ['Required "id", 'Required "name"] -- -- -- a default user -- -- don't worry about undefined values, the types will make sure you can't accidentally evaluate -- -- them -- newEntity = Entity (User undefined undefined) -- -- instance UniqueConstraint "blog_user_pkey" where -- -- the table which this constraint targets -- type UniqueTable "blog_user_pkey" = User -- -- -- you can have multiple fields that make up one unique constraint -- type UniqueFields "blog_user_pkey" = '["id"] -- -- -- PrimaryKeyConstraint is really just a synonym for a unique constraint + the condition that -- -- all the values must not be null -- instance PrimaryKeyConstraint "blog_user_pkey" -- -- -- each field gets an instance saying what Haskell type it maps to and providing a lens -- instance TableField User "id" where -- type TableFieldType User "id" = Key -- tableFieldLens = serId -- -- instance TableField User "name" where -- type TableFieldType User "name" = Text -- tableFieldLens = serName -- -- instance FromRow User where -- fromRow = User <$> field <*> field -- ---- -- Now we do the same for a "blog_post" table. -- --
-- data Post = Post { _ostId :: Key
-- , _ostName :: Text
-- , _ostUserId :: Key } deriving (Eq, Ord, Read, Show)
--
-- instance Table Post where
-- type TableName Post = "blog_post"
-- type TableFields Post = ["id", "name", "author"]
-- type TableConstraints Post = '[ 'ForeignKey "blog_post_author_fkey"]
-- type TablePrimaryKey Post = 'Just "blog_post_pkey"
-- type TableRequiredFields Post = ['Required "id", 'Required "name", 'Required "author"]
-- newEntity = Entity (Post undefined undefined)
--
-- instance UniqueConstraint "blog_post_pkey" where
-- type UniqueTable "blog_post_pkey" = Post
-- type UniqueFields "blog_post_pkey" = '["id"]
--
-- instance PrimaryKeyConstraint "blog_post_pkey"
--
-- instance FromRow Post where
-- fromRow = Post <$> field <*> field <*> field
-- makeLenses ''Post
--
-- instance TableField Post "id" where
-- type TableFieldType Post "id" = Key
-- tableFieldLens = ostId
--
-- instance TableField Post "name" where
-- type TableFieldType Post "name" = Text
-- tableFieldLens = ostName
--
-- instance TableField Post "author" where
-- type TableFieldType Post "author" = Key
-- tableFieldLens = ostUserId
--
--
--
-- Next, we declare a foreign key from the post table to the user table.
-- The instance is more or less self explanatory.
--
-- -- instance ForeignKeyConstraint "blog_post_author_fkey" where -- type ForeignKeyFrom "blog_post_author_fkey" = Post -- type ForeignKeyFromFields "blog_post_author_fkey" = '["author"] -- type ForeignKeyTo "blog_post_author_fkey" = User -- type ForeignKeyToFields "blog_post_author_fkey" = '["id"] -- ---- -- Now we're ready to create the lenses and values that we'll use to -- manipulate our data. Again, keep in mind that all of this can be -- generated for you via the TH functions, directly from your SQL schema. -- --
-- -- this value will represent a virtual "list" of all the users in the database
-- allUsers :: AllRows User m r => m r
-- allUsers = allRows "blog_user"
--
-- -- this is the same, but for posts
-- allPosts :: AllRows Post m r => m r
-- allPosts = allRows "blog_post"
--
-- -- we use this value to construct new users
-- newUser :: Entity ('Fresh ['Required "id", 'Required "name"]) User
-- newUser = newEntity
--
-- newPost :: Entity ('Fresh ['Required "id", 'Required "name", 'Required "author"]) Post
-- newPost = newEntity
--
-- -- we can use this lens to get all posts belonging to some author
-- posts :: VirtualTable "blog_post_author_fkey" m r
-- => 'Getter'\' (Entity ('FromDb c) (ForeignKeyTo "blog_post_author_fkey")) (m r)
-- posts = virtualTableLens "blog_post_author_fkey"
--
-- -- a lens to access the id field of any table that has it; same for name and authorId
-- id :: FieldOpticProxy (Proxy "id" -> o) => o
-- id = fieldOptic "id"
--
-- name :: FieldOpticProxy (Proxy "name" -> o) => o
-- name = fieldOptic "name"
--
-- authorId :: FieldOpticProxy (Proxy "author" -> o) => o
-- authorId = fieldOptic "author"
--
-- -- this lens will let us get the actual user value from a post, through the foreign key
-- author :: ForeignKeyLensProxy (Proxy "blog_post_author_fkey" -> o) => o
-- author = foreignKeyLens @"blog_post_author_fkey"
--
--
--
-- Finally, we get to a usage example.
--
-- -- test1 :: (MonadIO m, MonadEffect Basic m) => m () -- test1 = do -- void $ ddelete allPosts -- void $ ddelete allUsers -- -- -- we use the lens to construct values -- let user = newUser & name .~ John -- & id .~ 1 -- -- -- check this out: try not setting one of the fields on user -- -- the compiler will not let you insert the value into the database -- user <- insert user -- let post = newPost & id .~ 1 -- & name .~ "New post" -- & author .~ user -- post <- insert post -- -- -- to access our data we use functions like dfilter and pretend we're dealing with -- -- lists of values -- users <- dfilter (\u -> (u ^. id) In [1, 3, 4]) allUsers -- -- -- get the author of a post, update the name and save it to the database -- auth <- post ^. author -- void $ save (auth & name .~ "John H") -- -- let user2 = newUser & name .~ Mike -- & id .~ 2 -- void $ insert user2 -- -- -- sorting and taking works just like lists do, at least syntactically -- -- the semantics still need to be translated to SQL so first taking, then sorting won't -- -- compile -- -- you can use the usual Down newtype for switching from ascending to descending -- us <- dtake 1 $ dsortOn (\u -> Down (u ^. id)) allUsers -- print us -- -- -- dupdate is like mapM -- void $ dupdate (\u' -> u' & id .~ (2 :: Key)) allUsers -- -- [mike] <- dfilter (\u' -> u' ^. id ==. (1 :: Key)) allUsers -- -- here we're using that special virtual table lens to get a list of all posts by Mike -- psts <- mike ^. posts -- -- we can also filter on that list like it's a table in the database -- somePsts <- dfilter (\p -> p ^. id ==. (0 :: Key)) (mike ^. posts) -- -- -- joins are done with the djoin function; the resulting list can also be filtered -- usersPosts <- allUsers djoin allPosts -- print usersPosts -- -- test :: IO () -- test = do -- conn <- connectPostgreSQL "host=localhost port=5432 user=postgres dbname=postgres password=admin connect_timeout=10" -- handleBasicPsql conn test1 -- --module Data.Basic.Tutorial module Data.Basic data Key data Point Point :: {-# UNPACK #-} !Double -> {-# UNPACK #-} !Double -> Point class (KnownSymbol (TableName table), AllSatisfy (TableField table) (TableFields table), AllSatisfy KnownSymbol (TableFields table), AllSatisfy (ValidConstraint table) (TableConstraints table), AllTypesSatisfy (TypeSatisfies ToField) table (TableFields table), OnMaybe (() :: Constraint) PrimaryKeyConstraint (TablePrimaryKey table), FromRow table) => Table table where type TableName table = (name :: Symbol) | name -> table type TableFields table :: [Symbol] type TableConstraints table :: [FieldConstraint] type TablePrimaryKey table :: Maybe Symbol type TableRequiredFields table :: [MissingField] where { type family TableName table = (name :: Symbol) | name -> table; type family TableFields table :: [Symbol]; type family TableConstraints table :: [FieldConstraint]; type family TablePrimaryKey table :: Maybe Symbol; type family TableRequiredFields table :: [MissingField]; } newEntity :: Table table => Entity (Fresh (TableRequiredFields table)) table class (KnownSymbol name, IsDbExp (TableFieldType table name) ~ False) => TableField (table :: *) (name :: Symbol) where type TableFieldType table name :: * where { type family TableFieldType table name :: *; } tableFieldLens :: TableField table name => Lens' table (TableFieldType table name) class (AllSatisfy (TableField (UniqueTable name)) (UniqueFields name), KnownSymbol name) => UniqueConstraint (name :: Symbol) where type UniqueTable name :: * type UniqueFields name :: [Symbol] where { type family UniqueTable name :: *; type family UniqueFields name :: [Symbol]; } class (UniqueConstraint name, AllTypesSatisfy NotNull (UniqueTable name) (UniqueFields name)) => PrimaryKeyConstraint (name :: Symbol) class (KnownSymbol name, AllSatisfy (TableField (ForeignKeyFrom name)) (ForeignKeyFromFields name), AllSatisfy (TableField (ForeignKeyTo name)) (ForeignKeyToFields name), SameTypes (ForeignKeyTo name) (ForeignKeyToFields name) (ForeignKeyFrom name) (ForeignKeyFromFields name)) => ForeignKeyConstraint (name :: Symbol) where type ForeignKeyFrom name :: * type ForeignKeyTo name :: * type ForeignKeyFromFields name :: [Symbol] type ForeignKeyToFields name :: [Symbol] where { type family ForeignKeyFrom name :: *; type family ForeignKeyTo name :: *; type family ForeignKeyFromFields name :: [Symbol]; type family ForeignKeyToFields name :: [Symbol]; } -- | Defines MissingField kind. data MissingField Required :: Symbol -> MissingField DynamicDefault :: Symbol -> MissingField data FieldConstraint Unique :: Symbol -> FieldConstraint ForeignKey :: Symbol -> FieldConstraint type AllRows table res = (Table table, LiftedStatement Unfiltered '[table] res) newtype Entity (entKind :: EntityKind) a Entity :: a -> Entity a data EntityKind Fresh :: [MissingField] -> EntityKind FromDb :: Cached -> EntityKind type VirtualTable foreignKeyName res = (ForeignKeyConstraint foreignKeyName, AllFieldsMatch (ForeignKeyToFields foreignKeyName) (ForeignKeyFromFields foreignKeyName) (ForeignKeyTo foreignKeyName) (ForeignKeyFrom foreignKeyName), LiftedStatement Filtered '[ForeignKeyFrom foreignKeyName] res) virtualTableLens :: forall foreignKeyName c res. VirtualTable foreignKeyName res => Getter' (Entity (FromDb c) (ForeignKeyTo foreignKeyName)) (res) type Getter' s a = PolyOptic (Const a) s s a a class FieldOpticProxy t fieldOptic :: forall name o. FieldOpticProxy (Proxy name -> o) => o class ForeignKeyLensProxy t foreignKeyLens :: forall name o. ForeignKeyLensProxy (Proxy name -> o) => o class Monad m => MonadEffect effKind (m :: * -> *) data Basic allRows :: forall tableName table res. (TableName table ~ tableName, AllRows table res) => res ddelete :: (LiftedStatement Deleted '[table] res, Selection f, Table table) => DbStatement f '[table] -> res dupdate :: (MonadEffect Basic m, FromRow table, Selection f) => (Var Updating table -> UpdateExp fields table) -> DbStatement f '[table] -> m [Entity (FromDb Live) table] insert :: (CanInsert entKind table, MonadEffect Basic m, FromRow table) => Entity entKind table -> m (Entity (FromDb Live) table) dfilter :: (LiftedStatement Filtered tables res, TableSetVars Filtering tables, Selection f) => (Variables Filtering tables -> ConditionExp) -> DbStatement f tables -> res save :: forall table pk fields c m. (Table table, Just pk ~ TablePrimaryKey table, fields ~ UniqueFields pk, PrimaryKeyMatch fields table, SetAllFields (TableFields table) table, MonadEffect Basic m) => Entity (FromDb c) table -> m (Entity (FromDb Live) table) dtake :: (LiftedStatement Limited tables res, SelectionOrSortedSelection f) => Int -> DbStatement f tables -> res djoin :: LiftedStatement Unfiltered (tables1 ++ tables2) res => DbStatement Unfiltered tables1 -> DbStatement Unfiltered tables2 -> res dsortOn :: (LiftedStatement Sorted tables res, TableSetVars Sorting tables, Sortable ord, Selection f) => (Variables Sorting tables -> ord) -> DbStatement f tables -> res dfoldMap :: forall tables aggr f res. (Aggregatable aggr, CanAggregate f, TableSetVars Folding tables, LiftedAggregation (InterpretAsGroupMap res) aggr res) => (Variables Folding tables -> aggr) -> DbStatement f tables -> res dfoldMapInner :: (AsAggregate group ~ GroupMappableThing t AM, LiftedMapStatement Folded (ListToSimpleTuple (TupleToList t ++ TupleToList (AggregationResult aggr))) res, Aggregatable aggr, TableSetVars Folding tables) => (Variables Folding tables -> aggr) -> GroupStatement group tables -> res dmap :: forall f res a b m (ts :: [*]) t. (Dmap' ((a -> b) -> m ts -> DbStatement f '[t]), LiftedMapStatement f t res) => (a -> b) -> m ts -> res dgroupOn :: (Groupable group, TableSetVars Grouping tables, Selection f) => (Variables Grouping tables -> group) -> DbStatement f tables -> GroupStatement group tables rawQuery :: forall a r m. (MonadEffect Basic m, FromRow a, ToRow r) => Text -> r -> m [Entity (FromDb Live) a] (<.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 <. (>.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 >. (==.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 ==. (/=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 /=. (<=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 <=. (>=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 >=. (&&.) :: ConditionExp -> ConditionExp -> ConditionExp infix 3 &&. (||.) :: ConditionExp -> ConditionExp -> ConditionExp infix 2 ||. data ConditionExp [In] :: LiteralCollection collection a => DbExp k a -> collection -> ConditionExp newtype Avg a Avg :: a -> Avg a newtype Count a Count :: a -> Count a newtype Min a :: * -> * Min :: a -> Min a [getMin] :: Min a -> a newtype Max a :: * -> * Max :: a -> Max a [getMax] :: Max a -> a -- | Monoid under addition. newtype Sum a :: * -> * Sum :: a -> Sum a [getSum] :: Sum a -> a -- | Handles SQL by querying a PostgreSQL database. handleBasicPsql :: MonadIO m => Connection -> EffectHandler Basic m a -> m a handleBasic :: Functor m => (forall b. FromRow b => SqlRequest b -> m [b]) -> EffectHandler Basic m a -> m a -- | Attempt to make a connection based on a libpq connection string. See -- https://www.postgresql.org/docs/9.5/static/libpq-connect.html#LIBPQ-CONNSTRING -- for more information. Also note that environment variables also affect -- parameters not provided, parameters provided as the empty string, and -- a few other things; see -- https://www.postgresql.org/docs/9.5/static/libpq-envars.html -- for details. Here is an example with some of the most commonly used -- parameters: -- --
-- host='db.somedomain.com' port=5432 ... ---- -- This attempts to connect to db.somedomain.com:5432. Omitting -- the port will normally default to 5432. -- -- On systems that provide unix domain sockets, omitting the host -- parameter will cause libpq to attempt to connect via unix domain -- sockets. The default filesystem path to the socket is constructed from -- the port number and the DEFAULT_PGSOCKET_DIR constant defined -- in the pg_config_manual.h header file. Connecting via unix -- sockets tends to use the peer authentication method, which is -- very secure and does not require a password. -- -- On Windows and other systems without unix domain sockets, omitting the -- host will default to localhost. -- --
-- ... dbname='postgres' user='postgres' password='secret \' \\ pw' ---- -- This attempts to connect to a database named postgres with -- user postgres and password secret ' \ pw. Backslash -- characters will have to be double-quoted in literal Haskell strings, -- of course. Omitting dbname and user will both -- default to the system username that the client process is running as. -- -- Omitting password will default to an appropriate password -- found in the pgpass file, or no password at all if a matching -- line is not found. See -- https://www.postgresql.org/docs/9.5/static/libpq-pgpass.html -- for more information regarding this file. -- -- As all parameters are optional and the defaults are sensible, the -- empty connection string can be useful for development and exploratory -- use, assuming your system is set up appropriately. -- -- On Unix, such a setup would typically consist of a local postgresql -- server listening on port 5432, as well as a system user, database -- user, and database sharing a common name, with permissions granted to -- the user on the database. -- -- On Windows, in addition you will either need pg_hba.conf to -- specify the use of the trust authentication method for the -- connection, which may not be appropriate for multiuser or production -- machines, or you will need to use a pgpass file with the -- password or md5 authentication methods. -- -- See -- https://www.postgresql.org/docs/9.5/static/client-authentication.html -- for more information regarding the authentication process. -- -- SSL/TLS will typically "just work" if your postgresql server supports -- or requires it. However, note that libpq is trivially vulnerable to a -- MITM attack without setting additional SSL connection parameters. In -- particular, sslmode needs to be set to require, -- verify-ca, or verify-full in order to perform -- certificate validation. When sslmode is require, -- then you will also need to specify a sslrootcert file, -- otherwise no validation of the server's identity will be performed. -- Client authentication via certificates is also possible via the -- sslcert and sslkey parameters. See -- https://www.postgresql.org/docs/9.5/static/libpq-ssl.html for -- detailed information regarding libpq and SSL. connectPostgreSQL :: ByteString -> IO Connection -- | Generates haskell code from an SQL file. mkFromFile :: FilePath -> Q [Dec] -- | Generates haskell code from multiple SQL files. mkFromFiles :: [FilePath] -> Q [Dec] -- | Allows you to print generated template haskell code to a file printToFile :: [FilePath] -> FilePath -> Q [Dec] -- | A collection type that can be converted from a sequence of fields. -- Instances are provided for tuples up to 10 elements and lists of any -- length. -- -- Note that instances can be defined outside of postgresql-simple, which -- is often useful. For example, here's an instance for a user-defined -- pair: -- --
-- data User = User { name :: String, fileQuota :: Int }
--
-- instance FromRow User where
-- fromRow = User <$> field <*> field
--
--
-- The number of calls to field must match the number of fields
-- returned in a single row of the query result. Otherwise, a
-- ConversionFailed exception will be thrown.
--
-- Note that field evaluates its result to WHNF, so the caveats
-- listed in mysql-simple and very early versions of postgresql-simple no
-- longer apply. Instead, look at the caveats associated with
-- user-defined implementations of fromField.
class FromRow a
fromRow :: FromRow a => RowParser a
field :: FromField a => RowParser a
data Cached
Live :: Cached
Cached :: Cached
module Data.Basic.Example
data User
User :: {-# UNPACK #-} !Key -> {-# UNPACK #-} !Text -> Point -> User
[$sel:_userId:User] :: User -> {-# UNPACK #-} !Key
[$sel:_userName:User] :: User -> {-# UNPACK #-} !Text
[$sel:_userLocation:User] :: User -> Point
userName :: Lens' User Text
userLocation :: Lens' User Point
userId :: Lens' User Key
data Post
Post :: Key -> Text -> Key -> Post
[$sel:_postId:Post] :: Post -> Key
[$sel:_postName:Post] :: Post -> Text
[$sel:_postUserId:Post] :: Post -> Key
postUserId :: Lens' Post Key
postName :: Lens' Post Text
postId :: Lens' Post Key
allUsers :: AllRows User res => res
allPosts :: AllRows Post res => res
newUser :: Entity (Fresh '[Required "id", Required "name", Required "location"]) User
newPost :: Entity (Fresh '[Required "id", Required "name", Required "author"]) Post
posts :: VirtualTable "blog_post_author_fkey" res => Getter' (Entity (FromDb c) (ForeignKeyTo "blog_post_author_fkey")) res
id :: FieldOpticProxy (Proxy "id" -> o) => o
name :: FieldOpticProxy (Proxy "name" -> o) => o
location :: FieldOpticProxy (Proxy "location" -> o) => o
authorId :: FieldOpticProxy (Proxy "author" -> o) => o
author :: ForeignKeyLensProxy (Proxy "blog_post_author_fkey" -> o) => o
test1 :: (MonadIO m, MonadEffect Basic m) => m ()
test :: IO ()
putQ :: Show a => Q a -> IO ()
putQLn :: Show a => Q a -> IO ()
instance Internal.Data.Basic.Types.Table Data.Basic.Example.Post
instance Internal.Data.Basic.Types.UniqueConstraint "blog_post_pkey"
instance Internal.Data.Basic.Types.PrimaryKeyConstraint "blog_post_pkey"
instance Database.PostgreSQL.Simple.FromRow.FromRow Data.Basic.Example.Post
instance Internal.Data.Basic.Types.TableField Data.Basic.Example.Post "id"
instance Internal.Data.Basic.Types.TableField Data.Basic.Example.Post "name"
instance Internal.Data.Basic.Types.TableField Data.Basic.Example.Post "author"
instance Internal.Data.Basic.Types.ForeignKeyConstraint "blog_post_author_fkey"
instance GHC.Show.Show Data.Basic.Example.Post
instance GHC.Read.Read Data.Basic.Example.Post
instance GHC.Classes.Ord Data.Basic.Example.Post
instance GHC.Classes.Eq Data.Basic.Example.Post
instance Internal.Data.Basic.Types.Table Data.Basic.Example.User
instance Internal.Data.Basic.Types.UniqueConstraint "blog_user_pkey"
instance Internal.Data.Basic.Types.PrimaryKeyConstraint "blog_user_pkey"
instance Internal.Data.Basic.Types.TableField Data.Basic.Example.User "id"
instance Internal.Data.Basic.Types.TableField Data.Basic.Example.User "name"
instance Internal.Data.Basic.Types.TableField Data.Basic.Example.User "location"
instance Database.PostgreSQL.Simple.FromRow.FromRow Data.Basic.Example.User
instance GHC.Show.Show Data.Basic.Example.User
instance GHC.Read.Read Data.Basic.Example.User
instance GHC.Classes.Ord Data.Basic.Example.User
instance GHC.Classes.Eq Data.Basic.Example.User