on master help sign in
Add (<*>+)
commit0f13c595f5e674f0f5bd2bf388616a84e126a293 authorlyxia <lysxia@gmail.com> dateWed 27 Sep 2017, 19:41 (9 years ago) parentb61e9a5
2 files changed+11−1
Data/Aeson/Types.hs+1 Data/Aeson/Types/Internal.hs+10−1
Data/Aeson/Types.hs+1
@@ -36,6 +36,7 @@ module Data.Aeson.Types
3636 , ToJSON(..)
3737 , KeyValue(..)
3838 , liftP2
39+ , (<*>+)
3940 , modifyFailure
4041 , parserThrowError
4142 , parserCatchError
Data/Aeson/Types/Internal.hs+10−1
@@ -44,6 +44,7 @@ module Data.Aeson.Types.Internal
4444 , parseEither
4545 , parseMaybe
4646 , liftP2
47+ , (<*>+)
4748 , modifyFailure
4849 , parserThrowError
4950 , parserCatchError
@@ -339,7 +340,8 @@ apP d e = do
339340 return (b a)
340341{-# INLINE apP #-}
341342
342−-- | A variant of 'liftA2' that lazily accumulates errors from both subparsers.
343+-- | A variant of 'Control.Applicative.liftA2' that lazily accumulates errors
344+-- from both subparsers.
343345liftP2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c
344346liftP2 f pa pb = Parser $ \path kf ks ->
345347 runParser pa path
@@ -347,6 +349,13 @@ liftP2 f pa pb = Parser $ \path kf ks ->
347349 (\a -> runParser pb path kf (\b -> ks (f a b)))
348350{-# INLINE liftP2 #-}
349351
352+infixl 4 <*>+
353+
354+-- | A variant of ('<*>') that lazily accumulates errors from both subparsers.
355+(<*>+) :: Parser (a -> b) -> Parser a -> Parser b
356+(<*>+) = liftP2 id
357+{-# INLINE (<*>+) #-}
358+
350359-- | A JSON \"object\" (key\/value map).
351360type Object = HashMap Text Value
352361