/usr/share/doc/libghc-persistent-template-doc/html/Database-Persist-TH.html is in libghc-persistent-template-doc 2.1.4-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Database.Persist.TH</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Database-Persist-TH.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Database-Persist-TH.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">persistent-template-2.1.4: Type-safe, non-relational, multi-backend persistence.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Database.Persist.TH</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Parse entity defs</a></li><li><a href="#g:2">Turn <code>EntityDef</code>s into types</a></li><li><a href="#g:3">Various other TH functions</a></li><li><a href="#g:4">Internal</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module provides utilities for creating backends. Regular users do not
need to use this module.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:persistWith">persistWith</a> :: <a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Quasi.html#t:PersistSettings">PersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Quote.html#t:QuasiQuoter">QuasiQuoter</a></li><li class="src short"><a href="#v:persistUpperCase">persistUpperCase</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Quote.html#t:QuasiQuoter">QuasiQuoter</a></li><li class="src short"><a href="#v:persistLowerCase">persistLowerCase</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Quote.html#t:QuasiQuoter">QuasiQuoter</a></li><li class="src short"><a href="#v:persistFileWith">persistFileWith</a> :: <a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Quasi.html#t:PersistSettings">PersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a></li><li class="src short"><a href="#v:mkPersist">mkPersist</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><span class="keyword">data</span> <a href="#t:MkPersistSettings">MkPersistSettings</a></li><li class="src short"><a href="#v:mpsBackend">mpsBackend</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Type">Type</a></li><li class="src short"><a href="#v:mpsGeneric">mpsGeneric</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:mpsPrefixFields">mpsPrefixFields</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:mpsEntityJSON">mpsEntityJSON</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Database-Persist-TH.html#t:EntityJSON">EntityJSON</a></li><li class="src short"><a href="#v:mpsGenerateLenses">mpsGenerateLenses</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:EntityJSON">EntityJSON</a> = <a href="#v:EntityJSON">EntityJSON</a> {<ul class="subs"><li><a href="#v:entityToJSON">entityToJSON</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></li><li><a href="#v:entityFromJSON">entityFromJSON</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></li></ul>}</li><li class="src short"><a href="#v:mkPersistSettings">mkPersistSettings</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Type">Type</a> -> <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a></li><li class="src short"><a href="#v:sqlSettings">sqlSettings</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a></li><li class="src short"><a href="#v:sqlOnlySettings">sqlOnlySettings</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a></li><li class="src short"><a href="#v:mkMigrate">mkMigrate</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:mkSave">mkSave</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:mkDeleteCascade">mkDeleteCascade</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:share">share</a> :: [[<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]] -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:derivePersistField">derivePersistField</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:derivePersistFieldJSON">derivePersistFieldJSON</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:persistFieldFromEntity">persistFieldFromEntity</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]</li><li class="src short"><a href="#v:packPTH">packPTH</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></li><li class="src short"><a href="#v:lensPTH">lensPTH</a> :: (s -> a) -> (s -> b -> t) -> Lens s t a b</li></ul></div><div id="interface"><h1 id="g:1">Parse entity defs</h1><div class="top"><p class="src"><a name="v:persistWith" class="def">persistWith</a> :: <a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Quasi.html#t:PersistSettings">PersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Quote.html#t:QuasiQuoter">QuasiQuoter</a> <a href="src/Database-Persist-TH.html#persistWith" class="link">Source</a></p><div class="doc"><p>Converts a quasi-quoted syntax into a list of entity definitions, to be
used as input to the template haskell generation code (mkPersist).</p></div></div><div class="top"><p class="src"><a name="v:persistUpperCase" class="def">persistUpperCase</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Quote.html#t:QuasiQuoter">QuasiQuoter</a> <a href="src/Database-Persist-TH.html#persistUpperCase" class="link">Source</a></p><div class="doc"><p>Apply <code><a href="Database-Persist-TH.html#v:persistWith">persistWith</a></code> to <code><a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Quasi.html#v:upperCaseSettings">upperCaseSettings</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:persistLowerCase" class="def">persistLowerCase</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Quote.html#t:QuasiQuoter">QuasiQuoter</a> <a href="src/Database-Persist-TH.html#persistLowerCase" class="link">Source</a></p><div class="doc"><p>Apply <code><a href="Database-Persist-TH.html#v:persistWith">persistWith</a></code> to <code><a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Quasi.html#v:lowerCaseSettings">lowerCaseSettings</a></code>.</p></div></div><div class="top"><p class="src"><a name="v:persistFileWith" class="def">persistFileWith</a> :: <a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Quasi.html#t:PersistSettings">PersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a> <a href="src/Database-Persist-TH.html#persistFileWith" class="link">Source</a></p><div class="doc"><p>Same as <code><a href="Database-Persist-TH.html#v:persistWith">persistWith</a></code>, but uses an external file instead of a
quasiquotation.</p></div></div><h1 id="g:2">Turn <code>EntityDef</code>s into types</h1><div class="top"><p class="src"><a name="v:mkPersist" class="def">mkPersist</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>] <a href="src/Database-Persist-TH.html#mkPersist" class="link">Source</a></p><div class="doc"><p>Create data types and appropriate <code><a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Class.html#t:PersistEntity">PersistEntity</a></code> instances for the given
<code><a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a></code>s. Works well with the persist quasi-quoter.</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:MkPersistSettings" class="def">MkPersistSettings</a> <a href="src/Database-Persist-TH.html#MkPersistSettings" class="link">Source</a></p><div class="doc"><p>Settings to be passed to the <code><a href="Database-Persist-TH.html#v:mkPersist">mkPersist</a></code> function.</p></div></div><div class="top"><p class="src"><a name="v:mpsBackend" class="def">mpsBackend</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Type">Type</a> <a href="src/Database-Persist-TH.html#mpsBackend" class="link">Source</a></p><div class="doc"><p>Which database backend we're using.</p><p>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.</p></div></div><div class="top"><p class="src"><a name="v:mpsGeneric" class="def">mpsGeneric</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Database-Persist-TH.html#mpsGeneric" class="link">Source</a></p><div class="doc"><p>Create generic types that can be used with multiple backends. Good for
reusable code, but makes error messages harder to understand. Default:
True.</p></div></div><div class="top"><p class="src"><a name="v:mpsPrefixFields" class="def">mpsPrefixFields</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Database-Persist-TH.html#mpsPrefixFields" class="link">Source</a></p><div class="doc"><p>Prefix field names with the model name. Default: True.</p></div></div><div class="top"><p class="src"><a name="v:mpsEntityJSON" class="def">mpsEntityJSON</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="Database-Persist-TH.html#t:EntityJSON">EntityJSON</a> <a href="src/Database-Persist-TH.html#mpsEntityJSON" class="link">Source</a></p><div class="doc"><p>Generate <code>ToJSON</code>/<code>FromJSON</code> instances for each model types. If it's
<code>Nothing</code>, no instances will be generated. Default:</p><pre> Just EntityJSON
{ entityToJSON = 'keyValueEntityToJSON
, entityFromJSON = 'keyValueEntityFromJSON
}
</pre></div></div><div class="top"><p class="src"><a name="v:mpsGenerateLenses" class="def">mpsGenerateLenses</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Database-Persist-TH.html#mpsGenerateLenses" class="link">Source</a></p><div class="doc"><p>Instead of generating normal field accessors, generator lens-style accessors.</p><p>Default: False</p><p>Since 1.3.1</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:EntityJSON" class="def">EntityJSON</a> <a href="src/Database-Persist-TH.html#EntityJSON" class="link">Source</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:EntityJSON" class="def">EntityJSON</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:entityToJSON" class="def">entityToJSON</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></dt><dd class="doc"><p>Name of the <code>toJSON</code> implementation for <code>Entity a</code>.</p></dd><dt class="src"><a name="v:entityFromJSON" class="def">entityFromJSON</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Name">Name</a></dt><dd class="doc"><p>Name of the <code>fromJSON</code> implementation for <code>Entity a</code>.</p></dd></dl><div class="clear"></div></div></td></tr></table></div></div><div class="top"><p class="src"><a name="v:mkPersistSettings" class="def">mkPersistSettings</a> <a href="src/Database-Persist-TH.html#mkPersistSettings" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Type">Type</a></td><td class="doc"><p>Value for <code><a href="Database-Persist-TH.html#v:mpsBackend">mpsBackend</a></code></p></td></tr><tr><td class="src">-> <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Create an <code>MkPersistSettings</code> with default values.</p></div></div><div class="top"><p class="src"><a name="v:sqlSettings" class="def">sqlSettings</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> <a href="src/Database-Persist-TH.html#sqlSettings" class="link">Source</a></p><div class="doc"><p>Use the <code>SqlPersist</code> backend.</p></div></div><div class="top"><p class="src"><a name="v:sqlOnlySettings" class="def">sqlOnlySettings</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> <a href="src/Database-Persist-TH.html#sqlOnlySettings" class="link">Source</a></p><div class="doc"><div class="warning"><p>Deprecated: use sqlSettings</p></div><p>Same as <code><a href="Database-Persist-TH.html#v:sqlSettings">sqlSettings</a></code>.</p><p>Since 1.1.1</p></div></div><h1 id="g:3">Various other TH functions</h1><div class="top"><p class="src"><a name="v:mkMigrate" class="def">mkMigrate</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>] <a href="src/Database-Persist-TH.html#mkMigrate" class="link">Source</a></p><div class="doc"><p>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.</p></div></div><div class="top"><p class="src"><a name="v:mkSave" class="def">mkSave</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>] <a href="src/Database-Persist-TH.html#mkSave" class="link">Source</a></p><div class="doc"><p>Save the <code>EntityDef</code>s passed in under the given name.</p></div></div><div class="top"><p class="src"><a name="v:mkDeleteCascade" class="def">mkDeleteCascade</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>] <a href="src/Database-Persist-TH.html#mkDeleteCascade" class="link">Source</a></p><div class="doc"><p>Generate a <code><a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Class.html#t:DeleteCascade">DeleteCascade</a></code> instance for the given <code>EntityDef</code>s.</p></div></div><div class="top"><p class="src"><a name="v:share" class="def">share</a> :: [[<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>]] -> [<a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>] <a href="src/Database-Persist-TH.html#share" class="link">Source</a></p><div class="doc"><p>Apply the given list of functions to the same <code>EntityDef</code>s.</p><p>This function is useful for cases such as:</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>share [mkSave "myDefs", mkPersist sqlSettings] [persistLowerCase|...|]
</code></strong></pre></div></div><div class="top"><p class="src"><a name="v:derivePersistField" class="def">derivePersistField</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>] <a href="src/Database-Persist-TH.html#derivePersistField" class="link">Source</a></p><div class="doc"><p>Automatically creates a valid <code><a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Class.html#t:PersistField">PersistField</a></code> instance for any datatype
that has valid <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Show.html#t:Show">Show</a></code> and <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Text-Read.html#t:Read">Read</a></code> instances. Can be very convenient for
<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Prelude.html#t:Enum">Enum</a></code> types.</p></div></div><div class="top"><p class="src"><a name="v:derivePersistFieldJSON" class="def">derivePersistFieldJSON</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>] <a href="src/Database-Persist-TH.html#derivePersistFieldJSON" class="link">Source</a></p><div class="doc"><p>Automatically creates a valid <code><a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Class.html#t:PersistField">PersistField</a></code> instance for any datatype
that has valid <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:ToJSON">ToJSON</a></code> and <code><a href="file:///usr/share/doc/libghc-aeson-doc/html/Data-Aeson-Types.html#t:FromJSON">FromJSON</a></code> instances. For a datatype <code>T</code> it
generates instances similar to these:</p><pre> instance PersistField T where
toPersistValue = PersistByteString . L.toStrict . encode
fromPersistValue = (left T.pack) . eitherDecodeStrict' <=< fromPersistValue
instance PersistFieldSql T where
sqlType _ = SqlString
</pre></div></div><div class="top"><p class="src"><a name="v:persistFieldFromEntity" class="def">persistFieldFromEntity</a> :: <a href="Database-Persist-TH.html#t:MkPersistSettings">MkPersistSettings</a> -> <a href="file:///usr/share/doc/libghc-persistent-doc/html/Database-Persist-Types.html#t:EntityDef">EntityDef</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/template-haskell-2.10.0.0/Language-Haskell-TH-Syntax.html#t:Dec">Dec</a>] <a href="src/Database-Persist-TH.html#persistFieldFromEntity" class="link">Source</a></p><div class="doc"><p>produce code similar to the following:</p><pre> 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
</pre></div></div><h1 id="g:4">Internal</h1><div class="top"><p class="src"><a name="v:packPTH" class="def">packPTH</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> <a href="src/Database-Persist-TH.html#packPTH" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:lensPTH" class="def">lensPTH</a> :: (s -> a) -> (s -> b -> t) -> Lens s t a b <a href="src/Database-Persist-TH.html#lensPTH" class="link">Source</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>
|