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, IsDbExp (TableFieldType table name) ~ False) => TableField table name where
- type TableFieldType table name :: *
- class (AllSatisfy (TableField (UniqueTable name)) (UniqueFields name), KnownSymbol name) => UniqueConstraint name where
- type UniqueTable name :: *
- type UniqueFields name :: [Symbol]
- class (UniqueConstraint name, AllTypesSatisfy NotNull (UniqueTable name) (UniqueFields name)) => PrimaryKeyConstraint name
- 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]
- data MissingField
- data FieldConstraint
- type AllRows table res = (Table table, LiftedStatement Unfiltered '[table] res)
- newtype Entity entKind a = Entity 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 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
- (>.) :: 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
- 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
- connectPostgreSQL :: ByteString -> IO Connection
- mkFromFile :: FilePath -> Q [Dec]
- mkFromFiles :: [FilePath] -> Q [Dec]
- printToFile :: [FilePath] -> FilePath -> Q [Dec]
- class FromRow a where
- field :: FromField a => RowParser a
- data Cached
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, 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 (AllSatisfy (TableField (UniqueTable name)) (UniqueFields name), KnownSymbol name) => UniqueConstraint name Source #
type UniqueTable name :: * Source #
type UniqueFields name :: [Symbol] Source #
class (UniqueConstraint name, AllTypesSatisfy NotNull (UniqueTable name) (UniqueFields name)) => PrimaryKeyConstraint name 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 AllRows table res = (Table table, LiftedStatement Unfiltered '[table] res) Source #
newtype Entity entKind a Source #
Entity a |
(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 # | |
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 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 (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, 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 # | |
(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 # | |
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 Monad m => MonadEffect effKind m #
(MonadEffect method m, MonadTrans t, Monad (t m)) => MonadEffect method (t m) | |
Monad m => MonadEffect effKind (EffectHandler effKind m) | |
TypeError Constraint (UnhandledError a b) => MonadEffect (Signal a b) IO | |
Monad m => MonadEffect (Signal a b) (MaybeT m) | |
Monad m => MonadEffect (State * s) (StateT s m) | |
Monad m => MonadEffect (Signal e b) (ExceptT e m) | |
(Show e, Monad m) => MonadEffect (Signal e b) (ExceptT SomeSignal m) | |
(Monad m, (~) * b c) => MonadEffect (Signal a c) (EffectHandler (Signal a b) 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, SelectionOrSortedSelection 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 infix 3 Source #
(||.) :: ConditionExp -> ConditionExp -> ConditionExp infix 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 | |
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 # | |
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 # | |
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) | |
Data a => Data (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 # | |
handleBasicPsql :: MonadIO m => Connection -> EffectHandler Basic m a -> m a Source #
Handles SQL by querying a PostgreSQL database.
handleBasic :: Functor m => (forall b. FromRow b => SqlRequest b -> m [b]) -> EffectHandler Basic m a -> m a Source #
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.
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
.