Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data VarContext
- newtype Var ctx a = Var Int
- newtype Key = Key Int
- data MissingField
- data Cached
- data EntityKind
- = Fresh [MissingField]
- | FromDb Cached
- newtype Entity entKind a = Entity {
- _getEntity :: a
- getEntity :: forall entKind a entKind a. Iso (Entity entKind a) (Entity entKind a) a a
- toFreshEntity :: forall fs c a. Entity (FromDb c) a -> Entity (Fresh fs) a
- data FieldConstraint
- type family MissingFields (entKind :: EntityKind) :: [MissingField] where ...
- type SetFields missing table = TableFields table `Without` MissingFieldsNames missing
- class AllSatisfy (TableField table) fields => AllTypesSatisfy c table fields where
- class (KnownSymbol n, ToJSON a) => JSONableField a n
- class GetEntityFromValue fs a miss where
- type family SameTypes toTable (toFields :: [Symbol]) fromTable (fromFields :: [Symbol]) :: Constraint where ...
- 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]
- class ValidConstraint table constr
- getDbFields :: forall table. (MappableList (TableFields table), Table table) => [Text]
- type family IsDbExp a :: Bool where ...
- type family KindOfDbExp a :: ExpressionKind where ...
- type family IsDbStatement (m :: k -> *) :: Bool where ...
- class ValueAsDbExp' (IsDbExp a) a b => ValueAsDbExp a b where
- class ValueAsDbExp' isDbExp a b where
- class (KnownSymbol name, IsDbExp (TableFieldType table name) ~ False) => TableField table name where
- type TableFieldType table name :: *
- class (UniqueConstraint name, AllTypesSatisfy NotNull (UniqueTable name) (UniqueFields name)) => PrimaryKeyConstraint name
- class (AllSatisfy (TableField (UniqueTable name)) (UniqueFields name), KnownSymbol name) => UniqueConstraint name where
- type UniqueTable name :: *
- type 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 where
- type ForeignKeyFrom name :: *
- type ForeignKeyTo name :: *
- type ForeignKeyFromFields name :: [Symbol]
- type ForeignKeyToFields name :: [Symbol]
- type family MissingFieldName (f :: MissingField) :: Symbol where ...
- type family MissingFieldsNames (fs :: [MissingField]) :: [Symbol] where ...
- type family WithFieldSet (field :: Symbol) (entKind :: EntityKind) :: EntityKind where ...
- type family WithFieldsSet (fields :: [Symbol]) (entKind :: EntityKind) :: EntityKind where ...
- type family WithoutMissingField (name :: Symbol) (fs :: [MissingField]) :: [MissingField] where ...
- type family WithoutMissingFields (fields :: [Symbol]) (fs :: [MissingField]) :: [MissingField] where ...
- type CanInsert entKind table = (Table table, CanInsertFresh (MissingFields entKind) table)
- type family CanInsert' (entKind :: EntityKind) (table :: *) :: Constraint where ...
- type CanInsertFresh missing 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 family CanInsertMissing (fs :: [MissingField]) :: Constraint where ...
- 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 where
- data BoolOp
- data ResultType
- type family Selection (t :: ResultType) :: Constraint where ...
- type family SelectionOrSortedSelection (t :: ResultType) :: Constraint where ...
- type family CanAggregate (t :: ResultType) :: Constraint where ...
- type family CanMap (f :: ResultType) :: Constraint where ...
- 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 family ListToSimpleTuple (l :: [*]) :: * where ...
- type family TupleToList (map :: *) :: [*] where ...
- type FlattenTuple t = ListToSimpleTuple (TupleToList t)
- data DbStatement resultType ts where
- 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 where
- GroupOn :: (Selection f, TableSetVars Grouping tables, Groupable group) => (Variables Grouping tables -> group) -> DbStatement f tables -> GroupStatement group tables
- data AM = AM
- data AggregateStatement aggr marker where
- Aggregate :: (Aggregatable aggr, CanAggregate f, TableSetVars Folding tables) => (Variables Folding tables -> aggr) -> DbStatement f tables -> AggregateStatement aggr AM
- data UpdateExp fields table where
- 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 where
- 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
- data DbExp kind a where
- 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)
- class Sortable ord where
- class LiteralCollection collection a | collection -> a where
- class Groupable group where
- type AsAggregate group :: *
- data GroupMappableThing res am where
- GroupMappableDbExp :: DbExp k a -> GroupMappableThing a AM
- GroupMappableAggr :: Aggregatable aggr => AggregateStatement aggr AM -> GroupMappableThing (AggregationResult aggr) AM
- type family GroupMapResultBase a where ...
- class GroupMappableBase map where
- type family GroupMapResult (map :: *) :: * where ...
- class GroupMappable map where
- type family InterpretAsGroupMap (a :: *) :: Bool where ...
- class MappableBase map where
- type MapResultBase map :: *
- type family MapResult (map :: *) :: * where ...
- class Mappable map where
- getAggr :: AggregateStatement aggr AM -> aggr
- newtype Avg a = Avg a
- newtype Count a = Count a
- newtype Only a = Only a
- class AggregatableBase aggr where
- type AggregationBaseResult aggr :: *
- type family BadAggregateBaseError where ...
- type family AggregationResult (aggr :: *) where ...
- class Aggregatable aggr where
- nameText :: forall name. KnownSymbol name => Text
- module Internal.Data.Basic.TypeLevel
- newtype Max a :: * -> * = Max {
- getMax :: a
- newtype Min a :: * -> * = Min {
- getMin :: a
- newtype Sum a :: * -> * = Sum {
- getSum :: a
Documentation
(ValueAsDbExp val0 (TableFieldType t0 name0), TableField t0 name0, (~) * t7 (Identity (UpdateExp ((:) Symbol name0 ([] Symbol)) t0)), (~) * t6 t0, (~) VarContext t5 Updating, (~) (* -> * -> *) t4 (->), (~) * t3 val0, (~) (* -> *) t2 ((->) (DbExp FieldExp (TableFieldType t0 name0))), (~) (* -> * -> *) t1 (->), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (Identity t3)) (t4 (Var t5 t6) t7))) Source # | |
(ValueAsDbExp val0 (TableFieldType t0 name0), TableField t0 name0, (~) * t5 (UpdateExp ((:) Symbol name0 ([] Symbol)) t0), (~) * t4 t0, (~) VarContext t3 Updating, (~) (* -> * -> *) t2 (->), (~) (* -> *) t1 ((->) (DbExp FieldExp (TableFieldType t0 name0) -> Identity val0)), (~) (* -> *) t7 ((->) (proxy0 name0))) => FieldOpticProxy (t7 (t1 (t2 (Var t3 t4) (Identity t5)))) Source # | |
(ValueAsDbExp val0 (TableFieldType t0 name0), TableField t0 name0, (~) * t7 t0, (~) [Symbol] t6 ((:) Symbol name0 ([] Symbol)), (~) (* -> *) t5 Identity, (~) * t4 t0, (~) VarContext t3 Updating, (~) (* -> * -> *) t2 (->), (~) (* -> *) t1 ((->) (DbExp FieldExp (TableFieldType t0 name0) -> Identity val0)), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (Var t3 t4) (t5 (UpdateExp t6 t7))))) Source # | |
(TableField t0 name0, (~) * t9 (Const * (DbExp FieldExp (TableFieldType t0 name0)) (Var anyCtx0 t0)), (~) * t8 t0, (~) VarContext t7 anyCtx0, (~) (* -> * -> *) t6 (->), (~) * t5 (DbExp FieldExp (TableFieldType t0 name0)), (~) * t4 (DbExp FieldExp (TableFieldType t0 name0)), (~) (* -> * -> *) t3 (Const *), (~) (* -> *) t2 ((->) (DbExp FieldExp (TableFieldType t0 name0))), (~) (* -> * -> *) t1 (->), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (t3 t4 t5)) (t6 (Var t7 t8) t9))) Source # | |
(TableField t0 name0, (~) * t7 (Var anyCtx0 t0), (~) * t6 (DbExp FieldExp (TableFieldType t0 name0)), (~) (* -> * -> *) t5 (Const *), (~) * t4 t0, (~) VarContext t3 anyCtx0, (~) (* -> * -> *) t2 (->), (~) (* -> *) t1 ((->) (DbExp FieldExp (TableFieldType t0 name0) -> Const * (DbExp FieldExp (TableFieldType t0 name0)) (DbExp FieldExp (TableFieldType t0 name0)))), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (Var t3 t4) (t5 t6 t7)))) Source # | |
(TableField t0 name0, (~) * t5 t0, (~) VarContext t4 anyCtx0, (~) (* -> *) t3 (Const * (DbExp FieldExp (TableFieldType t0 name0))), (~) (* -> *) t2 ((->) (Var anyCtx0 t0)), (~) (* -> *) t1 ((->) (DbExp FieldExp (TableFieldType t0 name0) -> Const * (DbExp FieldExp (TableFieldType t0 name0)) (DbExp FieldExp (TableFieldType t0 name0)))), (~) (* -> *) t7 ((->) (proxy0 name0))) => FieldOpticProxy (t7 (t1 (t2 (t3 (Var t4 t5))))) Source # | |
Eq (Var ctx a) Source # | |
Ord (Var ctx a) Source # | |
Read (Var ctx a) Source # | |
Show (Var ctx a) Source # | |
data EntityKind Source #
newtype Entity entKind a Source #
Entity | |
|
(TableField t0 name0, SupportedModifyAccess Bool (Not (Elem Symbol name0 (MissingFieldsNames (MissingFields entKind0)))) existingValue0 (TableFieldType t0 name0), (~) * t7 (Identity (Entity (WithFieldSet name0 entKind0) t0)), (~) * t6 t0, (~) EntityKind t5 entKind0, (~) (* -> * -> *) t4 (->), (~) * t3 (TableFieldType t0 name0), (~) (* -> *) t2 ((->) existingValue0), (~) (* -> * -> *) t1 (->), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (Identity t3)) (t4 (Entity t5 t6) t7))) Source # | |
(TableField t0 name0, SupportedModifyAccess Bool (Not (Elem Symbol name0 (MissingFieldsNames (MissingFields entKind0)))) existingValue0 (TableFieldType t0 name0), (~) * t7 t0, (~) EntityKind t6 (WithFieldSet name0 entKind0), (~) (* -> *) t5 Identity, (~) (* -> *) t4 ((->) (Entity entKind0 t0)), (~) * t3 (TableFieldType t0 name0), (~) (* -> *) t2 ((->) existingValue0), (~) (* -> * -> *) t1 (->), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (Identity t3)) (t4 (t5 (Entity t6 t7))))) Source # | |
(TableField t0 name0, SupportedModifyAccess Bool (Not (Elem Symbol name0 (MissingFieldsNames (MissingFields entKind0)))) existingValue0 (TableFieldType t0 name0), (~) * t5 (Entity (WithFieldSet name0 entKind0) t0), (~) * t4 t0, (~) EntityKind t3 entKind0, (~) (* -> * -> *) t2 (->), (~) (* -> *) t1 ((->) (existingValue0 -> Identity (TableFieldType t0 name0))), (~) (* -> *) t7 ((->) (proxy0 name0))) => FieldOpticProxy (t7 (t1 (t2 (Entity t3 t4) (Identity t5)))) Source # | |
(TableField t0 name0, SupportedModifyAccess Bool (Not (Elem Symbol name0 (MissingFieldsNames (MissingFields entKind0)))) existingValue0 (TableFieldType t0 name0), (~) * t4 t0, (~) EntityKind t3 (WithFieldSet name0 entKind0), (~) (* -> *) t2 ((->) (Entity entKind0 t0)), (~) (* -> *) t1 ((->) (existingValue0 -> Identity (TableFieldType t0 name0))), (~) (* -> *) t7 ((->) (proxy0 name0))) => FieldOpticProxy (t7 (t1 (t2 (Identity (Entity t3 t4))))) Source # | |
(TableField t0 name0, EqualOrError Bool (Not (Elem Symbol name0 (MissingFieldsNames (MissingFields entKind0)))) True ((:<>:) ((:<>:) (Text "Field ") (ShowType Symbol name0)) (Text " is not set")), (~) * t9 (Const * (TableFieldType t0 name0) (Entity entKind0 t0)), (~) * t8 t0, (~) EntityKind t7 entKind0, (~) (* -> * -> *) t6 (->), (~) * t5 (TableFieldType t0 name0), (~) * t4 (TableFieldType t0 name0), (~) (* -> * -> *) t3 (Const *), (~) (* -> *) t2 ((->) (TableFieldType t0 name0)), (~) (* -> * -> *) t1 (->), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (t3 t4 t5)) (t6 (Entity t7 t8) t9))) Source # | |
(TableField t0 name0, EqualOrError Bool (Not (Elem Symbol name0 (MissingFieldsNames (MissingFields entKind0)))) True ((:<>:) ((:<>:) (Text "Field ") (ShowType Symbol name0)) (Text " is not set")), (~) * t7 (Entity entKind0 t0), (~) * t6 (TableFieldType t0 name0), (~) (* -> * -> *) t5 (Const *), (~) * t4 t0, (~) EntityKind t3 entKind0, (~) (* -> * -> *) t2 (->), (~) (* -> *) t1 ((->) (TableFieldType t0 name0 -> Const * (TableFieldType t0 name0) (TableFieldType t0 name0))), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (Entity t3 t4) (t5 t6 t7)))) Source # | |
(TableField t0 name0, EqualOrError Bool (Not (Elem Symbol name0 (MissingFieldsNames (MissingFields entKind0)))) True ((:<>:) ((:<>:) (Text "Field ") (ShowType Symbol name0)) (Text " is not set")), (~) * t9 t0, (~) EntityKind t8 entKind0, (~) (* -> *) t7 (Const * (TableFieldType t0 name0)), (~) (* -> *) t6 ((->) (Entity entKind0 t0)), (~) * t5 (TableFieldType t0 name0), (~) * t4 (TableFieldType t0 name0), (~) (* -> * -> *) t3 (Const *), (~) (* -> *) t2 ((->) (TableFieldType t0 name0)), (~) (* -> * -> *) t1 (->), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (t3 t4 t5)) (t6 (t7 (Entity t8 t9))))) Source # | |
(TableField t0 name0, EqualOrError Bool (Not (Elem Symbol name0 (MissingFieldsNames (MissingFields entKind0)))) True ((:<>:) ((:<>:) (Text "Field ") (ShowType Symbol name0)) (Text " is not set")), (~) * t6 t0, (~) EntityKind t5 entKind0, (~) * t4 (TableFieldType t0 name0), (~) (* -> * -> *) t3 (Const *), (~) (* -> *) t2 ((->) (Entity entKind0 t0)), (~) (* -> *) t1 ((->) (TableFieldType t0 name0 -> Const * (TableFieldType t0 name0) (TableFieldType t0 name0))), (~) (* -> *) t7 ((->) (proxy0 name0))) => FieldOpticProxy (t7 (t1 (t2 (t3 t4 (Entity t5 t6))))) Source # | |
Eq a => Eq (Entity entKind a) Source # | |
Ord a => Ord (Entity entKind a) Source # | |
Read a => Read (Entity entKind a) Source # | |
Show a => Show (Entity entKind a) Source # | |
(IsSubset Symbol (SetFields fs a) (SetFields fs a), AllTypesSatisfy JSONableField a (SetFields fs a)) => ToJSON (Entity (Fresh fs) a) Source # | |
(IsSubset Symbol (TableFields a) (TableFields a), AllTypesSatisfy JSONableField a (TableFields a)) => ToJSON (Entity (FromDb Live) a) Source # | |
GetEntityFromValue (SetFields miss a) a miss => FromJSON (Entity (Fresh miss) a) Source # | |
FromRow a => FromRow (Entity l a) Source # | |
type family MissingFields (entKind :: EntityKind) :: [MissingField] where ... Source #
MissingFields (Fresh missing) = missing | |
MissingFields (FromDb c) = '[] |
type SetFields missing table = TableFields table `Without` MissingFieldsNames missing Source #
class AllSatisfy (TableField table) fields => AllTypesSatisfy c table fields where Source #
mapFields :: fields `IsSubset` SetFields (MissingFields entKind) table => (forall proxy n x. c x n => proxy n -> x -> a) -> Entity entKind table -> [a] Source #
AllTypesSatisfy c table ([] Symbol) Source # | |
(TableField table x, c (TableFieldType table x) x, AllTypesSatisfy c table xs) => AllTypesSatisfy c table ((:) Symbol x xs) Source # | |
class (KnownSymbol n, ToJSON a) => JSONableField a n Source #
(KnownSymbol n, ToJSON a) => JSONableField a n Source # | |
class GetEntityFromValue fs a miss where Source #
(Table a, (~) [MissingField] miss (TableRequiredFields a)) => GetEntityFromValue ([] Symbol) a miss Source # | |
(GetEntityFromValue fs a miss, (~) [MissingField] miss' (WithoutMissingField f miss), FromJSON (TableFieldType a f), TableField a f) => GetEntityFromValue ((:) Symbol f fs) a miss' Source # | |
type family SameTypes toTable (toFields :: [Symbol]) fromTable (fromFields :: [Symbol]) :: Constraint where ... Source #
SameTypes toTable '[] fromTable '[] = () | |
SameTypes toTable (x ': xs) fromTable (y ': ys) = (TableFieldType toTable x ~ TableFieldType fromTable y, SameTypes toTable xs fromTable ys) |
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 Source #
type TableName table = (name :: Symbol) | name -> table Source #
type TableFields table :: [Symbol] Source #
type TableConstraints table :: [FieldConstraint] Source #
type TablePrimaryKey table :: Maybe Symbol Source #
type TableRequiredFields table :: [MissingField] Source #
class ValidConstraint table constr Source #
(ForeignKeyConstraint name, (~) * table (ForeignKeyFrom name)) => ValidConstraint table (ForeignKey name) Source # | |
(UniqueConstraint name, (~) * table (UniqueTable name)) => ValidConstraint table (Unique name) Source # | |
getDbFields :: forall table. (MappableList (TableFields table), Table table) => [Text] Source #
type family KindOfDbExp a :: ExpressionKind where ... Source #
KindOfDbExp (DbExp k a) = k | |
KindOfDbExp a = LiteralExp |
type family IsDbStatement (m :: k -> *) :: Bool where ... Source #
IsDbStatement (DbStatement r) = True | |
IsDbStatement a = False |
class ValueAsDbExp' (IsDbExp a) a b => ValueAsDbExp a b where Source #
valueAsDbExp :: a -> DbExp (KindOfDbExp a) b Source #
ValueAsDbExp' (IsDbExp a) a b => ValueAsDbExp a b Source # | |
class ValueAsDbExp' isDbExp a b where Source #
valueAsDbExp' :: a -> DbExp (KindOfDbExp a) b Source #
((~) * a b, ToField a, (~) ExpressionKind (KindOfDbExp a) LiteralExp) => ValueAsDbExp' False a b Source # | |
(~) * (DbExp k b) a => ValueAsDbExp' True a b Source # | |
class (KnownSymbol name, IsDbExp (TableFieldType table name) ~ False) => TableField table name where Source #
type TableFieldType table name :: * Source #
tableFieldLens :: Lens' table (TableFieldType table name) Source #
TableField User "id" Source # | |
TableField User "location" Source # | |
TableField User "name" Source # | |
TableField Post "author" Source # | |
TableField Post "id" Source # | |
TableField Post "name" Source # | |
class (UniqueConstraint name, AllTypesSatisfy NotNull (UniqueTable name) (UniqueFields name)) => PrimaryKeyConstraint name Source #
class (AllSatisfy (TableField (UniqueTable name)) (UniqueFields name), KnownSymbol name) => UniqueConstraint name Source #
type UniqueTable name :: * Source #
type UniqueFields name :: [Symbol] Source #
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 Source #
type ForeignKeyFrom name :: * Source #
type ForeignKeyTo name :: * Source #
type ForeignKeyFromFields name :: [Symbol] Source #
type ForeignKeyToFields name :: [Symbol] Source #
type family MissingFieldName (f :: MissingField) :: Symbol where ... Source #
MissingFieldName (Required s) = s | |
MissingFieldName (DynamicDefault s) = s |
type family MissingFieldsNames (fs :: [MissingField]) :: [Symbol] where ... Source #
MissingFieldsNames '[] = '[] | |
MissingFieldsNames (f ': fs) = MissingFieldName f ': MissingFieldsNames fs |
type family WithFieldSet (field :: Symbol) (entKind :: EntityKind) :: EntityKind where ... Source #
WithFieldSet field (FromDb c) = FromDb c | |
WithFieldSet field (Fresh missing) = Fresh (WithoutMissingField field missing) |
type family WithFieldsSet (fields :: [Symbol]) (entKind :: EntityKind) :: EntityKind where ... Source #
WithFieldsSet '[] entKind = entKind | |
WithFieldsSet (f ': fs) entKind = WithFieldSet f (WithFieldsSet fs entKind) | |
WithFieldsSet field (FromDb c) = FromDb c |
type family WithoutMissingField (name :: Symbol) (fs :: [MissingField]) :: [MissingField] where ... Source #
WithoutMissingField name '[] = '[] | |
WithoutMissingField name (Required name ': fs) = fs | |
WithoutMissingField name (DynamicDefault name ': fs) = fs | |
WithoutMissingField name (f ': fs) = f ': WithoutMissingField name fs |
type family WithoutMissingFields (fields :: [Symbol]) (fs :: [MissingField]) :: [MissingField] where ... Source #
WithoutMissingFields '[] ms = ms | |
WithoutMissingFields (f ': fs) ms = WithoutMissingField f (WithoutMissingFields fs ms) |
type CanInsert entKind table = (Table table, CanInsertFresh (MissingFields entKind) table) Source #
type family CanInsert' (entKind :: EntityKind) (table :: *) :: Constraint where ... Source #
CanInsert' (Fresh missing) table = CanInsertFresh missing table | |
CanInsert' (FromDb c) table = () |
type CanInsertFresh missing 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)) Source #
type family CanInsertMissing (fs :: [MissingField]) :: Constraint where ... Source #
CanInsertMissing '[] = () | |
CanInsertMissing (DynamicDefault name ': fs) = CanInsertMissing fs | |
CanInsertMissing (f ': fs) = TypeError ((ErrorText "Can't insert entity because the required field " :<>: ShowType (MissingFieldName f)) :<>: ErrorText " is not set") |
type CanUpdate table pk = (KnownSymbol pk, Table table, SetFields '[] table `IsSubset` SetFields '[] table, MappableList (TableFields table)) Source #
type Variables ctx list = ListToTuple (Var ctx) list Source #
class TableSetVars ctx tables where Source #
data ResultType Source #
type family Selection (t :: ResultType) :: Constraint where ... Source #
Selection Filtered = () | |
Selection Unfiltered = () |
type family SelectionOrSortedSelection (t :: ResultType) :: Constraint where ... Source #
type family CanAggregate (t :: ResultType) :: Constraint where ... Source #
CanAggregate Filtered = () | |
CanAggregate Unfiltered = () | |
CanAggregate Grouped = () |
type family CanMap (f :: ResultType) :: Constraint where ... Source #
type FieldIsGettableBool field missing = Not (field `Elem` MissingFieldsNames missing) Source #
type FieldIsGettable field missing = CheckWithError (FieldIsGettableBool field missing) ((ErrorText "Field " :<>: ShowType field) :<>: ErrorText " is not set") Source #
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") Source #
type family ListToSimpleTuple (l :: [*]) :: * where ... Source #
ListToSimpleTuple '[] = () | |
ListToSimpleTuple '[a] = Only a | |
ListToSimpleTuple '[a, b] = (a, b) | |
ListToSimpleTuple '[a, b, c] = (a, b, c) | |
ListToSimpleTuple '[a, b, c, d] = (a, b, c, d) | |
ListToSimpleTuple '[a, b, c, d, e] = (a, b, c, d, e) |
type family TupleToList (map :: *) :: [*] where ... Source #
TupleToList () = '[] | |
TupleToList (Only a) = TupleToList a | |
TupleToList (a, b) = TupleToList a ++ TupleToList b | |
TupleToList (a, b, c) = (TupleToList a ++ TupleToList b) ++ TupleToList c | |
TupleToList (a, b, c, d) = ((TupleToList a ++ TupleToList b) ++ TupleToList c) ++ TupleToList d | |
TupleToList (a, b, c, d, e) = (((TupleToList a ++ TupleToList b) ++ TupleToList c) ++ TupleToList d) ++ TupleToList e | |
TupleToList a = '[a] |
type FlattenTuple t = ListToSimpleTuple (TupleToList t) Source #
data DbStatement resultType ts where Source #
(Mappable map0, CanMap f0, TableSetVars Mapping tables0, (~) * t4 (DbStatement Mapped ((:) * (MapResult map0) ([] *))), (~) [*] t3 tables0, (~) ResultType t2 f0, (~) (* -> * -> *) t1 (->), (~) (* -> *) t0 ((->) (ListToTuple * (Var Mapping) tables0 -> map0))) => Dmap' (t0 (t1 (DbStatement t2 t3) t4)) Source # | |
data GroupStatement group tables where Source #
GroupOn :: (Selection f, TableSetVars Grouping tables, Groupable group) => (Variables Grouping tables -> group) -> DbStatement f tables -> GroupStatement group tables |
(GroupMappable map0, (~) Bool (InterpretAsGroupMap map0) True, (~) * t4 (DbStatement Folded ((:) * (GroupMapResult map0) ([] *))), (~) [*] t3 tables0, (~) * t2 group0, (~) (* -> * -> *) t1 (->), (~) (* -> *) t0 ((->) ((AsAggregate group0, DbStatement Grouped tables0) -> map0))) => Dmap' (t0 (t1 (GroupStatement t2 t3) t4)) Source # | |
A kind and type used so LiftAggregation can differentiate types like `m a` from
AggregateStatement
by their kind.
data AggregateStatement aggr marker where Source #
Aggregate :: (Aggregatable aggr, CanAggregate f, TableSetVars Folding tables) => (Variables Folding tables -> aggr) -> DbStatement f tables -> AggregateStatement aggr AM |
data UpdateExp fields table where Source #
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 |
(TableField t0 name0, EqualOrError Bool (Not (Elem Symbol name0 fields0)) True ((:<>:) ((:<>:) (Text "Cannot update the field ") (ShowType Symbol name0)) (Text " because it's already updated in this expression")), ValueAsDbExp val0 (TableFieldType t0 name0), (~) * t5 (Identity (UpdateExp ((:) Symbol name0 fields0) t0)), (~) * t4 t0, (~) [Symbol] t3 fields0, (~) (* -> * -> *) t2 (->), (~) (* -> *) t1 ((->) (DbExp FieldExp (TableFieldType t0 name0) -> Identity val0)), (~) (* -> *) t7 ((->) (proxy0 name0))) => FieldOpticProxy (t7 (t1 (t2 (UpdateExp t3 t4) t5))) Source # | |
(ValueAsDbExp val0 (TableFieldType t0 name0), TableField t0 name0, (~) * t7 t0, (~) [Symbol] t6 ((:) Symbol name0 ([] Symbol)), (~) (* -> *) t5 Identity, (~) * t4 t0, (~) VarContext t3 Updating, (~) (* -> * -> *) t2 (->), (~) (* -> *) t1 ((->) (DbExp FieldExp (TableFieldType t0 name0) -> Identity val0)), (~) (* -> *) t11 ((->) (proxy0 name0))) => FieldOpticProxy (t11 (t1 (t2 (Var t3 t4) (t5 (UpdateExp t6 t7))))) Source # | |
data ConditionExp where Source #
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 DbExp kind a where Source #
Field :: TableField table fieldName => proxy fieldName -> Var anyCtx table -> DbExp FieldExp (TableFieldType table fieldName) | |
Literal :: ToField a => a -> DbExp LiteralExp a |
class Sortable ord where Source #
getOrdering :: ord -> [(SomeDbExp, SortDirection)] Source #
class LiteralCollection collection a | collection -> a where Source #
getLiteralCollection :: collection -> [SomeDbExp] Source #
(~) * (DbExp b x) a => LiteralCollection * [a] x Source # | |
(~) * a b => LiteralCollection * (DbExp k a) a Source # | |
(LiteralCollection k a x, LiteralCollection k b x) => LiteralCollection k (a, b) x Source # | |
(LiteralCollection k a x, LiteralCollection k b x, LiteralCollection k c x) => LiteralCollection k (a, b, c) x Source # | |
class Groupable group where Source #
type AsAggregate group :: * Source #
Wrapps every DbExp in the tuple with the GroupMappableDbExp
getGrouping :: group -> [SomeDbExp] Source #
asAggregate :: group -> AsAggregate group Source #
data GroupMappableThing res am where Source #
GroupMappableDbExp :: DbExp k a -> GroupMappableThing a AM | |
GroupMappableAggr :: Aggregatable aggr => AggregateStatement aggr AM -> GroupMappableThing (AggregationResult aggr) AM |
type family GroupMapResultBase a where ... Source #
GroupMapResultBase (GroupMappableThing res AM) = res |
class GroupMappableBase map where Source #
getGroupMappingBase :: map -> [(AggregateFunction, SomeDbExp)] Source #
(~) * (GroupMappableThing res AM) a => GroupMappableBase a Source # | |
type family GroupMapResult (map :: *) :: * where ... Source #
GroupMapResult (a, b) = FlattenTuple (GroupMapResultBase a, GroupMapResultBase b) | |
GroupMapResult (a, b, c) = FlattenTuple (GroupMapResultBase a, GroupMapResultBase b, GroupMapResultBase c) | |
GroupMapResult (a, b, c, d) = FlattenTuple (GroupMapResultBase a, GroupMapResultBase b, GroupMapResultBase c, GroupMapResultBase d) | |
GroupMapResult (a, b, c, d, e) = FlattenTuple (GroupMapResultBase a, GroupMapResultBase b, GroupMapResultBase c, GroupMapResultBase d, GroupMapResultBase e) | |
GroupMapResult a = FlattenTuple (Only (GroupMapResultBase a)) |
class GroupMappable map where Source #
getGroupMapping :: map -> [(AggregateFunction, SomeDbExp)] Source #
GroupMappableBase (m a) => GroupMappable (m a) Source # | |
(GroupMappableBase a, GroupMappableBase b) => GroupMappable (a, b) Source # | |
(GroupMappableBase a, GroupMappableBase b, GroupMappableBase c) => GroupMappable (a, b, c) Source # | |
(GroupMappableBase a, GroupMappableBase b, GroupMappableBase c, GroupMappableBase d) => GroupMappable (a, b, c, d) Source # | |
(GroupMappableBase a, GroupMappableBase b, GroupMappableBase c, GroupMappableBase d, GroupMappableBase e) => GroupMappable (a, b, c, d, e) Source # | |
type family InterpretAsGroupMap (a :: *) :: Bool where ... Source #
So dfoldMap knows to behave like an expression when used inside of a dmap
InterpretAsGroupMap (a, b) = True | |
InterpretAsGroupMap (a, b, c) = True | |
InterpretAsGroupMap (a, b, c, d) = True | |
InterpretAsGroupMap (a, b, c, d, e) = True | |
InterpretAsGroupMap (a, b, c, d, e, f) = True | |
InterpretAsGroupMap (m (a :: *)) = False | |
InterpretAsGroupMap a = True |
class MappableBase map where Source #
type MapResultBase map :: * Source #
getMappingBase :: map -> [SomeDbExp] Source #
MappableBase (DbExp k a) Source # | |
type family MapResult (map :: *) :: * where ... Source #
MapResult (a, b) = FlattenTuple (MapResultBase a, MapResultBase b) | |
MapResult (a, b, c) = FlattenTuple (MapResultBase a, MapResultBase b, MapResultBase c) | |
MapResult (a, b, c, d) = FlattenTuple (MapResultBase a, MapResultBase b, MapResultBase c, MapResultBase d) | |
MapResult (a, b, c, d, e) = FlattenTuple (MapResultBase a, MapResultBase b, MapResultBase c, MapResultBase d, MapResultBase e) | |
MapResult a = FlattenTuple (Only (MapResultBase a)) |
class Mappable map where Source #
getMapping :: map -> [SomeDbExp] Source #
MappableBase a => Mappable a Source # | |
(MappableBase a, MappableBase b) => Mappable (a, b) Source # | |
(MappableBase a, MappableBase b, MappableBase c) => Mappable (a, b, c) Source # | |
(MappableBase a, MappableBase b, MappableBase c, MappableBase d) => Mappable (a, b, c, d) Source # | |
(MappableBase a, MappableBase b, MappableBase c, MappableBase d, MappableBase e) => Mappable (a, b, c, d, e) Source # | |
getAggr :: AggregateStatement aggr AM -> aggr Source #
Avg a |
Count a |
AggregatableBase (Count (DbExp f a)) Source # | |
type AggregationBaseResult (Count (DbExp f a)) Source # | |
Only a |
AggregatableBase (Only (DbExp f a)) Source # | |
type AggregationBaseResult (Only (DbExp f a)) Source # | |
class AggregatableBase aggr where Source #
type AggregationBaseResult aggr :: * Source #
getAggregatingBase :: aggr -> (AggregateFunction, SomeDbExp) Source #
BadAggregateBaseError Constraint => AggregatableBase a Source # | |
Ord a => AggregatableBase (Min (DbExp f a)) Source # | |
Ord a => AggregatableBase (Max (DbExp f a)) Source # | |
Num a => AggregatableBase (Sum (DbExp f a)) Source # | |
AggregatableBase (Only (DbExp f a)) Source # | |
AggregatableBase (Count (DbExp f a)) Source # | |
Num a => AggregatableBase (Avg (DbExp f a)) Source # | |
type family BadAggregateBaseError where ... Source #
BadAggregateBaseError = TypeError ((ErrorText "The only types that can exist in a fold expression are expressions involving entity fields wrapped in one of the Monoid newtypes." :$$: ErrorText "Along with the newtypes from Data.Monoid (Max, Min, Sum), there are Avg and Count.") :$$: ErrorText "Example: dfoldMap (\\e -> (Max (e ^. height), Avg (e ^. weigth))) t") |
type family AggregationResult (aggr :: *) where ... Source #
AggregationResult (a, b) = (AggregationBaseResult a, AggregationBaseResult b) | |
AggregationResult (a, b, c) = (AggregationBaseResult a, AggregationBaseResult b, AggregationBaseResult c) | |
AggregationResult a = Only (AggregationBaseResult a) |
class Aggregatable aggr where Source #
getAggregating :: aggr -> [(AggregateFunction, SomeDbExp)] Source #
AggregatableBase a => Aggregatable a Source # | |
(AggregatableBase a, AggregatableBase b) => Aggregatable (a, b) Source # | |
(AggregatableBase a, AggregatableBase b, AggregatableBase c) => Aggregatable (a, b, c) Source # | |
nameText :: forall name. KnownSymbol name => Text Source #
Monad Max | |
Functor Max | |
MonadFix Max | |
Applicative Max | |
Foldable Max | |
Traversable Max | |
Generic1 Max | |
ToJSON1 Max | |
FromJSON1 Max | |
Bounded a => Bounded (Max a) | |
Enum a => Enum (Max a) | |
Eq a => Eq (Max a) | |
Data a => Data (Max a) | |
Num a => Num (Max a) | |
Ord a => Ord (Max a) | |
Read a => Read (Max a) | |
Show a => Show (Max a) | |
Generic (Max a) | |
Ord a => Semigroup (Max a) | |
(Ord a, Bounded a) => Monoid (Max a) | |
Hashable a => Hashable (Max a) | |
ToJSON a => ToJSON (Max a) | |
FromJSON a => FromJSON (Max a) | |
Wrapped (Max a) | |
Ord a => AggregatableBase (Max (DbExp f a)) Source # | |
(~) * t (Max b) => Rewrapped (Max a) t | |
type Rep1 Max | |
type Rep (Max a) | |
type Unwrapped (Max a) | |
type AggregationBaseResult (Max (DbExp f a)) Source # | |
Monad Min | |
Functor Min | |
MonadFix Min | |
Applicative Min | |
Foldable Min | |
Traversable Min | |
Generic1 Min | |
ToJSON1 Min | |
FromJSON1 Min | |
Bounded a => Bounded (Min a) | |
Enum a => Enum (Min a) | |
Eq a => Eq (Min a) | |
Data a => Data (Min a) | |
Num a => Num (Min a) | |
Ord a => Ord (Min a) | |
Read a => Read (Min a) | |
Show a => Show (Min a) | |
Generic (Min a) | |
Ord a => Semigroup (Min a) | |
(Ord a, Bounded a) => Monoid (Min a) | |
Hashable a => Hashable (Min a) | |
ToJSON a => ToJSON (Min a) | |
FromJSON a => FromJSON (Min a) | |
Wrapped (Min a) | |
Ord a => AggregatableBase (Min (DbExp f a)) Source # | |
(~) * t (Min b) => Rewrapped (Min a) t | |
type Rep1 Min | |
type Rep (Min a) | |
type Unwrapped (Min a) | |
type AggregationBaseResult (Min (DbExp f a)) Source # | |
Monoid under addition.
Monad Sum | |
Functor Sum | |
Applicative Sum | |
Foldable Sum | |
Traversable Sum | |
Generic1 Sum | |
Representable Sum | |
Bounded a => Bounded (Sum a) | |
Eq a => Eq (Sum a) | |
Num a => Num (Sum a) | |
Ord a => Ord (Sum a) | |
Read a => Read (Sum a) | |
Show a => Show (Sum a) | |
Generic (Sum a) | |
Num a => Semigroup (Sum a) | |
Num a => Monoid (Sum a) | |
Wrapped (Sum a) | |
Num a => AggregatableBase (Sum (DbExp f a)) Source # | |
(~) * t (Sum b) => Rewrapped (Sum a) t | |
type Rep1 Sum | |
type Rep Sum | |
type Rep (Sum a) | |
type Unwrapped (Sum a) | |
type AggregationBaseResult (Sum (DbExp f a)) Source # | |