-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Type-safe, non-relational, multi-backend persistence.
--
-- This library provides just the general interface and helper functions.
-- You must use a specific backend in order to make this useful.
@package persistent
@version 0.0.0.1
-- | This defines the API for performing database actions. There are two
-- levels to this API: dealing with fields, and dealing with entities. In
-- SQL, a field corresponds to a column, and should be a single,
-- non-composite value. An entity corresponds to a SQL table. In other
-- words: An entity is a collection of fields.
module Database.Persist
-- | A raw value which can be stored in any backend and can be marshalled
-- to and from a PersistField.
data PersistValue
PersistString :: String -> PersistValue
PersistByteString :: ByteString -> PersistValue
PersistInt64 :: Int64 -> PersistValue
PersistDouble :: Double -> PersistValue
PersistBool :: Bool -> PersistValue
PersistDay :: Day -> PersistValue
PersistTimeOfDay :: TimeOfDay -> PersistValue
PersistUTCTime :: UTCTime -> PersistValue
PersistNull :: 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
SqlInteger :: SqlType
SqlReal :: SqlType
SqlBool :: SqlType
SqlDay :: SqlType
SqlTime :: SqlType
SqlDayTime :: SqlType
SqlBlob :: SqlType
-- | A value which can be marshalled to and from a PersistValue.
class PersistField a
toPersistValue :: (PersistField a) => a -> PersistValue
fromPersistValue :: (PersistField a) => PersistValue -> Either String 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 { type family PersistMonad val :: (* -> *) -> * -> *; data family Key val; data family Update val; data family Filter val; data family Order val; data family Unique val; }
initialize :: (PersistEntity val, MonadCatchIO m) => val -> (PersistMonad val) m ()
insert :: (PersistEntity val, MonadCatchIO m) => val -> (PersistMonad val) m (Key val)
replace :: (PersistEntity val, MonadCatchIO m) => Key val -> val -> (PersistMonad val) m ()
update :: (PersistEntity val, MonadCatchIO m) => Key val -> [Update val] -> (PersistMonad val) m ()
updateWhere :: (PersistEntity val, MonadCatchIO m) => [Filter val] -> [Update val] -> (PersistMonad val) m ()
delete :: (PersistEntity val, MonadCatchIO m) => Key val -> (PersistMonad val) m ()
deleteBy :: (PersistEntity val, MonadCatchIO m) => Unique val -> (PersistMonad val) m ()
deleteWhere :: (PersistEntity val, MonadCatchIO m) => [Filter val] -> (PersistMonad val) m ()
get :: (PersistEntity val, MonadCatchIO m) => Key val -> (PersistMonad val) m (Maybe val)
getBy :: (PersistEntity val, MonadCatchIO m) => Unique val -> (PersistMonad val) m (Maybe (Key val, val))
select :: (PersistEntity val, MonadCatchIO m) => [Filter val] -> [Order val] -> (PersistMonad val) m [(Key val, val)]
instance Typeable SqlType
instance Typeable PersistValue
instance Show SqlType
instance Read SqlType
instance Eq SqlType
instance Show PersistValue
instance Read PersistValue
instance Eq PersistValue
instance (PersistField a) => PersistField (Maybe a)
instance PersistField UTCTime
instance PersistField TimeOfDay
instance PersistField Day
instance PersistField Bool
instance PersistField Double
instance PersistField Int64
instance PersistField Int
instance PersistField (Html ())
instance PersistField Text
instance PersistField ByteString
instance PersistField String
-- | This module provides utilities for creating backends. Regular users do
-- not need to use this module.
module Database.Persist.Helper
recName :: String -> String -> String
upperFirst :: String -> String
data EntityDef
EntityDef :: String -> [(String, String, [String])] -> [(String, [String])] -> [String] -> EntityDef
entityName :: EntityDef -> String
-- | name, type, attribs
entityColumns :: EntityDef -> [(String, String, [String])]
-- | name, columns
entityUniques :: EntityDef -> [(String, [String])]
entityDerives :: EntityDef -> [String]
entityOrders :: EntityDef -> [(String, String)]
entityFilters :: EntityDef -> [(String, String, Bool, PersistFilter)]
entityUpdates :: EntityDef -> [(String, String, Bool)]
dataTypeDec :: EntityDef -> Dec
persistMonadTypeDec :: Type -> EntityDef -> Dec
keyTypeDec :: String -> String -> EntityDef -> Dec
filterTypeDec :: EntityDef -> Dec
updateTypeDec :: EntityDef -> Dec
orderTypeDec :: EntityDef -> Dec
uniqueTypeDec :: EntityDef -> Dec
mkToPersistFields :: Type -> [(String, Int)] -> Q Dec
mkToFieldNames :: Type -> [(String, [String])] -> Dec
mkToFieldName :: Type -> [(String, String)] -> Dec
mkPersistField :: Type -> [String] -> Dec
mkToFilter :: Type -> [(String, PersistFilter, Bool)] -> Dec
mkToOrder :: Type -> [(String, String)] -> Dec
mkHalfDefined :: Type -> String -> Int -> Dec
data SomePersistField
SomePersistField :: a -> SomePersistField
class ToPersistFields a
toPersistFields :: (ToPersistFields a) => a -> [SomePersistField]
class FromPersistValues a
fromPersistValues :: (FromPersistValues a) => [PersistValue] -> Either String a
toPersistValues :: (ToPersistFields a) => a -> [PersistValue]
class ToFieldNames a
toFieldNames :: (ToFieldNames a) => a -> [String]
class ToOrder a
toOrder :: (ToOrder a) => a -> PersistOrder
data PersistOrder
Asc :: PersistOrder
Desc :: PersistOrder
class ToFieldName a
toFieldName :: (ToFieldName a) => a -> String
data PersistFilter
Eq :: PersistFilter
Ne :: PersistFilter
Gt :: PersistFilter
Lt :: PersistFilter
Ge :: PersistFilter
Le :: PersistFilter
class ToFilter a
toFilter :: (ToFilter a) => a -> PersistFilter
isNull :: (ToFilter a) => a -> Bool
class HalfDefined a
halfDefined :: (HalfDefined a) => a
apE :: Either x (y -> z) -> Either x y -> Either x z
addIsNullable :: EntityDef -> (String, (String, String)) -> (String, (String, Bool))
instance Read PersistFilter
instance Show PersistFilter
instance Show EntityDef
instance PersistField SomePersistField
instance Lift EntityDef
module Database.Persist.Quasi
-- | Converts a quasi-quoted syntax into a list of entity definitions, to
-- be used as input to the backend-specific template haskell generation
-- code.
persist :: QuasiQuoter
-- | This is a helper module for creating SQL backends. Regular users do
-- not need to use this module.
module Database.Persist.GenericSql
-- | 64-bit signed integer type
data Int64 :: *
-- | Converts a quasi-quoted syntax into a list of entity definitions, to
-- be used as input to the backend-specific template haskell generation
-- code.
persist :: QuasiQuoter
deriveGenericSql :: Type -> Exp -> EntityDef -> Q [Dec]
type RowPopper m = m (Maybe [PersistValue])
data GenericSql m
GenericSql :: (forall a. String -> [PersistValue] -> (RowPopper m -> m a) -> m a) -> (String -> [PersistValue] -> m ()) -> (String -> [String] -> [PersistValue] -> m Int64) -> (String -> m Bool) -> String -> GenericSql m
gsWithStmt :: GenericSql m -> forall a. String -> [PersistValue] -> (RowPopper m -> m a) -> m a
gsExecute :: GenericSql m -> String -> [PersistValue] -> m ()
gsInsert :: GenericSql m -> String -> [String] -> [PersistValue] -> m Int64
gsEntityDefExists :: GenericSql m -> String -> m Bool
gsKeyType :: GenericSql m -> String