Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Key
- data Point = Point !Double !Double
- 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 (KnownSymbol name, KnownSymbol (CapsName table name), IsDbExp (TableFieldType table name) ~ False) => TableField (table :: *) (name :: Symbol) where
- type TableFieldType table name :: *
- type TableFieldCapsName table name :: Maybe Symbol
- class (AllSatisfy (TableField (UniqueTable name)) (UniqueFields name), KnownSymbol name) => UniqueConstraint (name :: Symbol) where
- type UniqueTable name :: *
- type 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]
- data MissingField
- data FieldConstraint
- type AllRows table res = (Table table, LiftedStatement Unfiltered '[table] res)
- newtype Entity (entKind :: EntityKind) a = Entity {
- _getEntity :: a
- data EntityKind
- = Fresh [MissingField]
- | FromDb Cached
- 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 (Effect e, Monad m) => MonadEffect e (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, CanTake 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
- (>.) :: ComparableInDbExp a b => a -> b -> ConditionExp
- (==.) :: ComparableInDbExp a b => a -> b -> ConditionExp
- (/=.) :: ComparableInDbExp a b => a -> b -> ConditionExp
- (<=.) :: ComparableInDbExp a b => a -> b -> ConditionExp
- (>=.) :: ComparableInDbExp a b => a -> b -> ConditionExp
- (&&.) :: ConditionExp -> ConditionExp -> ConditionExp
- (||.) :: ConditionExp -> ConditionExp -> ConditionExp
- data ConditionExp where
- In :: LiteralCollection collection a => DbExp k a -> collection -> ConditionExp
- newtype Avg a = Avg a
- newtype Count a = Count a
- newtype Min a :: * -> * = Min {
- getMin :: a
- newtype Max a :: * -> * = Max {
- getMax :: a
- newtype Sum a :: * -> * = Sum {
- getSum :: a
- newtype List a = List a
- newtype PGArray a :: * -> * = PGArray {
- fromPGArray :: [a]
- handleBasicPsql :: MonadIO m => Connection -> RuntimeImplemented Basic (RuntimeImplemented Logging (ExceptT BasicException m)) a -> m a
- connectPostgreSQL :: ByteString -> IO Connection
- handleBasicPsqlWithLogging :: forall m a. (MonadEffects '[Logging, Signal BasicException Query] m, MonadIO m) => Connection -> RuntimeImplemented Basic m a -> m a
- data BasicException
- throwBasicToIO :: forall m a. MonadIO m => ExceptT BasicException m a -> m a
- logOnlyErrors :: MonadEffect Logging m => RuntimeImplemented Logging m a -> m a
- prettyPrintSummary :: MonadIO m => Int -> RuntimeImplemented Logging m a -> m a
- mkFromFile :: FilePath -> Q [Dec]
- mkFromFiles :: [FilePath] -> Q [Dec]
- printToFile :: [FilePath] -> FilePath -> Q [Dec]
- class FromRow a where
- field :: FromField a => RowParser a
- data Cached
- delem :: LiteralCollection collection a => DbExp k a -> collection -> ConditionExp
- disNothing :: DbExp FieldExp (Maybe a) -> ConditionExp
- disJust :: DbExp FieldExp (Maybe a) -> ConditionExp
- type GettableField entKind field = FieldIsGettable field (MissingFields entKind)
- type ModifyableField table entKind field = SupportedModifyAccess (FieldIsGettableBool field (MissingFields entKind)) (TableFieldType table field)
- type SettableField table entKind field = ModifyableField table entKind field
- type family WithFieldSet (field :: Symbol) (entKind :: EntityKind) :: EntityKind where ...
- like :: DbExp FieldExp Text -> Text -> ConditionExp
- ilike :: DbExp FieldExp Text -> Text -> ConditionExp
- dtrue :: ConditionExp
- dfalse :: ConditionExp
- executeQuery :: (ToRow r, MonadEffect Basic m) => Text -> r -> m ()
- applySchema :: MonadEffect Basic m => Schema -> m ()
- data Schema
- toFreshEntity :: forall fs c a. Entity (FromDb c) a -> Entity (Fresh fs) a
Documentation
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 (KnownSymbol name, KnownSymbol (CapsName table name), IsDbExp (TableFieldType table name) ~ False) => TableField (table :: *) (name :: Symbol) where Source #
type TableFieldType table name :: * Source #
type TableFieldCapsName table name :: Maybe Symbol 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 (AllSatisfy (TableField (UniqueTable name)) (UniqueFields name), KnownSymbol name) => UniqueConstraint (name :: Symbol) Source #
type UniqueTable name :: * Source #
type UniqueFields name :: [Symbol] Source #
class (UniqueConstraint name, AllTypesSatisfy NotNull (UniqueTable name) (UniqueFields name)) => PrimaryKeyConstraint (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 :: Symbol) Source #
type ForeignKeyFrom name :: * Source #
type ForeignKeyTo name :: * Source #
type ForeignKeyFromFields name :: [Symbol] Source #
type ForeignKeyToFields name :: [Symbol] Source #
type AllRows table res = (Table table, LiftedStatement Unfiltered '[table] res) Source #
newtype Entity (entKind :: EntityKind) a Source #
Entity | |
|
data EntityKind Source #
type VirtualTable foreignKeyName res = (ForeignKeyConstraint foreignKeyName, AllFieldsMatch (ForeignKeyToFields foreignKeyName) (ForeignKeyFromFields foreignKeyName) (ForeignKeyTo foreignKeyName) (ForeignKeyFrom foreignKeyName), LiftedStatement Filtered '[ForeignKeyFrom foreignKeyName] res) Source #
virtualTableLens :: forall foreignKeyName c res. VirtualTable foreignKeyName res => Getter' (Entity (FromDb c) (ForeignKeyTo foreignKeyName)) res Source #
class FieldOpticProxy t Source #
(TableField t name, EqualOrError Bool (Not (Elem Symbol name fields)) True ((:<>:) ((:<>:) (Text "Cannot update the field ") (ShowType Symbol name)) (Text " because it's already updated in this expression")), ValueAsDbExp val (TableFieldType t name), (~) * t5 (Identity (UpdateExp ((:) Symbol name fields) t)), (~) * t4 t, (~) [Symbol] t3 fields, (~) (* -> * -> *) t2 ((->) LiftedRep LiftedRep), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (DbExp FieldExp (TableFieldType t name) -> Identity val)), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (UpdateExp t3 t4) t5))) Source # | |
(ValueAsDbExp val (TableFieldType t name), TableField t name, (~) * t7 (Identity (UpdateExp ((:) Symbol name ([] Symbol)) t)), (~) * t6 t, (~) VarContext t5 Updating, (~) (* -> * -> *) t4 ((->) LiftedRep LiftedRep), (~) * t3 val, (~) (* -> *) t2 ((->) LiftedRep LiftedRep (DbExp FieldExp (TableFieldType t name))), (~) (* -> * -> *) t1 ((->) LiftedRep LiftedRep), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Identity t3)) (t4 (Var t5 t6) t7))) Source # | |
(ValueAsDbExp val (TableFieldType t name), TableField t name, (~) * t5 (UpdateExp ((:) Symbol name ([] Symbol)) t), (~) * t4 t, (~) VarContext t3 Updating, (~) (* -> * -> *) t2 ((->) LiftedRep LiftedRep), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (DbExp FieldExp (TableFieldType t name) -> Identity val)), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Var t3 t4) (Identity t5)))) Source # | |
(ValueAsDbExp val (TableFieldType t name), TableField t name, (~) * t7 t, (~) [Symbol] t6 ((:) Symbol name ([] Symbol)), (~) (* -> *) t5 Identity, (~) * t4 t, (~) VarContext t3 Updating, (~) (* -> * -> *) t2 ((->) LiftedRep LiftedRep), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (DbExp FieldExp (TableFieldType t name) -> Identity val)), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Var t3 t4) (t5 (UpdateExp t6 t7))))) Source # | |
(TableField t name, SupportedModifyAccess Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) (TableFieldType t name), (~) * t7 (Identity (Entity (WithFieldSet name entKind) t)), (~) * t6 t, (~) EntityKind t5 entKind, (~) (* -> * -> *) t4 ((->) LiftedRep LiftedRep), (~) * t3 (TableFieldType t name), (~) (* -> *) t2 ((->) LiftedRep LiftedRep (ExistingValue Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) (TableFieldType t name))), (~) (* -> * -> *) t1 ((->) LiftedRep LiftedRep), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Identity t3)) (t4 (Entity t5 t6) t7))) Source # | |
(TableField t name, SupportedModifyAccess Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) (TableFieldType t name), (~) * t7 t, (~) EntityKind t6 (WithFieldSet name entKind), (~) (* -> *) t5 Identity, (~) (* -> *) t4 ((->) LiftedRep LiftedRep (Entity entKind t)), (~) * t3 (TableFieldType t name), (~) (* -> *) t2 ((->) LiftedRep LiftedRep (ExistingValue Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) (TableFieldType t name))), (~) (* -> * -> *) t1 ((->) LiftedRep LiftedRep), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Identity t3)) (t4 (t5 (Entity t6 t7))))) Source # | |
(TableField t name, SupportedModifyAccess Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) (TableFieldType t name), (~) * t5 (Entity (WithFieldSet name entKind) t), (~) * t4 t, (~) EntityKind t3 entKind, (~) (* -> * -> *) t2 ((->) LiftedRep LiftedRep), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (ExistingValue Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) (TableFieldType t name) -> Identity (TableFieldType t name))), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Entity t3 t4) (Identity t5)))) Source # | |
(TableField t name, SupportedModifyAccess Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) (TableFieldType t name), (~) * t4 t, (~) EntityKind t3 (WithFieldSet name entKind), (~) (* -> *) t2 ((->) LiftedRep LiftedRep (Entity entKind t)), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (ExistingValue Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) (TableFieldType t name) -> Identity (TableFieldType t name))), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Identity (Entity t3 t4))))) Source # | |
(TableField t name, EqualOrError Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) True ((:<>:) ((:<>:) (Text "Field ") (ShowType Symbol name)) (Text " is not set")), (~) * t9 (Const * (TableFieldType t name) (Entity entKind t)), (~) * t8 t, (~) EntityKind t7 entKind, (~) (* -> * -> *) t6 ((->) LiftedRep LiftedRep), (~) * t5 (TableFieldType t name), (~) * t4 (TableFieldType t name), (~) (* -> * -> *) t3 (Const *), (~) (* -> *) t2 ((->) LiftedRep LiftedRep (TableFieldType t name)), (~) (* -> * -> *) t1 ((->) LiftedRep LiftedRep), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (t3 t4 t5)) (t6 (Entity t7 t8) t9))) Source # | |
(TableField t name, EqualOrError Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) True ((:<>:) ((:<>:) (Text "Field ") (ShowType Symbol name)) (Text " is not set")), (~) * t7 (Entity entKind t), (~) * t6 (TableFieldType t name), (~) (* -> * -> *) t5 (Const *), (~) * t4 t, (~) EntityKind t3 entKind, (~) (* -> * -> *) t2 ((->) LiftedRep LiftedRep), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (TableFieldType t name -> Const * (TableFieldType t name) (TableFieldType t name))), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Entity t3 t4) (t5 t6 t7)))) Source # | |
(TableField t name, EqualOrError Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) True ((:<>:) ((:<>:) (Text "Field ") (ShowType Symbol name)) (Text " is not set")), (~) * t9 t, (~) EntityKind t8 entKind, (~) (* -> *) t7 (Const * (TableFieldType t name)), (~) (* -> *) t6 ((->) LiftedRep LiftedRep (Entity entKind t)), (~) * t5 (TableFieldType t name), (~) * t4 (TableFieldType t name), (~) (* -> * -> *) t3 (Const *), (~) (* -> *) t2 ((->) LiftedRep LiftedRep (TableFieldType t name)), (~) (* -> * -> *) t1 ((->) LiftedRep LiftedRep), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (t3 t4 t5)) (t6 (t7 (Entity t8 t9))))) Source # | |
(TableField t name, EqualOrError Bool (Not (Elem Symbol name (MissingFieldsNames (MissingFields entKind)))) True ((:<>:) ((:<>:) (Text "Field ") (ShowType Symbol name)) (Text " is not set")), (~) * t6 t, (~) EntityKind t5 entKind, (~) * t4 (TableFieldType t name), (~) (* -> * -> *) t3 (Const *), (~) (* -> *) t2 ((->) LiftedRep LiftedRep (Entity entKind t)), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (TableFieldType t name -> Const * (TableFieldType t name) (TableFieldType t name))), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (t3 t4 (Entity t5 t6))))) Source # | |
(TableField t name, (~) * t9 (Const * (DbExp FieldExp (TableFieldType t name)) (Var anyCtx t)), (~) * t8 t, (~) VarContext t7 anyCtx, (~) (* -> * -> *) t6 ((->) LiftedRep LiftedRep), (~) * t5 (DbExp FieldExp (TableFieldType t name)), (~) * t4 (DbExp FieldExp (TableFieldType t name)), (~) (* -> * -> *) t3 (Const *), (~) (* -> *) t2 ((->) LiftedRep LiftedRep (DbExp FieldExp (TableFieldType t name))), (~) (* -> * -> *) t1 ((->) LiftedRep LiftedRep), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (t3 t4 t5)) (t6 (Var t7 t8) t9))) Source # | |
(TableField t name, (~) * t7 (Var anyCtx t), (~) * t6 (DbExp FieldExp (TableFieldType t name)), (~) (* -> * -> *) t5 (Const *), (~) * t4 t, (~) VarContext t3 anyCtx, (~) (* -> * -> *) t2 ((->) LiftedRep LiftedRep), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (DbExp FieldExp (TableFieldType t name) -> Const * (DbExp FieldExp (TableFieldType t name)) (DbExp FieldExp (TableFieldType t name)))), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (Var t3 t4) (t5 t6 t7)))) Source # | |
(TableField t name, (~) * t5 t, (~) VarContext t4 anyCtx, (~) (* -> *) t3 (Const * (DbExp FieldExp (TableFieldType t name))), (~) (* -> *) t2 ((->) LiftedRep LiftedRep (Var anyCtx t)), (~) (* -> *) t1 ((->) LiftedRep LiftedRep (DbExp FieldExp (TableFieldType t name) -> Const * (DbExp FieldExp (TableFieldType t name)) (DbExp FieldExp (TableFieldType t name)))), (~) (* -> *) t0 ((->) LiftedRep LiftedRep (proxy name))) => FieldOpticProxy (t0 (t1 (t2 (t3 (Var t4 t5))))) Source # | |
fieldOptic :: forall name o. FieldOpticProxy (Proxy name -> o) => o Source #
class ForeignKeyLensProxy t Source #
foreignKeyLens :: forall name o. ForeignKeyLensProxy (Proxy name -> o) => o Source #
class (Effect e, Monad m) => MonadEffect e (m :: * -> *) #
(MonadEffect e m, Monad (t m), CanLift e t) => MonadEffect e (t m) | |
(Effect e, Monad m, CanLift e (RuntimeImplemented e)) => MonadEffect e (RuntimeImplemented e m) | |
(Monad m, (~) * a b) => MonadEffect (Early a) (ExceptT (EarlyValue b) m) | |
Monad m => MonadEffect (HandleException e) (ExceptT e m) | |
Monad m => MonadEffect (State s) (StateT s m) | |
TypeError Constraint (UnhandledError a b) => MonadEffect (Signal a b) IO | |
Monad m => MonadEffect (Signal a b) (MaybeT m) | |
(Monad m, (~) * b c) => MonadEffect (Signal a c) (RuntimeImplemented (Signal a b) m) | |
(Show e, Monad m) => MonadEffect (Signal e b) (ExceptT SomeSignal m) | |
Monad m => MonadEffect (Signal e b) (ExceptT e m) | |
allRows :: forall tableName table res. (TableName table ~ tableName, AllRows table res) => res Source #
ddelete :: (LiftedStatement Deleted '[table] res, Selection f, Table table) => DbStatement f '[table] -> res Source #
dupdate :: (MonadEffect Basic m, FromRow table, Selection f) => (Var Updating table -> UpdateExp fields table) -> DbStatement f '[table] -> m [Entity (FromDb Live) table] Source #
insert :: (CanInsert entKind table, MonadEffect Basic m, FromRow table) => Entity entKind table -> m (Entity (FromDb Live) table) Source #
dfilter :: (LiftedStatement Filtered tables res, TableSetVars Filtering tables, Selection f) => (Variables Filtering tables -> ConditionExp) -> DbStatement f tables -> res Source #
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) Source #
dtake :: (LiftedStatement Limited tables res, CanTake f) => Int -> DbStatement f tables -> res Source #
djoin :: LiftedStatement Unfiltered (tables1 ++ tables2) res => DbStatement Unfiltered tables1 -> DbStatement Unfiltered tables2 -> res Source #
dsortOn :: (LiftedStatement Sorted tables res, TableSetVars Sorting tables, Sortable ord, Selection f) => (Variables Sorting tables -> ord) -> DbStatement f tables -> res Source #
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 Source #
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 Source #
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 Source #
dgroupOn :: (Groupable group, TableSetVars Grouping tables, Selection f) => (Variables Grouping tables -> group) -> DbStatement f tables -> GroupStatement group tables Source #
rawQuery :: forall a r m. (MonadEffect Basic m, FromRow a, ToRow r) => Text -> r -> m [Entity (FromDb Live) a] Source #
(<.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 Source #
(>.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 Source #
(==.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 Source #
(/=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 Source #
(<=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 Source #
(>=.) :: ComparableInDbExp a b => a -> b -> ConditionExp infix 4 Source #
(&&.) :: ConditionExp -> ConditionExp -> ConditionExp infixr 3 Source #
(||.) :: ConditionExp -> ConditionExp -> ConditionExp infixr 2 Source #
data ConditionExp where Source #
In :: LiteralCollection collection a => DbExp k a -> collection -> ConditionExp |
Avg a |
Count a |
AggregatableBase (Count (DbExp f a)) Source # | |
type AggregationBaseResult (Count (DbExp f a)) Source # | |
Monad Min | Since: 4.9.0.0 |
Functor Min | Since: 4.9.0.0 |
MonadFix Min | Since: 4.9.0.0 |
Applicative Min | Since: 4.9.0.0 |
Foldable Min | Since: 4.9.0.0 |
Traversable Min | Since: 4.9.0.0 |
ToJSON1 Min | |
FromJSON1 Min | |
Bounded a => Bounded (Min a) | |
Enum a => Enum (Min a) | Since: 4.9.0.0 |
Eq a => Eq (Min a) | |
Data a => Data (Min a) | |
Num a => Num (Min a) | Since: 4.9.0.0 |
Ord a => Ord (Min a) | |
Read a => Read (Min a) | |
Show a => Show (Min a) | |
Generic (Min a) | |
Ord a => Semigroup (Min a) | Since: 4.9.0.0 |
(Ord a, Bounded a) => Monoid (Min a) | Since: 4.9.0.0 |
ToJSON a => ToJSON (Min a) | |
FromJSON a => FromJSON (Min a) | |
Wrapped (Min a) | |
Ord a => AggregatableBase (Min (DbExp f a)) Source # | |
Generic1 * Min | |
(~) * t (Min b) => Rewrapped (Min a) t | |
type Rep (Min a) | |
type Unwrapped (Min a) | |
type AggregationBaseResult (Min (DbExp f a)) Source # | |
type Rep1 * Min | |
Monad Max | Since: 4.9.0.0 |
Functor Max | Since: 4.9.0.0 |
MonadFix Max | Since: 4.9.0.0 |
Applicative Max | Since: 4.9.0.0 |
Foldable Max | Since: 4.9.0.0 |
Traversable Max | Since: 4.9.0.0 |
ToJSON1 Max | |
FromJSON1 Max | |
Bounded a => Bounded (Max a) | |
Enum a => Enum (Max a) | Since: 4.9.0.0 |
Eq a => Eq (Max a) | |
Data a => Data (Max a) | |
Num a => Num (Max a) | Since: 4.9.0.0 |
Ord a => Ord (Max a) | |
Read a => Read (Max a) | |
Show a => Show (Max a) | |
Generic (Max a) | |
Ord a => Semigroup (Max a) | Since: 4.9.0.0 |
(Ord a, Bounded a) => Monoid (Max a) | Since: 4.9.0.0 |
ToJSON a => ToJSON (Max a) | |
FromJSON a => FromJSON (Max a) | |
Wrapped (Max a) | |
Ord a => AggregatableBase (Max (DbExp f a)) Source # | |
Generic1 * Max | |
(~) * t (Max b) => Rewrapped (Max a) t | |
type Rep (Max a) | |
type Unwrapped (Max a) | |
type AggregationBaseResult (Max (DbExp f a)) Source # | |
type Rep1 * Max | |
Monoid under addition.
Monad Sum | Since: 4.8.0.0 |
Functor Sum | Since: 4.8.0.0 |
Applicative Sum | Since: 4.8.0.0 |
Foldable Sum | Since: 4.8.0.0 |
Traversable Sum | Since: 4.8.0.0 |
Representable Sum | |
Bounded a => Bounded (Sum a) | |
Eq a => Eq (Sum a) | |
Data a => Data (Sum a) | Since: 4.8.0.0 |
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) | Since: 4.9.0.0 |
Num a => Monoid (Sum a) | Since: 2.1 |
Wrapped (Sum a) | |
Num a => AggregatableBase (Sum (DbExp f a)) Source # | |
Generic1 * Sum | |
(~) * t (Sum b) => Rewrapped (Sum a) t | |
type Rep Sum | |
type Rep (Sum a) | |
type Unwrapped (Sum a) | |
type AggregationBaseResult (Sum (DbExp f a)) Source # | |
type Rep1 * Sum | |
List a |
Wrap a list for use as a PostgreSQL array.
PGArray | |
|
handleBasicPsql :: MonadIO m => Connection -> RuntimeImplemented Basic (RuntimeImplemented Logging (ExceptT BasicException m)) a -> m a Source #
Handles SQL by querying a PostgreSQL database. Writes logs to console.
connectPostgreSQL :: ByteString -> IO Connection #
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.
handleBasicPsqlWithLogging :: forall m a. (MonadEffects '[Logging, Signal BasicException Query] m, MonadIO m) => Connection -> RuntimeImplemented Basic m a -> m a Source #
Handles SQL by querying a PostgreSQL database. Leaves logs unhandled.
data BasicException Source #
throwBasicToIO :: forall m a. MonadIO m => ExceptT BasicException m a -> m a Source #
logOnlyErrors :: MonadEffect Logging m => RuntimeImplemented Logging m a -> m a Source #
prettyPrintSummary :: MonadIO m => Int -> RuntimeImplemented Logging m a -> m a #
Print out the logs in rich format. Truncates at the given length. Logs will contain: message, timestamp, data, user and the call stack.
printToFile :: [FilePath] -> FilePath -> Q [Dec] Source #
Allows you to print generated template haskell code to a file
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 } instanceFromRow
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
.
delem :: LiteralCollection collection a => DbExp k a -> collection -> ConditionExp Source #
disNothing :: DbExp FieldExp (Maybe a) -> ConditionExp Source #
type GettableField entKind field = FieldIsGettable field (MissingFields entKind) Source #
type ModifyableField table entKind field = SupportedModifyAccess (FieldIsGettableBool field (MissingFields entKind)) (TableFieldType table field) Source #
A field that's settable, but also potentially gettable (if it's already set). If it is gettable then you can modify it, otherwise you can just set it.
type SettableField table entKind field = ModifyableField table entKind field Source #
A synonym for ModifyableField. It still checks if the field is already set.
type family WithFieldSet (field :: Symbol) (entKind :: EntityKind) :: EntityKind where ... Source #
WithFieldSet field (FromDb c) = FromDb c | |
WithFieldSet field (Fresh missing) = Fresh (WithoutMissingField field missing) |
dtrue :: ConditionExp Source #
executeQuery :: (ToRow r, MonadEffect Basic m) => Text -> r -> m () Source #
applySchema :: MonadEffect Basic m => Schema -> m () Source #