Merge pull request #1795 from TeofilC/monad-aform
yesod-form: Add Monad AForm instance for transformers >=0.6
This commit is contained in:
commit
0fa3dbcab6
@ -1,5 +1,9 @@
|
|||||||
# ChangeLog for yesod-form
|
# ChangeLog for yesod-form
|
||||||
|
|
||||||
|
## 1.7.4
|
||||||
|
|
||||||
|
* Added a `Monad AForm` instance only when `transformers` >= 0.6 [#1795](https://github.com/yesodweb/yesod/pull/1795)
|
||||||
|
|
||||||
## 1.7.3
|
## 1.7.3
|
||||||
|
|
||||||
* Fixed `radioField` according to Bootstrap 3 docs. [#1783](https://github.com/yesodweb/yesod/pull/1783)
|
* Fixed `radioField` according to Bootstrap 3 docs. [#1783](https://github.com/yesodweb/yesod/pull/1783)
|
||||||
|
|||||||
@ -166,6 +166,18 @@ instance Monad m => Applicative (AForm m) where
|
|||||||
(a, b, ints', c) <- f mr env ints
|
(a, b, ints', c) <- f mr env ints
|
||||||
(x, y, ints'', z) <- g mr env ints'
|
(x, y, ints'', z) <- g mr env ints'
|
||||||
return (a <*> x, b . y, ints'', c `mappend` z)
|
return (a <*> x, b . y, ints'', c `mappend` z)
|
||||||
|
|
||||||
|
#if MIN_VERSION_transformers(0,6,0)
|
||||||
|
instance Monad m => Monad (AForm m) where
|
||||||
|
(AForm f) >>= k = AForm $ \mr env ints -> do
|
||||||
|
(a, b, ints', c) <- f mr env ints
|
||||||
|
case a of
|
||||||
|
FormSuccess r -> do
|
||||||
|
(x, y, ints'', z) <- unAForm (k r) mr env ints'
|
||||||
|
return (x, b . y, ints'', c `mappend` z)
|
||||||
|
FormFailure err -> pure (FormFailure err, b, ints', c)
|
||||||
|
FormMissing -> pure (FormMissing, b, ints', c)
|
||||||
|
#endif
|
||||||
instance (Monad m, Monoid a) => Monoid (AForm m a) where
|
instance (Monad m, Monoid a) => Monoid (AForm m a) where
|
||||||
mempty = pure mempty
|
mempty = pure mempty
|
||||||
mappend a b = mappend <$> a <*> b
|
mappend a b = mappend <$> a <*> b
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
cabal-version: >= 1.10
|
cabal-version: >= 1.10
|
||||||
name: yesod-form
|
name: yesod-form
|
||||||
version: 1.7.3
|
version: 1.7.4
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user