id package:hledger-web

Identity function.
id x = x
Creates a hidden field on the form that identifies it. This identification is then used to distinguish between missing and wrong form data when a single handler contains more than one form. For instance, if you have the following code on your handler:
((fooRes, fooWidget), fooEnctype) <- runFormPost fooForm
((barRes, barWidget), barEnctype) <- runFormPost barForm
Then replace it with
((fooRes, fooWidget), fooEnctype) <- runFormPost $ identifyForm "foo" fooForm
((barRes, barWidget), barEnctype) <- runFormPost $ identifyForm "bar" barForm
Note that it's your responsibility to ensure that the identification strings are unique (using the same one twice on a single handler will not generate any errors). This allows you to create a variable number of forms and still have them work even if their number or order change between the HTML generation and the form submission.
Find out if the sidebar should be visible. Show it, unless there is a showsidebar cookie set to "0", or a ?sidebar=0 query parameter.
The definition for the entity's primary key ID.
The entity has a single key column, and it is a surrogate key - that is, you can't go from rec -> Key rec.
The entity has a natural key. This means you can write rec -> Key rec because all the key fields are present on the datatype. A natural key can have one or more columns.
A specification for how the implied ID columns are created. By default, persistent will give each table a default column named id (customizable by PersistSettings), and the column type will be whatever you'd expect from BackendKey yourBackendType. For The SqlBackend type, this is an auto incrementing integer primary key. You might want to give a different example. A common use case in postgresql is to use the UUID type, and automatically generate them using a SQL function. Previously, you'd need to add a custom Id annotation for each model.
User
Id   UUID default="uuid_generate_v1mc()"
name Text

Dog
Id   UUID default="uuid_generate_v1mc()"
name Text
user UserId
Now, you can simply create an ImplicitIdDef that corresponds to this declaration.
newtype UUID = UUID ByteString

instance PersistField UUID where
toPersistValue (UUID bs) =
PersistLiteral_ Escaped bs
fromPersistValue pv =
case pv of
PersistLiteral_ Escaped bs ->
Right (UUID bs)
_ ->
Left "nope"

instance PersistFieldSql UUID where
sqlType _ = SqlOther UUID
With this instance at the ready, we can now create our implicit definition:
uuidDef :: ImplicitIdDef
uuidDef = mkImplicitIdDef @UUID "uuid_generate_v1mc()"
And we can use setImplicitIdDef to use this with the MkPersistSettings for our block.
mkPersist (setImplicitIdDef uuidDef sqlSettings) [persistLowerCase| ... |]
TODO: either explain interaction with mkMigrate or fix it. see issue #1249 for more details.
Indicates some sort of invalid or missing argument, like a missing query parameter or malformed JSON body. Examples Yesod functions that send this include requireCheckJsonBody and Yesod.Auth.GoogleEmail2. HTTP status: 400.
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following: The method names refer to the monoid of lists under concatenation, but there are many other instances. Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Sum and Product. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.