-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Type-safe, non-relational, multi-backend persistence. -- @package persistent-template @version 2.1.3 -- | This module provides utilities for creating backends. Regular users do -- not need to use this module. module Database.Persist.TH -- | Converts a quasi-quoted syntax into a list of entity definitions, to -- be used as input to the template haskell generation code (mkPersist). persistWith :: PersistSettings -> QuasiQuoter -- | Apply persistWith to upperCaseSettings. persistUpperCase :: QuasiQuoter -- | Apply persistWith to lowerCaseSettings. persistLowerCase :: QuasiQuoter -- | Same as persistWith, but uses an external file instead of a -- quasiquotation. persistFileWith :: PersistSettings -> FilePath -> Q Exp -- | Create data types and appropriate PersistEntity instances for -- the given EntityDefs. Works well with the persist quasi-quoter. mkPersist :: MkPersistSettings -> [EntityDef] -> Q [Dec] -- | Settings to be passed to the mkPersist function. data MkPersistSettings -- | Which database backend we're using. -- -- When generating data types, each type is given a generic version- -- which works with any backend- and a type synonym for the commonly used -- backend. This is where you specify that commonly used backend. mpsBackend :: MkPersistSettings -> Type -- | Create generic types that can be used with multiple backends. Good for -- reusable code, but makes error messages harder to understand. Default: -- True. mpsGeneric :: MkPersistSettings -> Bool -- | Prefix field names with the model name. Default: True. mpsPrefixFields :: MkPersistSettings -> Bool -- | Generate ToJSON/FromJSON instances for each model -- types. If it's Nothing, no instances will be generated. -- Default: -- --
-- Just EntityJSON
-- { entityToJSON = 'keyValueEntityToJSON
-- , entityFromJSON = 'keyValueEntityFromJSON
-- }
--
mpsEntityJSON :: MkPersistSettings -> Maybe EntityJSON
-- | Instead of generating normal field accessors, generator lens-style
-- accessors.
--
-- Default: False
--
-- Since 1.3.1
mpsGenerateLenses :: MkPersistSettings -> Bool
data EntityJSON
EntityJSON :: Name -> Name -> EntityJSON
-- | Name of the toJSON implementation for Entity a.
entityToJSON :: EntityJSON -> Name
-- | Name of the fromJSON implementation for Entity a.
entityFromJSON :: EntityJSON -> Name
-- | Create an MkPersistSettings with default values.
mkPersistSettings :: Type -> MkPersistSettings
-- | Use the SqlPersist backend.
sqlSettings :: MkPersistSettings
-- | Same as sqlSettings.
--
-- Since 1.1.1
-- | Deprecated: use sqlSettings
sqlOnlySettings :: MkPersistSettings
-- | Creates a single function to perform all migrations for the entities
-- defined here. One thing to be aware of is dependencies: if you have
-- entities with foreign references, make sure to place those definitions
-- after the entities they reference.
mkMigrate :: String -> [EntityDef] -> Q [Dec]
-- | Save the EntityDefs passed in under the given name.
mkSave :: String -> [EntityDef] -> Q [Dec]
-- | Generate a DeleteCascade instance for the given
-- EntityDefs.
mkDeleteCascade :: MkPersistSettings -> [EntityDef] -> Q [Dec]
-- | Apply the given list of functions to the same EntityDefs.
--
-- This function is useful for cases such as:
--
-- -- >>> share [mkSave "myDefs", mkPersist sqlSettings] [persistLowerCase|...|] --share :: [[EntityDef] -> Q [Dec]] -> [EntityDef] -> Q [Dec] -- | Automatically creates a valid PersistField instance for any -- datatype that has valid Show and Read instances. Can be -- very convenient for Enum types. derivePersistField :: String -> Q [Dec] -- | Automatically creates a valid PersistField instance for any -- datatype that has valid ToJSON and FromJSON instances. -- For a datatype T it generates instances similar to these: -- --
-- instance PersistField T where -- toPersistValue = PersistByteString . L.toStrict . encode -- fromPersistValue = (left T.pack) . eitherDecodeStrict' <=< fromPersistValue -- instance PersistFieldSql T where -- sqlType _ = SqlString --derivePersistFieldJSON :: String -> Q [Dec] -- | produce code similar to the following: -- --
-- instance PersistEntity e => PersistField e where -- toPersistValue = PersistMap $ zip columNames (map toPersistValue . toPersistFields) -- fromPersistValue (PersistMap o) = -- let columns = HM.fromList o -- in fromPersistValues $ map (name -> -- case HM.lookup name columns of -- Just v -> v -- Nothing -> PersistNull -- fromPersistValue x = Left $ "Expected PersistMap, received: " ++ show x -- sqlType _ = SqlString --persistFieldFromEntity :: MkPersistSettings -> EntityDef -> Q [Dec] packPTH :: String -> Text lensPTH :: (s -> a) -> (s -> b -> t) -> Lens s t a b instance [overlap ok] Show SqlTypeExp instance [overlap ok] Show EntityDefSqlTypeExp instance [overlap ok] Lift SqlType instance [overlap ok] Lift PersistUpdate instance [overlap ok] Lift PersistFilter instance [overlap ok] Lift FieldType instance [overlap ok] Lift DBName instance [overlap ok] Lift HaskellName instance [overlap ok] Lift' a => Lift a instance [overlap ok] (Lift' k, Lift' v) => Lift' (Map k v) instance [overlap ok] Lift' a => Lift' [a] instance [overlap ok] Lift' Text instance [overlap ok] Lift ForeignDef instance [overlap ok] Lift CompositeDef instance [overlap ok] Lift UniqueDef instance [overlap ok] Lift FieldDef instance [overlap ok] Lift EntityDef instance [overlap ok] Lift EmbedFieldDef instance [overlap ok] Lift EmbedEntityDef instance [overlap ok] Lift ReferenceDef instance [overlap ok] Lift EntityDefSqlTypeExp instance [overlap ok] Lift FieldSqlTypeExp instance [overlap ok] Lift FieldsSqlTypeExp instance [overlap ok] Lift SqlTypeExp