-- 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-template
@version 1.2.0.4


-- | 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 <a>persistWith</a> to <a>upperCaseSettings</a>.
persistUpperCase :: QuasiQuoter

-- | Apply <a>persistWith</a> to <a>lowerCaseSettings</a>.
persistLowerCase :: QuasiQuoter

-- | Same as <a>persistWith</a>, but uses an external file instead of a
--   quasiquotation.
persistFileWith :: PersistSettings -> FilePath -> Q Exp

-- | Create data types and appropriate <a>PersistEntity</a> instances for
--   the given <a>EntityDef</a>s. Works well with the persist quasi-quoter.
mkPersist :: MkPersistSettings -> [EntityDef SqlType] -> Q [Dec]

-- | Settings to be passed to the <a>mkPersist</a> 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

-- | Create an <tt>MkPersistSettings</tt> with default values.
mkPersistSettings :: Type -> MkPersistSettings

-- | Use the <tt>SqlPersist</tt> backend.
sqlSettings :: MkPersistSettings

-- | Same as <a>sqlSettings</a>, but set <a>mpsGeneric</a> to
--   <tt>False</tt>.
--   
--   Since 1.1.1
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 :: Lift' a => String -> [EntityDef a] -> Q [Dec]

-- | Save the <tt>EntityDef</tt>s passed in under the given name.
mkSave :: String -> [EntityDef SqlType] -> Q [Dec]

-- | Generate a <a>DeleteCascade</a> instance for the given
--   <tt>EntityDef</tt>s.
mkDeleteCascade :: MkPersistSettings -> [EntityDef a] -> Q [Dec]

-- | Apply the given list of functions to the same <tt>EntityDef</tt>s.
--   
--   This function is useful for cases such as:
--   
--   <pre>
--   &gt;&gt;&gt; share [mkSave "myDefs", mkPersist sqlSettings] [persistLowerCase|...|]
--   </pre>
share :: [[EntityDef a] -> Q [Dec]] -> [EntityDef a] -> Q [Dec]

-- | Automatically creates a valid <a>PersistField</a> instance for any
--   datatype that has valid <a>Show</a> and <a>Read</a> instances. Can be
--   very convenient for <a>Enum</a> types.
derivePersistField :: String -> Q [Dec]

-- | produce code similar to the following:
--   
--   instance PersistEntity e =&gt; PersistField e where toPersistValue =
--   PersistMap $ zip columNames (map toPersistValue . toPersistFields)
--   fromPersistValue (PersistMap o) = fromPersistValues $ map ((_,v) -&gt;
--   casefromPersistValue v of Left e -&gt; error e Right r -&gt; r) o
--   fromPersistValue x = Left $ <a>Expected PersistMap, received: </a> ++
--   show x sqlType _ = SqlString
persistFieldFromEntity :: MkPersistSettings -> EntityDef a -> Q [Dec]
instance Lift SqlType
instance Lift PersistUpdate
instance Lift PersistFilter
instance Lift FieldType
instance Lift DBName
instance Lift HaskellName
instance Lift' SqlTypeExp
instance Lift' ()
instance Lift' a => Lift' (EntityDef a)
instance Lift' a => Lift' (Maybe a)
instance Lift' SqlType
instance Lift UniqueDef
instance Lift' a => Lift (FieldDef a)
instance Lift' a => Lift (EntityDef a)
instance Lift SqlTypeExp
