@@ -16,7 +16,6 @@ module Control.Monad.Validation
1616 , vWarningL
1717 , vZoom
1818 , vZoomL
19− , vPromote
2019 , mmSingleton
2120 , setMempty
2221 , neConcat
@@ -38,14 +37,11 @@ import Data.Foldable as F
3837import Data.Functor
3938import Data.List as L
4039import Data.Map.Strict as M
40+import Data.Monoid
4141import Data.Text as T
4242import Data.Vector as V
4343import Test.QuickCheck
4444
45−#if MIN_VERSION_mtl(2,3,0)
46−import Control.Monad
47−import Control.Monad.Fix
48−#endif
4945
5046-- | Collects all thrown warnings in 'StateT' and errors
5147-- in 'ExceptT' into a single value using 'Monoid'.
@@ -89,7 +85,7 @@ instance (Ord k, Semigroup v) => Semigroup (MonoidMap k v) where
8985
9086instance (Ord k, Monoid v) => Monoid (MonoidMap k v) where
9187 mempty = MonoidMap M.empty
92− mappend = (<>)
88+ mappend = mmAppend
9389
9490instance (ToJSON k, ToJSON v) => ToJSON (MonoidMap k v) where
9591 toJSON (MonoidMap m) = toJSON $ L.map toObj $ M.toList m
@@ -147,12 +143,12 @@ neConcat f a
147143textErrors :: [Text] -> Maybe Text
148144textErrors = neConcat (\a b -> a <> ", " <> b)
149145
150−-- | Returns 'mempty' instead of error if no warnings have occurred.
146+-- | Returns 'mempty' instead of error if no warnings have occured.
151147-- Returns 'Nothing' as the second element of tuple if computation was
152148-- interrupted by 'vError'.
153149--
154150-- Returns all concatenated errors and warnings and the result if no
155−-- errors have occurred (warnings could have occurred).
151+-- errors have occured (warnings could have occured).
156152--
157153-- >>> :{
158154-- runValidationT $ do
@@ -178,7 +174,7 @@ runValidationT (ValidationT m) = do
178174 Right a -> (warnings, Just a)
179175
180176-- | Like 'runValidationT' but doesn't return the result
181−-- if any warning has occurred.
177+-- if any warning has occured.
182178--
183179-- >>> :{
184180-- runValidationTEither $ do
@@ -289,12 +285,3 @@ vZoomL
289285 -> ValidationT a m x
290286 -> ValidationT b m x
291287vZoomL l = vZoom (setMempty l)
292−
293−-- | Turn any warnings the have occurred into errors.
294−vPromote
295− :: (Monad m, Monoid a, Eq a)
296− => ValidationT a m x
297− -> ValidationT a m x
298−vPromote m = do
299− err <- lift $ runValidationTEither m
300− either vError return err