checkMMod

This commit is contained in:
Michael Snoyman 2012-08-22 20:05:34 +03:00
parent 34db07760a
commit 6b31b583f2
2 changed files with 15 additions and 8 deletions

View File

@ -33,6 +33,7 @@ module Yesod.Form.Functions
, check , check
, checkBool , checkBool
, checkM , checkM
, checkMMod
, customErrorMessage , customErrorMessage
-- * Utilities -- * Utilities
, fieldSettingsLabel , fieldSettingsLabel
@ -355,14 +356,20 @@ checkM :: RenderMessage master msg
=> (a -> GHandler sub master (Either msg a)) => (a -> GHandler sub master (Either msg a))
-> Field sub master a -> Field sub master a
-> Field sub master a -> Field sub master a
checkM f = checkM' f id checkM f = checkMMod f id
checkM' :: RenderMessage master msg -- | Same as 'checkM', but modifies the datatype.
=> (a -> GHandler sub master (Either msg b)) --
-> (b -> a) -- In order to make this work, you must provide a function to convert back from
-> Field sub master a -- the new datatype to the old one (the second argument to this function).
-> Field sub master b --
checkM' f inv field = field -- Since 1.1.1
checkMMod :: RenderMessage master msg
=> (a -> GHandler sub master (Either msg b))
-> (b -> a)
-> Field sub master a
-> Field sub master b
checkMMod f inv field = field
{ fieldParse = \ts -> do { fieldParse = \ts -> do
e1 <- fieldParse field ts e1 <- fieldParse field ts
case e1 of case e1 of

View File

@ -1,5 +1,5 @@
name: yesod-form name: yesod-form
version: 1.1.0.1 version: 1.1.1
license: MIT license: MIT
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>