-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Type-safe, multi-backend data serialization.
--   
--   Type-safe, data serialization. You must use a specific backend in
--   order to make this useful.
@package persistent
@version 1.1.5.1

module Database.Persist.Util
nullable :: [Text] -> IsNullable
data IsNullable
Nullable :: !WhyNullable -> IsNullable
NotNullable :: IsNullable

-- | The reason why a field is <a>nullable</a> is very important. A field
--   that is nullable because of a <tt>Maybe</tt> tag will have its type
--   changed from <tt>A</tt> to <tt>Maybe A</tt>. OTOH, a field that is
--   nullable because of a <tt>nullable</tt> tag will remain with the same
--   type.
data WhyNullable
ByMaybeAttr :: WhyNullable
ByNullableAttr :: WhyNullable
deprecate :: String -> a -> a
instance Eq WhyNullable
instance Show WhyNullable
instance Eq IsNullable
instance Show IsNullable

module Database.Persist.TH.Library
apE :: Either x (y -> z) -> Either x y -> Either x z

module Database.Persist.EntityDef
newtype HaskellName
HaskellName :: Text -> HaskellName
unHaskellName :: HaskellName -> Text
newtype DBName
DBName :: Text -> DBName
unDBName :: DBName -> Text
type Attr = Text
data EntityDef
EntityDef :: HaskellName -> DBName -> DBName -> [Attr] -> [FieldDef] -> [UniqueDef] -> [Text] -> Map Text [ExtraLine] -> Bool -> EntityDef
entityHaskell :: EntityDef -> HaskellName
entityDB :: EntityDef -> DBName
entityID :: EntityDef -> DBName
entityAttrs :: EntityDef -> [Attr]
entityFields :: EntityDef -> [FieldDef]
entityUniques :: EntityDef -> [UniqueDef]
entityDerives :: EntityDef -> [Text]
entityExtra :: EntityDef -> Map Text [ExtraLine]
entitySum :: EntityDef -> Bool
data FieldDef
FieldDef :: HaskellName -> DBName -> FieldType -> [Attr] -> FieldDef
fieldHaskell :: FieldDef -> HaskellName
fieldDB :: FieldDef -> DBName
fieldType :: FieldDef -> FieldType
fieldAttrs :: FieldDef -> [Attr]
data FieldType

-- | optional module, name
FTTypeCon :: (Maybe Text) -> Text -> FieldType
FTApp :: FieldType -> FieldType -> FieldType
FTList :: FieldType -> FieldType
data UniqueDef
UniqueDef :: HaskellName -> DBName -> [(HaskellName, DBName)] -> [Attr] -> UniqueDef
uniqueHaskell :: UniqueDef -> HaskellName
uniqueDBName :: UniqueDef -> DBName
uniqueFields :: UniqueDef -> [(HaskellName, DBName)]
uniqueAttrs :: UniqueDef -> [Attr]
type ExtraLine = [Text]
stripId :: FieldType -> Maybe Text
instance Show HaskellName
instance Eq HaskellName
instance Read HaskellName
instance Ord HaskellName
instance Show DBName
instance Eq DBName
instance Read DBName
instance Ord DBName
instance Show FieldType
instance Eq FieldType
instance Read FieldType
instance Ord FieldType
instance Show FieldDef
instance Eq FieldDef
instance Read FieldDef
instance Ord FieldDef
instance Show UniqueDef
instance Eq UniqueDef
instance Read UniqueDef
instance Ord UniqueDef
instance Show EntityDef
instance Eq EntityDef
instance Read EntityDef
instance Ord EntityDef

module Database.Persist.Quasi

-- | Parses a quasi-quoted syntax into a list of entity definitions.
parse :: PersistSettings -> Text -> [EntityDef]
data PersistSettings
PersistSettings :: (Text -> Text) -> PersistSettings
psToDBName :: PersistSettings -> Text -> Text
upperCaseSettings :: PersistSettings
lowerCaseSettings :: PersistSettings
instance Show Token
instance Eq Token


-- | API for database actions. The API deals with fields and entities. In
--   SQL, a field corresponds to a column, and should be a single
--   non-composite value. An entity corresponds to a SQL table, so an
--   entity is a collection of fields.
module Database.Persist.Store

-- | A raw value which can be stored in any backend and can be marshalled
--   to and from a <a>PersistField</a>.
data PersistValue
PersistText :: Text -> PersistValue
PersistByteString :: ByteString -> PersistValue
PersistInt64 :: Int64 -> PersistValue
PersistDouble :: Double -> PersistValue
PersistBool :: Bool -> PersistValue
PersistDay :: Day -> PersistValue
PersistTimeOfDay :: TimeOfDay -> PersistValue
PersistUTCTime :: UTCTime -> PersistValue
PersistZonedTime :: ZT -> PersistValue
PersistNull :: PersistValue
PersistList :: [PersistValue] -> PersistValue
PersistMap :: [(Text, PersistValue)] -> PersistValue

-- | intended especially for MongoDB backend
PersistObjectId :: ByteString -> PersistValue

-- | A SQL data type. Naming attempts to reflect the underlying Haskell
--   datatypes, eg SqlString instead of SqlVarchar. Different SQL databases
--   may have different translations for these types.
data SqlType
SqlString :: SqlType
SqlInt32 :: SqlType
SqlInt64 :: SqlType
SqlReal :: SqlType
SqlBool :: SqlType
SqlDay :: SqlType
SqlTime :: SqlType
SqlDayTime :: SqlType
SqlDayTimeZoned :: SqlType
SqlBlob :: SqlType

-- | a backend-specific name
SqlOther :: Text -> SqlType

-- | A value which can be marshalled to and from a <a>PersistValue</a>.
class PersistField a where isNullable _ = False
toPersistValue :: PersistField a => a -> PersistValue
fromPersistValue :: PersistField a => PersistValue -> Either Text a
sqlType :: PersistField a => a -> SqlType
isNullable :: PersistField a => a -> Bool

-- | A single database entity. For example, if writing a blog application,
--   a blog entry would be an entry, containing fields such as title and
--   content.
class PersistEntity val where data family EntityField val :: * -> * type family PersistEntityBackend val data family Unique val
persistFieldDef :: PersistEntity val => EntityField val typ -> FieldDef
entityDef :: PersistEntity val => val -> EntityDef
toPersistFields :: PersistEntity val => val -> [SomePersistField]
fromPersistValues :: PersistEntity val => [PersistValue] -> Either Text val
halfDefined :: PersistEntity val => val
persistUniqueToFieldNames :: PersistEntity val => Unique val -> [(HaskellName, DBName)]
persistUniqueToValues :: PersistEntity val => Unique val -> [PersistValue]
persistUniqueKeys :: PersistEntity val => val -> [Unique val]
persistIdField :: PersistEntity val => EntityField val (Key val)
fieldLens :: PersistEntity val => EntityField val field -> (forall f. Functor f => (field -> f field) -> Entity val -> f (Entity val))
class MonadIO m => PersistStore m where type family PersistMonadBackend m insert_ val = insert val >> return ()
insert :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => val -> m (Key val)
insert_ :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => val -> m ()
insertKey :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m ()
repsert :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m ()
replace :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m ()
delete :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> m ()
get :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> m (Maybe val)

-- | Queries against unique keys (other than the id).
--   
--   Please read the general Persistent documentation to learn how to
--   create Unique keys. SQL backends automatically create uniqueness
--   constraints, but for MongoDB you must place a unique index on the
--   field.
class PersistStore m => PersistUnique m where insertUnique datum = do { isUnique <- checkUnique datum; if isUnique then Just `liftM` insert datum else return Nothing }
getBy :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => Unique val -> m (Maybe (Entity val))
deleteBy :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => Unique val -> m ()
insertUnique :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => val -> m (Maybe (Key val))
data PersistFilter
Eq :: PersistFilter
Ne :: PersistFilter
Gt :: PersistFilter
Lt :: PersistFilter
Ge :: PersistFilter
Le :: PersistFilter
In :: PersistFilter
NotIn :: PersistFilter
BackendSpecificFilter :: Text -> PersistFilter
data SomePersistField
SomePersistField :: a -> SomePersistField

-- | Avoid orphan instances.
newtype ZT
ZT :: ZonedTime -> ZT

-- | Insert a value, checking for conflicts with any unique constraints. If
--   a duplicate exists in the database, it is returned as <a>Left</a>.
--   Otherwise, the new 'Key is returned as <a>Right</a>.
insertBy :: (PersistEntity v, PersistStore m, PersistUnique m, PersistMonadBackend m ~ PersistEntityBackend v) => v -> m (Either (Entity v) (Key v))

-- | A modification of <a>getBy</a>, which takes the <a>PersistEntity</a>
--   itself instead of a <a>Unique</a> value. Returns a value matching
--   <i>one</i> of the unique keys. This function makes the most sense on
--   entities with a single <a>Unique</a> constructor.
getByValue :: (PersistEntity v, PersistUnique m, PersistEntityBackend v ~ PersistMonadBackend m) => v -> m (Maybe (Entity v))

-- | Same as get, but for a non-null (not Maybe) foreign key Unsafe unless
--   your database is enforcing that the foreign key is valid
getJust :: (PersistStore m, PersistEntity val, Show (Key val), PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> m val
belongsTo :: (PersistStore m, PersistEntity ent1, PersistEntity ent2, PersistMonadBackend m ~ PersistEntityBackend ent2) => (ent1 -> Maybe (Key ent2)) -> ent1 -> m (Maybe ent2)

-- | same as belongsTo, but uses <tt>getJust</tt> and therefore is
--   similarly unsafe
belongsToJust :: (PersistStore m, PersistEntity ent1, PersistEntity ent2, PersistMonadBackend m ~ PersistEntityBackend ent2) => (ent1 -> Key ent2) -> ent1 -> m ent2

-- | Check whether there are any conflicts for unique keys with this entity
--   and existing entities in the database.
--   
--   Returns <a>True</a> if the entity would be unique, and could thus
--   safely be <a>insert</a>ed; returns <a>False</a> on a conflict.
checkUnique :: (PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val, PersistUnique m) => val -> m Bool
class (PersistStore m, PersistEntity a, PersistEntityBackend a ~ PersistMonadBackend m) => DeleteCascade a m
deleteCascade :: DeleteCascade a m => Key a -> m ()
data PersistException

-- | Generic Exception
PersistError :: Text -> PersistException
PersistMarshalError :: Text -> PersistException
PersistInvalidField :: Text -> PersistException
PersistForeignConstraintUnmet :: Text -> PersistException
PersistMongoDBError :: Text -> PersistException
PersistMongoDBUnsupported :: Text -> PersistException
newtype KeyBackend backend entity
Key :: PersistValue -> KeyBackend backend entity
unKey :: KeyBackend backend entity -> PersistValue

-- | Helper wrapper, equivalent to <tt>Key (PersistEntityBackend val)
--   val</tt>.
--   
--   Since 1.1.0
type Key val = KeyBackend (PersistEntityBackend val) val

-- | Datatype that represents an entity, with both its key and its Haskell
--   representation.
--   
--   When using the an SQL-based backend (such as SQLite or PostgreSQL), an
--   <a>Entity</a> may take any number of columns depending on how many
--   fields it has. In order to reconstruct your entity on the Haskell
--   side, <tt>persistent</tt> needs all of your entity columns and in the
--   right order. Note that you don't need to worry about this when using
--   <tt>persistent</tt>'s API since everything is handled correctly behind
--   the scenes.
--   
--   However, if you want to issue a raw SQL command that returns an
--   <a>Entity</a>, then you have to be careful with the column order.
--   While you could use <tt>SELECT Entity.* WHERE ...</tt> and that would
--   work most of the time, there are times when the order of the columns
--   on your database is different from the order that <tt>persistent</tt>
--   expects (for example, if you add a new field in the middle of you
--   entity definition and then use the migration code --
--   <tt>persistent</tt> will expect the column to be in the middle, but
--   your DBMS will put it as the last column). So, instead of using a
--   query like the one above, you may use <a>rawSql</a> (from the
--   <a>Database.Persist.GenericSql</a> module) with its /entity selection
--   placeholder/ (a double question mark <tt>??</tt>). Using
--   <tt>rawSql</tt> the query above must be written as <tt>SELECT ?? WHERE
--   ..</tt>. Then <tt>rawSql</tt> will replace <tt>??</tt> with the list
--   of all columns that we need from your entity in the right order. If
--   your query returns two entities (i.e. <tt>(Entity backend a, Entity
--   backend b)</tt>), then you must you use <tt>SELECT ??, ?? WHERE
--   ...</tt>, and so on.
data Entity entity
Entity :: Key entity -> entity -> Entity entity
entityKey :: Entity entity -> Key entity
entityVal :: Entity entity -> entity
getPersistMap :: PersistValue -> Either Text [(Text, PersistValue)]
listToJSON :: [PersistValue] -> Text
mapToJSON :: [(Text, PersistValue)] -> Text

-- | Represents a value containing all the configuration options for a
--   specific backend. This abstraction makes it easier to write code that
--   can easily swap backends.
class PersistConfig c where type family PersistConfigBackend c :: (* -> *) -> * -> * type family PersistConfigPool c applyEnv = return
loadConfig :: PersistConfig c => Value -> Parser c
applyEnv :: PersistConfig c => c -> IO c
createPoolConfig :: PersistConfig c => c -> IO (PersistConfigPool c)
runPool :: (PersistConfig c, MonadBaseControl IO m, MonadIO m) => c -> PersistConfigBackend c m a -> PersistConfigPool c -> m a
instance [overlap ok] Typeable PersistException
instance [overlap ok] Typeable ZT
instance [overlap ok] Typeable PersistValue
instance [overlap ok] Typeable SqlType
instance [overlap ok] Show PersistException
instance [overlap ok] Show ZT
instance [overlap ok] Read ZT
instance [overlap ok] Show PersistValue
instance [overlap ok] Read PersistValue
instance [overlap ok] Eq PersistValue
instance [overlap ok] Ord PersistValue
instance [overlap ok] Show SqlType
instance [overlap ok] Read SqlType
instance [overlap ok] Eq SqlType
instance [overlap ok] Ord SqlType
instance [overlap ok] Show (KeyBackend backend entity)
instance [overlap ok] Read (KeyBackend backend entity)
instance [overlap ok] Eq (KeyBackend backend entity)
instance [overlap ok] Ord (KeyBackend backend entity)
instance [overlap ok] PersistField (KeyBackend backend entity)
instance [overlap ok] Eq entity => Eq (Entity entity)
instance [overlap ok] Ord entity => Ord (Entity entity)
instance [overlap ok] Show entity => Show (Entity entity)
instance [overlap ok] Read entity => Read (Entity entity)
instance [overlap ok] Read PersistFilter
instance [overlap ok] Show PersistFilter
instance [overlap ok] PersistField PersistValue
instance [overlap ok] (Monoid w, PersistUnique m) => PersistUnique (WriterT w m)
instance [overlap ok] PersistUnique m => PersistUnique (StateT s m)
instance [overlap ok] (Monoid w, PersistUnique m) => PersistUnique (RWST r w s m)
instance [overlap ok] (Monoid w, PersistUnique m) => PersistUnique (RWST r w s m)
instance [overlap ok] (Monoid w, PersistUnique m) => PersistUnique (WriterT w m)
instance [overlap ok] PersistUnique m => PersistUnique (Pipe l i o u m)
instance [overlap ok] PersistUnique m => PersistUnique (ResourceT m)
instance [overlap ok] PersistUnique m => PersistUnique (StateT s m)
instance [overlap ok] PersistUnique m => PersistUnique (ContT r m)
instance [overlap ok] PersistUnique m => PersistUnique (ReaderT r m)
instance [overlap ok] (Error e, PersistUnique m) => PersistUnique (ErrorT e m)
instance [overlap ok] PersistUnique m => PersistUnique (MaybeT m)
instance [overlap ok] PersistUnique m => PersistUnique (ListT m)
instance [overlap ok] PersistUnique m => PersistUnique (IdentityT m)
instance [overlap ok] PersistUnique m => PersistUnique (LoggingT m)
instance [overlap ok] (Monoid w, PersistStore m) => PersistStore (WriterT w m)
instance [overlap ok] PersistStore m => PersistStore (StateT s m)
instance [overlap ok] (Monoid w, PersistStore m) => PersistStore (RWST r w s m)
instance [overlap ok] (Monoid w, PersistStore m) => PersistStore (RWST r w s m)
instance [overlap ok] (Monoid w, PersistStore m) => PersistStore (WriterT w m)
instance [overlap ok] PersistStore m => PersistStore (ConduitM i o m)
instance [overlap ok] PersistStore m => PersistStore (Pipe l i o u m)
instance [overlap ok] PersistStore m => PersistStore (ResourceT m)
instance [overlap ok] PersistStore m => PersistStore (StateT s m)
instance [overlap ok] PersistStore m => PersistStore (ContT r m)
instance [overlap ok] PersistStore m => PersistStore (ReaderT r m)
instance [overlap ok] (Error e, PersistStore m) => PersistStore (ErrorT e m)
instance [overlap ok] PersistStore m => PersistStore (MaybeT m)
instance [overlap ok] PersistStore m => PersistStore (ListT m)
instance [overlap ok] PersistStore m => PersistStore (IdentityT m)
instance [overlap ok] PersistStore m => PersistStore (LoggingT m)
instance [overlap ok] FromJSON (KeyBackend backend entity)
instance [overlap ok] ToJSON (KeyBackend backend entity)
instance [overlap ok] PersistField SomePersistField
instance [overlap ok] PersistField v => PersistField (Map Text v)
instance [overlap ok] (PersistField a, PersistField b) => PersistField (a, b)
instance [overlap ok] (Ord a, PersistField a) => PersistField (Set a)
instance [overlap ok] PersistField a => PersistField [a]
instance [overlap ok] PersistField a => PersistField (Maybe a)
instance [overlap ok] PersistField ZonedTime
instance [overlap ok] PersistField UTCTime
instance [overlap ok] PersistField TimeOfDay
instance [overlap ok] PersistField Day
instance [overlap ok] PersistField Bool
instance [overlap ok] PersistField Double
instance [overlap ok] PersistField Word64
instance [overlap ok] PersistField Word32
instance [overlap ok] PersistField Word16
instance [overlap ok] PersistField Word8
instance [overlap ok] PersistField Int64
instance [overlap ok] PersistField Int32
instance [overlap ok] PersistField Int16
instance [overlap ok] PersistField Int8
instance [overlap ok] PersistField Int
instance [overlap ok] PersistField Html
instance [overlap ok] PersistField Text
instance [overlap ok] PersistField Text
instance [overlap ok] PersistField ByteString
instance [overlap ok] PersistField String
instance [overlap ok] FromJSON PersistValue
instance [overlap ok] ToJSON PersistValue
instance [overlap ok] PathPiece PersistValue
instance [overlap ok] Ord ZT
instance [overlap ok] Eq ZT
instance [overlap ok] Error PersistException
instance [overlap ok] Exception PersistException


-- | Code that is only needed for writing GenericSql backends.
module Database.Persist.GenericSql.Internal
data Connection
Connection :: (Text -> IO Statement) -> (DBName -> [DBName] -> DBName -> InsertSqlResult) -> IORef (Map Text Statement) -> IO () -> (forall v. PersistEntity v => [EntityDef] -> (Text -> IO Statement) -> v -> IO (Either [Text] [(Bool, Text)])) -> ((Text -> IO Statement) -> IO ()) -> ((Text -> IO Statement) -> IO ()) -> ((Text -> IO Statement) -> IO ()) -> (DBName -> Text) -> Text -> Connection

-- | table name, column names, id name, either 1 or 2 statements to run
prepare :: Connection -> Text -> IO Statement
insertSql :: Connection -> DBName -> [DBName] -> DBName -> InsertSqlResult
stmtMap :: Connection -> IORef (Map Text Statement)
close :: Connection -> IO ()
migrateSql :: Connection -> forall v. PersistEntity v => [EntityDef] -> (Text -> IO Statement) -> v -> IO (Either [Text] [(Bool, Text)])
begin :: Connection -> (Text -> IO Statement) -> IO ()
commitC :: Connection -> (Text -> IO Statement) -> IO ()
rollbackC :: Connection -> (Text -> IO Statement) -> IO ()
escapeName :: Connection -> DBName -> Text
noLimit :: Connection -> Text
data Statement
Statement :: IO () -> IO () -> ([PersistValue] -> IO Int64) -> (forall m. MonadResource m => [PersistValue] -> Source m [PersistValue]) -> Statement
finalize :: Statement -> IO ()
reset :: Statement -> IO ()
execute :: Statement -> [PersistValue] -> IO Int64
withStmt :: Statement -> forall m. MonadResource m => [PersistValue] -> Source m [PersistValue]
withSqlConn :: (MonadIO m, MonadBaseControl IO m) => IO Connection -> (Connection -> m a) -> m a
withSqlPool :: MonadIO m => IO Connection -> Int -> (Pool Connection -> m a) -> m a
createSqlPool :: MonadIO m => IO Connection -> Int -> m (Pool Connection)

-- | Create the list of columns for the given entity.
mkColumns :: PersistEntity val => [EntityDef] -> val -> ([Column], [UniqueDef])
data Column
Column :: DBName -> Bool -> SqlType -> Maybe Text -> Maybe Integer -> (Maybe (DBName, DBName)) -> Column
cName :: Column -> DBName
cNull :: Column -> Bool
cType :: Column -> SqlType
cDefault :: Column -> Maybe Text
cMaxLen :: Column -> Maybe Integer
cReference :: Column -> (Maybe (DBName, DBName))
logSQL :: Q Exp
data InsertSqlResult
ISRSingle :: Text -> InsertSqlResult
ISRInsertGet :: Text -> Text -> InsertSqlResult
instance Eq Column
instance Ord Column
instance Show Column

module Database.Persist.GenericSql.Raw
withStmt :: (MonadSqlPersist m, MonadResource m) => Text -> [PersistValue] -> Source m [PersistValue]
execute :: MonadSqlPersist m => Text -> [PersistValue] -> m ()
executeCount :: MonadSqlPersist m => Text -> [PersistValue] -> m Int64
newtype SqlPersist m a
SqlPersist :: ReaderT Connection m a -> SqlPersist m a
unSqlPersist :: SqlPersist m a -> ReaderT Connection m a
getStmt' :: Connection -> Text -> IO Statement
getStmt :: MonadSqlPersist m => Text -> m Statement
data SqlBackend
class (MonadIO m, MonadLogger m) => MonadSqlPersist m
askSqlConn :: MonadSqlPersist m => m Connection
data StatementAlreadyFinalized
StatementAlreadyFinalized :: Text -> StatementAlreadyFinalized
instance Typeable StatementAlreadyFinalized
instance Monad m => Monad (SqlPersist m)
instance MonadIO m => MonadIO (SqlPersist m)
instance MonadTrans SqlPersist
instance Functor m => Functor (SqlPersist m)
instance Applicative m => Applicative (SqlPersist m)
instance MonadPlus m => MonadPlus (SqlPersist m)
instance Show StatementAlreadyFinalized
instance Exception StatementAlreadyFinalized
instance MonadLogger m => MonadLogger (SqlPersist m)
instance (Monoid w, MonadSqlPersist m) => MonadSqlPersist (WriterT w m)
instance MonadSqlPersist m => MonadSqlPersist (StateT s m)
instance (Monoid w, MonadSqlPersist m) => MonadSqlPersist (RWST r w s m)
instance (Monoid w, MonadSqlPersist m) => MonadSqlPersist (RWST r w s m)
instance (Monoid w, MonadSqlPersist m) => MonadSqlPersist (WriterT w m)
instance MonadSqlPersist m => MonadSqlPersist (ConduitM i o m)
instance MonadSqlPersist m => MonadSqlPersist (Pipe l i o u m)
instance MonadSqlPersist m => MonadSqlPersist (ResourceT m)
instance MonadSqlPersist m => MonadSqlPersist (StateT s m)
instance MonadSqlPersist m => MonadSqlPersist (ContT r m)
instance MonadSqlPersist m => MonadSqlPersist (ReaderT r m)
instance (Error e, MonadSqlPersist m) => MonadSqlPersist (ErrorT e m)
instance MonadSqlPersist m => MonadSqlPersist (MaybeT m)
instance MonadSqlPersist m => MonadSqlPersist (ListT m)
instance MonadSqlPersist m => MonadSqlPersist (IdentityT m)
instance MonadSqlPersist m => MonadSqlPersist (LoggingT m)
instance (MonadIO m, MonadLogger m) => MonadSqlPersist (SqlPersist m)
instance MonadResource m => MonadResource (SqlPersist m)
instance MonadTransControl SqlPersist
instance MonadBaseControl backend m => MonadBaseControl backend (SqlPersist m)
instance MonadBase backend m => MonadBase backend (SqlPersist m)
instance MonadThrow m => MonadThrow (SqlPersist m)

module Database.Persist.GenericSql.Migration
type Migration m = WriterT [Text] (WriterT CautiousMigration m) ()
parseMigration :: Monad m => Migration m -> m (Either [Text] CautiousMigration)
parseMigration' :: Monad m => Migration m -> m (CautiousMigration)
printMigration :: (MonadBaseControl IO m, MonadIO m) => Migration (SqlPersist m) -> SqlPersist m ()
getMigration :: (MonadBaseControl IO m, MonadIO m) => Migration (SqlPersist m) -> SqlPersist m [Sql]
runMigration :: (MonadIO m, MonadBaseControl IO m, MonadLogger m) => Migration (SqlPersist m) -> SqlPersist m ()

-- | Same as <a>runMigration</a>, but returns a list of the SQL commands
--   executed instead of printing them to stderr.
runMigrationSilent :: (MonadBaseControl IO m, MonadIO m, MonadLogger m) => Migration (SqlPersist m) -> SqlPersist m [Text]
runMigrationUnsafe :: (MonadBaseControl IO m, MonadIO m, MonadLogger m) => Migration (SqlPersist m) -> SqlPersist m ()
migrate :: (MonadIO m, MonadBaseControl IO m, PersistEntity val) => [EntityDef] -> val -> Migration (SqlPersist m)

-- | Perform a database commit.
commit :: MonadIO m => SqlPersist m ()

-- | Perform a database rollback.
rollback :: MonadIO m => SqlPersist m ()


-- | This is a helper module for creating SQL backends. Regular users do
--   not need to use this module.
module Database.Persist.GenericSql
newtype SqlPersist m a
SqlPersist :: ReaderT Connection m a -> SqlPersist m a
unSqlPersist :: SqlPersist m a -> ReaderT Connection m a
data Connection
type ConnectionPool = Pool Connection
data Statement
runSqlConn :: MonadBaseControl IO m => SqlPersist m a -> Connection -> m a

-- | Get a connection from the pool, run the given action, and then return
--   the connection to the pool.
runSqlPool :: MonadBaseControl IO m => SqlPersist m a -> Pool Connection -> m a

-- | Helper wrapper, equivalent to <tt>Key (PersistEntityBackend val)
--   val</tt>.
--   
--   Since 1.1.0
type Key val = KeyBackend (PersistEntityBackend val) val

-- | A <a>Checkmark</a> should be used as a field type whenever a
--   uniqueness constraint should guarantee that a certain kind of record
--   may appear at most once, but other kinds of records may appear any
--   number of times.
--   
--   <i>NOTE:</i> You need to mark any <tt>Checkmark</tt> fields as
--   <tt>nullable</tt> (see the following example).
--   
--   For example, suppose there's a <tt>Location</tt> entity that
--   represents where a user has lived:
--   
--   <pre>
--    Location
--        user    UserId
--        name    Text
--        current Checkmark nullable
--   
--   UniqueLocation user current
--   </pre>
--   
--   The <tt>UniqueLocation</tt> constraint allows any number of
--   <a>Inactive</a> <tt>Location</tt>s to be <tt>current</tt>. However,
--   there may be at most one <tt>current</tt> <tt>Location</tt> per user
--   (i.e., either zero or one per user).
--   
--   This data type works because of the way that SQL treats
--   <tt>NULL</tt>able fields within uniqueness constraints. The SQL
--   standard says that <tt>NULL</tt> values should be considered
--   different, so we represent <a>Inactive</a> as SQL <tt>NULL</tt>, thus
--   allowing any number of <a>Inactive</a> records. On the other hand, we
--   represent <a>Active</a> as <tt>TRUE</tt>, so the uniqueness constraint
--   will disallow more than one <a>Active</a> record.
--   
--   <i>Note:</i> There may be DBMSs that do not respect the SQL standard's
--   treatment of <tt>NULL</tt> values on uniqueness constraints, please
--   check if this data type works before relying on it.
--   
--   The SQL <tt>BOOLEAN</tt> type is used because it's the smallest data
--   type available. Note that we never use <tt>FALSE</tt>, just
--   <tt>TRUE</tt> and <tt>NULL</tt>. Provides the same behavior <tt>Maybe
--   ()</tt> would if <tt>()</tt> was a valid <a>PersistField</a>.
data Checkmark

-- | When used on a uniqueness constraint, there may be at most one
--   <a>Active</a> record.
Active :: Checkmark

-- | When used on a uniqueness constraint, there may be any number of
--   <a>Inactive</a> records.
Inactive :: Checkmark

-- | Execute a raw SQL statement and return its results as a list.
--   
--   If you're using <a>Entity</a><tt>s</tt> (which is quite likely), then
--   you <i>must</i> use entity selection placeholders (double question
--   mark, <tt>??</tt>). These <tt>??</tt> placeholders are then replaced
--   for the names of the columns that we need for your entities. You'll
--   receive an error if you don't use the placeholders. Please see the
--   <a>Entity</a><tt>s</tt> documentation for more details.
--   
--   You may put value placeholders (question marks, <tt>?</tt>) in your
--   SQL query. These placeholders are then replaced by the values you pass
--   on the second parameter, already correctly escaped. You may want to
--   use <a>toPersistValue</a> to help you constructing the placeholder
--   values.
--   
--   Since you're giving a raw SQL statement, you don't get any guarantees
--   regarding safety. If <a>rawSql</a> is not able to parse the results of
--   your query back, then an exception is raised. However, most common
--   problems are mitigated by using the entity selection placeholder
--   <tt>??</tt>, and you shouldn't see any error at all if you're not
--   using <a>Single</a>.
rawSql :: (RawSql a, MonadResource m, MonadLogger m) => Text -> [PersistValue] -> SqlPersist m [a]

-- | Datatype that represents an entity, with both its key and its Haskell
--   representation.
--   
--   When using the an SQL-based backend (such as SQLite or PostgreSQL), an
--   <a>Entity</a> may take any number of columns depending on how many
--   fields it has. In order to reconstruct your entity on the Haskell
--   side, <tt>persistent</tt> needs all of your entity columns and in the
--   right order. Note that you don't need to worry about this when using
--   <tt>persistent</tt>'s API since everything is handled correctly behind
--   the scenes.
--   
--   However, if you want to issue a raw SQL command that returns an
--   <a>Entity</a>, then you have to be careful with the column order.
--   While you could use <tt>SELECT Entity.* WHERE ...</tt> and that would
--   work most of the time, there are times when the order of the columns
--   on your database is different from the order that <tt>persistent</tt>
--   expects (for example, if you add a new field in the middle of you
--   entity definition and then use the migration code --
--   <tt>persistent</tt> will expect the column to be in the middle, but
--   your DBMS will put it as the last column). So, instead of using a
--   query like the one above, you may use <a>rawSql</a> (from the
--   <a>Database.Persist.GenericSql</a> module) with its /entity selection
--   placeholder/ (a double question mark <tt>??</tt>). Using
--   <tt>rawSql</tt> the query above must be written as <tt>SELECT ?? WHERE
--   ..</tt>. Then <tt>rawSql</tt> will replace <tt>??</tt> with the list
--   of all columns that we need from your entity in the right order. If
--   your query returns two entities (i.e. <tt>(Entity backend a, Entity
--   backend b)</tt>), then you must you use <tt>SELECT ??, ?? WHERE
--   ...</tt>, and so on.
data Entity entity
Entity :: Key entity -> entity -> Entity entity
entityKey :: Entity entity -> Key entity
entityVal :: Entity entity -> entity

-- | A single column (see <a>rawSql</a>). Any <a>PersistField</a> may be
--   used here, including <a>PersistValue</a> (which does not do any
--   processing).
newtype Single a
Single :: a -> Single a
unSingle :: Single a -> a

-- | Class for data types that may be retrived from a <a>rawSql</a> query.
class RawSql a
type Migration m = WriterT [Text] (WriterT CautiousMigration m) ()
parseMigration :: Monad m => Migration m -> m (Either [Text] CautiousMigration)
parseMigration' :: Monad m => Migration m -> m (CautiousMigration)
printMigration :: (MonadBaseControl IO m, MonadIO m) => Migration (SqlPersist m) -> SqlPersist m ()
getMigration :: (MonadBaseControl IO m, MonadIO m) => Migration (SqlPersist m) -> SqlPersist m [Sql]
runMigration :: (MonadIO m, MonadBaseControl IO m, MonadLogger m) => Migration (SqlPersist m) -> SqlPersist m ()

-- | Same as <a>runMigration</a>, but returns a list of the SQL commands
--   executed instead of printing them to stderr.
runMigrationSilent :: (MonadBaseControl IO m, MonadIO m, MonadLogger m) => Migration (SqlPersist m) -> SqlPersist m [Text]
runMigrationUnsafe :: (MonadBaseControl IO m, MonadIO m, MonadLogger m) => Migration (SqlPersist m) -> SqlPersist m ()
migrate :: (MonadIO m, MonadBaseControl IO m, PersistEntity val) => [EntityDef] -> val -> Migration (SqlPersist m)

-- | Perform a database commit.
commit :: MonadIO m => SqlPersist m ()

-- | Perform a database rollback.
rollback :: MonadIO m => SqlPersist m ()
instance Eq Checkmark
instance Ord Checkmark
instance Read Checkmark
instance Show Checkmark
instance Enum Checkmark
instance Bounded Checkmark
instance Eq a => Eq (Single a)
instance Ord a => Ord (Single a)
instance Show a => Show (Single a)
instance Read a => Read (Single a)
instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h) => RawSql (a, b, c, d, e, f, g, h)
instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g) => RawSql (a, b, c, d, e, f, g)
instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f) => RawSql (a, b, c, d, e, f)
instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e) => RawSql (a, b, c, d, e)
instance (RawSql a, RawSql b, RawSql c, RawSql d) => RawSql (a, b, c, d)
instance (RawSql a, RawSql b, RawSql c) => RawSql (a, b, c)
instance (RawSql a, RawSql b) => RawSql (a, b)
instance RawSql a => RawSql (Maybe a)
instance PersistEntity a => RawSql (Entity a)
instance PersistField a => RawSql (Single a)
instance PathPiece Checkmark
instance PersistField Checkmark
instance (MonadResource m, MonadLogger m) => PersistUnique (SqlPersist m)
instance (MonadResource m, MonadLogger m) => PersistStore (SqlPersist m)
instance PathPiece (KeyBackend SqlBackend entity)

module Database.Persist.Query.Internal
class PersistStore m => PersistQuery m where updateGet key ups = do { update key ups; get key >>= maybe (liftIO $ throwIO $ KeyNotFound $ show key) return } selectFirst filts opts = selectSource filts ((LimitTo 1) : opts) $$ head
update :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => Key val -> [Update val] -> m ()
updateGet :: (PersistQuery m, PersistEntity val, PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> [Update val] -> m val
updateWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [Update val] -> m ()
deleteWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m ()
selectSource :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Entity val)
selectFirst :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m (Maybe (Entity val))
selectKeys :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Key val)
count :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m Int

-- | Call <a>selectSource</a> but return the result as a list.
selectList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Entity val]

-- | Call <a>selectKeys</a> but return the result as a list.
selectKeysList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Key val]
data SelectOpt v
Asc :: (EntityField v typ) -> SelectOpt v
Desc :: (EntityField v typ) -> SelectOpt v
OffsetBy :: Int -> SelectOpt v
LimitTo :: Int -> SelectOpt v
limitOffsetOrder :: PersistEntity val => [SelectOpt val] -> (Int, Int, [SelectOpt val])

-- | Filters which are available for <tt>select</tt>, <a>updateWhere</a>
--   and <a>deleteWhere</a>. Each filter constructor specifies the field
--   being filtered on, the type of comparison applied (equals, not equals,
--   etc) and the argument for the comparison.
data Filter v
Filter :: EntityField v typ -> Either typ [typ] -> PersistFilter -> Filter v
filterField :: Filter v -> EntityField v typ
filterValue :: Filter v -> Either typ [typ]
filterFilter :: Filter v -> PersistFilter

-- | convenient for internal use, not needed for the API
FilterAnd :: [Filter v] -> Filter v
FilterOr :: [Filter v] -> Filter v
BackendFilter :: (BackendSpecificFilter (PersistEntityBackend v) v) -> Filter v
data PersistUpdate
Assign :: PersistUpdate
Add :: PersistUpdate
Subtract :: PersistUpdate
Multiply :: PersistUpdate
Divide :: PersistUpdate
data Update v
Update :: EntityField v typ -> typ -> PersistUpdate -> Update v
updateField :: Update v -> EntityField v typ
updateValue :: Update v -> typ
updateUpdate :: Update v -> PersistUpdate
updateFieldDef :: PersistEntity v => Update v -> FieldDef
deleteCascadeWhere :: (DeleteCascade a m, PersistQuery m) => [Filter a] -> m ()
data UpdateGetException
KeyNotFound :: String -> UpdateGetException
instance Typeable UpdateGetException
instance Read PersistUpdate
instance Show PersistUpdate
instance Enum PersistUpdate
instance Bounded PersistUpdate
instance (Monoid w, PersistQuery m) => PersistQuery (WriterT w m)
instance PersistQuery m => PersistQuery (StateT s m)
instance (Monoid w, PersistQuery m) => PersistQuery (RWST r w s m)
instance (Monoid w, PersistQuery m) => PersistQuery (RWST r w s m)
instance (Monoid w, PersistQuery m) => PersistQuery (WriterT w m)
instance PersistQuery m => PersistQuery (ConduitM i o m)
instance PersistQuery m => PersistQuery (Pipe l i o u m)
instance PersistQuery m => PersistQuery (ResourceT m)
instance PersistQuery m => PersistQuery (StateT s m)
instance PersistQuery m => PersistQuery (ContT r m)
instance PersistQuery m => PersistQuery (ReaderT r m)
instance (Error e, PersistQuery m) => PersistQuery (ErrorT e m)
instance PersistQuery m => PersistQuery (MaybeT m)
instance PersistQuery m => PersistQuery (ListT m)
instance PersistQuery m => PersistQuery (IdentityT m)
instance PersistQuery m => PersistQuery (LoggingT m)
instance Exception UpdateGetException
instance Show UpdateGetException

module Database.Persist.Query.GenericSql
class PersistStore m => PersistQuery m where updateGet key ups = do { update key ups; get key >>= maybe (liftIO $ throwIO $ KeyNotFound $ show key) return } selectFirst filts opts = selectSource filts ((LimitTo 1) : opts) $$ head
update :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => Key val -> [Update val] -> m ()
updateGet :: (PersistQuery m, PersistEntity val, PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> [Update val] -> m val
updateWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [Update val] -> m ()
deleteWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m ()
selectSource :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Entity val)
selectFirst :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m (Maybe (Entity val))
selectKeys :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Key val)
count :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m Int
newtype SqlPersist m a
SqlPersist :: ReaderT Connection m a -> SqlPersist m a
unSqlPersist :: SqlPersist m a -> ReaderT Connection m a
filterClauseNoWhere :: PersistEntity val => Bool -> Connection -> [Filter val] -> Text
filterClauseNoWhereOrNull :: PersistEntity val => Bool -> Connection -> [Filter val] -> Text
getFiltsValues :: PersistEntity val => Connection -> [Filter val] -> [PersistValue]

-- | Equivalent to <a>selectSource</a>, but instead of getting the
--   connection from the environment inside a <a>SqlPersist</a> monad,
--   provide an explicit <a>Connection</a>. This can allow you to use the
--   returned <a>Source</a> in an arbitrary monad.
selectSourceConn :: (PersistEntity val, MonadResource m, MonadLogger m, PersistEntityBackend val ~ SqlBackend, MonadBaseControl IO m) => Connection -> [Filter val] -> [SelectOpt val] -> Source m (Entity val)
dummyFromFilts :: [Filter v] -> v
orderClause :: PersistEntity val => Bool -> Connection -> SelectOpt val -> Text

-- | Same as <a>deleteWhere</a>, but returns the number of rows affected.
--   
--   Since 1.1.5
deleteWhereCount :: (PersistEntity val, MonadIO m, MonadLogger m) => [Filter val] -> SqlPersist m Int64

-- | Same as <a>updateWhere</a>, but returns the number of rows affected.
--   
--   Since 1.1.5
updateWhereCount :: (PersistEntity val, MonadIO m, MonadLogger m) => [Filter val] -> [Update val] -> SqlPersist m Int64
instance (MonadResource m, MonadLogger m) => PersistQuery (SqlPersist m)

module Database.Persist.Query
class PersistStore m => PersistQuery m where updateGet key ups = do { update key ups; get key >>= maybe (liftIO $ throwIO $ KeyNotFound $ show key) return } selectFirst filts opts = selectSource filts ((LimitTo 1) : opts) $$ head
update :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => Key val -> [Update val] -> m ()
updateGet :: (PersistQuery m, PersistEntity val, PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> [Update val] -> m val
updateWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [Update val] -> m ()
deleteWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m ()
selectSource :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Entity val)
selectFirst :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m (Maybe (Entity val))
selectKeys :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Key val)
count :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m Int

-- | Call <a>selectSource</a> but return the result as a list.
selectList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Entity val]

-- | Call <a>selectKeys</a> but return the result as a list.
selectKeysList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Key val]
deleteCascadeWhere :: (DeleteCascade a m, PersistQuery m) => [Filter a] -> m ()
data SelectOpt v
Asc :: (EntityField v typ) -> SelectOpt v
Desc :: (EntityField v typ) -> SelectOpt v
OffsetBy :: Int -> SelectOpt v
LimitTo :: Int -> SelectOpt v

-- | Filters which are available for <tt>select</tt>, <a>updateWhere</a>
--   and <a>deleteWhere</a>. Each filter constructor specifies the field
--   being filtered on, the type of comparison applied (equals, not equals,
--   etc) and the argument for the comparison.
data Filter v
Filter :: EntityField v typ -> Either typ [typ] -> PersistFilter -> Filter v
filterField :: Filter v -> EntityField v typ
filterValue :: Filter v -> Either typ [typ]
filterFilter :: Filter v -> PersistFilter

-- | convenient for internal use, not needed for the API
FilterAnd :: [Filter v] -> Filter v
FilterOr :: [Filter v] -> Filter v
BackendFilter :: (BackendSpecificFilter (PersistEntityBackend v) v) -> Filter v

-- | assign a field a value
(=.) :: PersistField typ => EntityField v typ -> typ -> Update v

-- | assign a field by addition (+=)
(+=.) :: PersistField typ => EntityField v typ -> typ -> Update v

-- | assign a field by subtraction (-=)
(-=.) :: PersistField typ => EntityField v typ -> typ -> Update v

-- | assign a field by multiplication (*=)
(*=.) :: PersistField typ => EntityField v typ -> typ -> Update v

-- | assign a field by division (/=)
(/=.) :: PersistField typ => EntityField v typ -> typ -> Update v
(==.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(!=.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(<.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(>.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(<=.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(>=.) :: PersistField typ => EntityField v typ -> typ -> Filter v

-- | In
(<-.) :: PersistField typ => EntityField v typ -> [typ] -> Filter v

-- | NotIn
(/<-.) :: PersistField typ => EntityField v typ -> [typ] -> Filter v

-- | the OR of two lists of filters
(||.) :: [Filter v] -> [Filter v] -> [Filter v]

module Database.Persist.Query.Join
class PersistQuery m => RunJoin a m where type family Result a
runJoin :: RunJoin a m => a -> m (Result a)
data SelectOneMany one many
SelectOneMany :: [Filter one] -> [SelectOpt one] -> [Filter many] -> [SelectOpt many] -> ([Key one] -> Filter many) -> (many -> Key one) -> Bool -> SelectOneMany one many
somFilterOne :: SelectOneMany one many -> [Filter one]
somOrderOne :: SelectOneMany one many -> [SelectOpt one]
somFilterMany :: SelectOneMany one many -> [Filter many]
somOrderMany :: SelectOneMany one many -> [SelectOpt many]
somFilterKeys :: SelectOneMany one many -> [Key one] -> Filter many
somGetKey :: SelectOneMany one many -> many -> Key one
somIncludeNoMatch :: SelectOneMany one many -> Bool
selectOneMany :: ([Key one] -> Filter many) -> (many -> Key one) -> SelectOneMany one many
instance (PersistEntity one, PersistEntity many, Ord (Key one), PersistQuery monad, PersistMonadBackend monad ~ PersistEntityBackend one, PersistEntityBackend one ~ PersistEntityBackend many) => RunJoin (SelectOneMany one many) monad

module Database.Persist.Query.Join.Sql
class RunJoin a
runJoin :: (RunJoin a, MonadResource m, MonadLogger m, MonadSqlPersist m) => a -> m (Result a)
instance (PersistEntity one, PersistEntity many, Eq (Key one)) => RunJoin (SelectOneMany one many)

module Database.Persist

-- | A value which can be marshalled to and from a <a>PersistValue</a>.
class PersistField a where isNullable _ = False
toPersistValue :: PersistField a => a -> PersistValue
fromPersistValue :: PersistField a => PersistValue -> Either Text a
sqlType :: PersistField a => a -> SqlType
isNullable :: PersistField a => a -> Bool

-- | A single database entity. For example, if writing a blog application,
--   a blog entry would be an entry, containing fields such as title and
--   content.
class PersistEntity val where data family EntityField val :: * -> * type family PersistEntityBackend val data family Unique val
persistFieldDef :: PersistEntity val => EntityField val typ -> FieldDef
entityDef :: PersistEntity val => val -> EntityDef
toPersistFields :: PersistEntity val => val -> [SomePersistField]
fromPersistValues :: PersistEntity val => [PersistValue] -> Either Text val
halfDefined :: PersistEntity val => val
persistUniqueToFieldNames :: PersistEntity val => Unique val -> [(HaskellName, DBName)]
persistUniqueToValues :: PersistEntity val => Unique val -> [PersistValue]
persistUniqueKeys :: PersistEntity val => val -> [Unique val]
persistIdField :: PersistEntity val => EntityField val (Key val)
fieldLens :: PersistEntity val => EntityField val field -> (forall f. Functor f => (field -> f field) -> Entity val -> f (Entity val))
class MonadIO m => PersistStore m where type family PersistMonadBackend m insert_ val = insert val >> return ()
insert :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => val -> m (Key val)
insert_ :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => val -> m ()
insertKey :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m ()
repsert :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m ()
replace :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> val -> m ()
delete :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> m ()
get :: (PersistStore m, PersistMonadBackend m ~ PersistEntityBackend val, PersistEntity val) => Key val -> m (Maybe val)

-- | Queries against unique keys (other than the id).
--   
--   Please read the general Persistent documentation to learn how to
--   create Unique keys. SQL backends automatically create uniqueness
--   constraints, but for MongoDB you must place a unique index on the
--   field.
class PersistStore m => PersistUnique m where insertUnique datum = do { isUnique <- checkUnique datum; if isUnique then Just `liftM` insert datum else return Nothing }
getBy :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => Unique val -> m (Maybe (Entity val))
deleteBy :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => Unique val -> m ()
insertUnique :: (PersistUnique m, PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val) => val -> m (Maybe (Key val))
class PersistStore m => PersistQuery m where updateGet key ups = do { update key ups; get key >>= maybe (liftIO $ throwIO $ KeyNotFound $ show key) return } selectFirst filts opts = selectSource filts ((LimitTo 1) : opts) $$ head
update :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => Key val -> [Update val] -> m ()
updateGet :: (PersistQuery m, PersistEntity val, PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> [Update val] -> m val
updateWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [Update val] -> m ()
deleteWhere :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m ()
selectSource :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Entity val)
selectFirst :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m (Maybe (Entity val))
selectKeys :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> Source m (Key val)
count :: (PersistQuery m, PersistEntity val, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> m Int
newtype KeyBackend backend entity
Key :: PersistValue -> KeyBackend backend entity
unKey :: KeyBackend backend entity -> PersistValue

-- | Helper wrapper, equivalent to <tt>Key (PersistEntityBackend val)
--   val</tt>.
--   
--   Since 1.1.0
type Key val = KeyBackend (PersistEntityBackend val) val

-- | Datatype that represents an entity, with both its key and its Haskell
--   representation.
--   
--   When using the an SQL-based backend (such as SQLite or PostgreSQL), an
--   <a>Entity</a> may take any number of columns depending on how many
--   fields it has. In order to reconstruct your entity on the Haskell
--   side, <tt>persistent</tt> needs all of your entity columns and in the
--   right order. Note that you don't need to worry about this when using
--   <tt>persistent</tt>'s API since everything is handled correctly behind
--   the scenes.
--   
--   However, if you want to issue a raw SQL command that returns an
--   <a>Entity</a>, then you have to be careful with the column order.
--   While you could use <tt>SELECT Entity.* WHERE ...</tt> and that would
--   work most of the time, there are times when the order of the columns
--   on your database is different from the order that <tt>persistent</tt>
--   expects (for example, if you add a new field in the middle of you
--   entity definition and then use the migration code --
--   <tt>persistent</tt> will expect the column to be in the middle, but
--   your DBMS will put it as the last column). So, instead of using a
--   query like the one above, you may use <a>rawSql</a> (from the
--   <a>Database.Persist.GenericSql</a> module) with its /entity selection
--   placeholder/ (a double question mark <tt>??</tt>). Using
--   <tt>rawSql</tt> the query above must be written as <tt>SELECT ?? WHERE
--   ..</tt>. Then <tt>rawSql</tt> will replace <tt>??</tt> with the list
--   of all columns that we need from your entity in the right order. If
--   your query returns two entities (i.e. <tt>(Entity backend a, Entity
--   backend b)</tt>), then you must you use <tt>SELECT ??, ?? WHERE
--   ...</tt>, and so on.
data Entity entity
Entity :: Key entity -> entity -> Entity entity
entityKey :: Entity entity -> Key entity
entityVal :: Entity entity -> entity

-- | Insert a value, checking for conflicts with any unique constraints. If
--   a duplicate exists in the database, it is returned as <a>Left</a>.
--   Otherwise, the new 'Key is returned as <a>Right</a>.
insertBy :: (PersistEntity v, PersistStore m, PersistUnique m, PersistMonadBackend m ~ PersistEntityBackend v) => v -> m (Either (Entity v) (Key v))

-- | Same as get, but for a non-null (not Maybe) foreign key Unsafe unless
--   your database is enforcing that the foreign key is valid
getJust :: (PersistStore m, PersistEntity val, Show (Key val), PersistMonadBackend m ~ PersistEntityBackend val) => Key val -> m val
belongsTo :: (PersistStore m, PersistEntity ent1, PersistEntity ent2, PersistMonadBackend m ~ PersistEntityBackend ent2) => (ent1 -> Maybe (Key ent2)) -> ent1 -> m (Maybe ent2)

-- | same as belongsTo, but uses <tt>getJust</tt> and therefore is
--   similarly unsafe
belongsToJust :: (PersistStore m, PersistEntity ent1, PersistEntity ent2, PersistMonadBackend m ~ PersistEntityBackend ent2) => (ent1 -> Key ent2) -> ent1 -> m ent2

-- | A modification of <a>getBy</a>, which takes the <a>PersistEntity</a>
--   itself instead of a <a>Unique</a> value. Returns a value matching
--   <i>one</i> of the unique keys. This function makes the most sense on
--   entities with a single <a>Unique</a> constructor.
getByValue :: (PersistEntity v, PersistUnique m, PersistEntityBackend v ~ PersistMonadBackend m) => v -> m (Maybe (Entity v))

-- | Check whether there are any conflicts for unique keys with this entity
--   and existing entities in the database.
--   
--   Returns <a>True</a> if the entity would be unique, and could thus
--   safely be <a>insert</a>ed; returns <a>False</a> on a conflict.
checkUnique :: (PersistEntityBackend val ~ PersistMonadBackend m, PersistEntity val, PersistUnique m) => val -> m Bool

-- | Call <a>selectSource</a> but return the result as a list.
selectList :: (PersistEntity val, PersistQuery m, PersistEntityBackend val ~ PersistMonadBackend m) => [Filter val] -> [SelectOpt val] -> m [Entity val]
deleteCascadeWhere :: (DeleteCascade a m, PersistQuery m) => [Filter a] -> m ()
data SelectOpt v
Asc :: (EntityField v typ) -> SelectOpt v
Desc :: (EntityField v typ) -> SelectOpt v
OffsetBy :: Int -> SelectOpt v
LimitTo :: Int -> SelectOpt v

-- | Filters which are available for <tt>select</tt>, <a>updateWhere</a>
--   and <a>deleteWhere</a>. Each filter constructor specifies the field
--   being filtered on, the type of comparison applied (equals, not equals,
--   etc) and the argument for the comparison.
data Filter v
Filter :: EntityField v typ -> Either typ [typ] -> PersistFilter -> Filter v
filterField :: Filter v -> EntityField v typ
filterValue :: Filter v -> Either typ [typ]
filterFilter :: Filter v -> PersistFilter

-- | convenient for internal use, not needed for the API
FilterAnd :: [Filter v] -> Filter v
FilterOr :: [Filter v] -> Filter v
BackendFilter :: (BackendSpecificFilter (PersistEntityBackend v) v) -> Filter v

-- | assign a field a value
(=.) :: PersistField typ => EntityField v typ -> typ -> Update v

-- | assign a field by addition (+=)
(+=.) :: PersistField typ => EntityField v typ -> typ -> Update v

-- | assign a field by subtraction (-=)
(-=.) :: PersistField typ => EntityField v typ -> typ -> Update v

-- | assign a field by multiplication (*=)
(*=.) :: PersistField typ => EntityField v typ -> typ -> Update v

-- | assign a field by division (/=)
(/=.) :: PersistField typ => EntityField v typ -> typ -> Update v
(==.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(!=.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(<.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(>.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(<=.) :: PersistField typ => EntityField v typ -> typ -> Filter v
(>=.) :: PersistField typ => EntityField v typ -> typ -> Filter v

-- | In
(<-.) :: PersistField typ => EntityField v typ -> [typ] -> Filter v

-- | NotIn
(/<-.) :: PersistField typ => EntityField v typ -> [typ] -> Filter v

-- | the OR of two lists of filters
(||.) :: [Filter v] -> [Filter v] -> [Filter v]
