úÎ]¶[1     © 2017 Mark Karpov BSD 3 clause$Mark Karpov <markkarpov92@gmail.com> experimentalportableNone!",2DQRTf/An internal type of response that we covert to  before returning it.TError info in JSON format associated with a particular form field. Parametrized by namesU, which is a collection of field names (on type level) the target field belongs to.  is an instance of G and that's how you combine values of that type. Note that it's not a  (, because we do not want to allow empty s.The type function computes a !€ which is satisfied when its first argument is contained in its second argument. Otherwise a friendly type error is displayed. names represents a name (") value) that is guaranteed to be in the namesÕ, which is a set of strings on type level. The purpose if this type is to avoid typos and to force users to update field names everywhere when they decide to change them. The only way to obtain a value of type  is via the  function, which see.AThis a type that user must return in the callback passed to the  U function. Quite simply, it allows you either report a error or finish successfully.7Form submission failed, here are the validation errors.*Form submission succeeded, send this info.5The type represents the parser that you can run on a  with the help of  J. The only way for the user of the library to create a parser is via the  N function. Users can combine existing parsers using the applicative notation.) is parametrized by three type variables:namesU collection of field names we can use in a form to be parsed with this parser.m underlying monad, c is not a monad itself, so it's not a monad transformer, but validation can make use of the m monad.a result of parsing.5 is not a monad because it's not possible to write a #k instance with the properties that we want (validation errors should not lead to short-cutting behavior).$State of a parsing branch.%RParsing of JSON failed, this is fatal, we shut down and report the parsing error.&™Validation of a field failed. This is also fatal but we still try to validate other branches (fields) to collect as many validation errors as possible.'&Success, we've got a result to return.-Pick a name from a given collection of names.Typical usage: `type Fields = '["foo", "bar", "baz"] myName :: SelectedName Fields myName = pick @"foo" @FieldsIt's a good idea to use œ to get field names not only where this approach is imposed by the library, but everywhere you need to use the field names, in your templates for example. Extract a " value from . $This is a smart constructor for the 7 type, and the only way to obtain values of that type.Typical usage: ƒtype Fields = '["foo", "bar", "baz"] myError :: FieldError Fields myError = mkFieldError (pick @"foo" @Fields) "That's all wrong." See also:  (to create ). 1Construct a parser for a field. Combine multiple  $s using applicative syntax like so: ÿ÷type LoginFields = '["username", "password", "remember_me"] data LoginForm = LoginForm { loginUsername :: Text , loginPassword :: Text , loginRememberMe :: Bool } loginForm :: Monad m => FormParser LoginFields m LoginForm loginForm = LoginForm <$> field @"username" notEmpty <*> field @"password" notEmpty <*> field' @"remember_me" notEmpty :: Monad m => Text -> ExceptT Text m Text notEmpty txt = if T.null txt then throwError "This field cannot be empty" else return txt4Referring to the types in the function's signature, s is extracted from JSON ! for you automatically using its (B instance. The field value is taken in assumption that top level ‰ is a dictionary, and field name is a key in that dictionary. So for example a valid JSON input for the form shown above could be this: C{ "username": "Bob", "password": "123", "remember_me": true }Once value of type s^ is extracted, validation phase beings. The supplied checker (you can easy compose them with ())1, as they are Kleisli arrows) is applied to the s4 value and validation either succeeds producing an a: value, or we collect an error in the form of a value of e type, which is fed into   internally.To run a form composed from  s, see  .  The same as  !, but does not require a checker. 5Transform a form by applying a checker on its result. ÿpasswordsMatch (a, b) = do if a == b then return a else throwError "Passwords don't match!" createNewPasswordForm = withCheck @"password_confirmation" passwordsMatch ((,) <$> field @"password" notEmpty <*> field @"password_confirmation" notEmpty)nNote that you must specify the field name on which to add a validation error message in case the check fails. sRun the supplied parser on given input and call the specified callback that uses the result of parsing on success.!The callback can either report a s (one or more), or report success providing a value that will be converted to JSON and included in the resulting  (response).The resulting  has the following format: Ô{ "parse_error": "Text or null." "field_errors": { "foo": "Foo's error serialized to JSON.", "bar": "Bar's error &" } "result": "What you return from the callback in FormResultSuccess." }"*+,-./0$%&' The field nameData that represents error PChecker that performs validation and possibly transformation of the field value The check to performOriginal parserParser with the check attached The form parser to runInput for the parser"Callback that is called on success%The result to send back to the client   *+,-./0$%&' 1      !"#$%#&'()*+,-#&./012 34#56789:"forma-0.2.0-CMTm802O8aJGDIZ4lZJtsp Web.Forma FieldErrorInSet SelectedName FormResultFormResultErrorFormResultSuccess FormParserpickunSelectedName mkFieldErrorfieldfield' withCheckrunForm$fToJSONResponse$fDefaultResponse$fToJSONFieldError$fSemigroupFieldError$fAlternativeFormParser$fApplicativeFormParser$fFunctorFormParser$fApplicativeBranchState$fEqSelectedName$fShowSelectedName$fEqFieldError$fShowFieldError$fEqFormResult$fShowFormResult$fFunctorBranchStateResponse$aeson-1.2.1.0-AaNXgHjd07wH94vQOVfApSData.Aeson.Types.InternalValuebaseData.Semigroup SemigroupGHC.BaseMonoidghc-prim GHC.Types Constraint#text-1.2.2.2-KC7dWoG09dA1F6jKj5GSqhData.Text.InternalTextMonad BranchState ParsingFailedValidationFailed SucceededData.Aeson.Types.FromJSONFromJSON Control.Monad>=>responseParseErrorresponseFieldErrorresponseResult