aeson-value-parser 0.19.4 → 0.19.4.1
raw patch · 5 files changed
+253/−267 lines, 5 filesdep −text-builderdep ~aesondep ~attoparsecPVP ok
version bump matches the API change (PVP)
Dependencies removed: text-builder
Dependency ranges changed: aeson, attoparsec
API changes (from Hackage documentation)
Files
- aeson-value-parser.cabal +3/−4
- library/AesonValueParser.hs +209/−191
- library/AesonValueParser/Error.hs +12/−12
- library/AesonValueParser/Prelude.hs +27/−56
- library/AesonValueParser/Vector.hs +2/−4
aeson-value-parser.cabal view
@@ -1,5 +1,5 @@ name: aeson-value-parser-version: 0.19.4+version: 0.19.4.1 synopsis: API for parsing "aeson" JSON tree into Haskell types description: A flexible parser DSL of JSON AST produced by the \"aeson\" library@@ -33,8 +33,8 @@ AesonValueParser.Prelude AesonValueParser.Vector build-depends:- aeson ==1.*,- attoparsec >=0.13 && <0.14,+ aeson >=2.0.2 && <3,+ attoparsec >=0.14 && <0.15, base >=4.12 && <5, bytestring >=0.10 && <0.12, hashable >=1.3 && <2,@@ -42,7 +42,6 @@ mtl >=2.2 && <3, scientific ==0.3.*, text ==1.*,- text-builder >=0.6.6.1 && <0.7, transformers >=0.5 && <0.7, unordered-containers ==0.2.*, vector >=0.10 && <0.13
library/AesonValueParser.hs view
@@ -4,99 +4,102 @@ The general model of this DSL is about switching between contexts. -} module AesonValueParser-(- Value,- run,- runWithTextError,- Error.Error(..),- -- * Value parsers- object,- array,- null,- nullable,- nullableMonoid,- string,- number,- bool,- fromJSON,- -- * String parsers- String,- text,- mappedText,- narrowedText,- matchedText,- attoparsedText,- megaparsedText,- -- * Number parsers- Number,- scientific,- integer,- floating,- matchedScientific,- matchedInteger,- matchedFloating,- -- * Object parsers- Object,- field,- oneOfFields,- fieldMap,- foldlFields,- -- * Array parsers- Array,- element,- elementVector,- foldlElements,- foldrElements,-)+ ( Value,+ run,+ runWithTextError,+ Error.Error (..),++ -- * Value parsers+ object,+ array,+ null,+ nullable,+ nullableMonoid,+ string,+ number,+ bool,+ fromJSON,++ -- * String parsers+ String,+ text,+ mappedText,+ narrowedText,+ matchedText,+ attoparsedText,+ megaparsedText,++ -- * Number parsers+ Number,+ scientific,+ integer,+ floating,+ matchedScientific,+ matchedInteger,+ matchedFloating,++ -- * Object parsers+ Object,+ field,+ oneOfFields,+ fieldMap,+ foldlFields,++ -- * Array parsers+ Array,+ element,+ elementVector,+ foldlElements,+ foldrElements,+ ) where -import AesonValueParser.Prelude hiding (bool, null, String) import qualified AesonValueParser.Error as Error+import AesonValueParser.Prelude hiding (String, bool, null)+import qualified AesonValueParser.Vector as Vector import qualified Data.Aeson as Aeson+import qualified Data.Aeson.Key as Key+import qualified Data.Aeson.KeyMap as KeyMap import qualified Data.Attoparsec.Text as Attoparsec-import qualified Text.Megaparsec as Megaparsec import qualified Data.HashMap.Strict as HashMap import qualified Data.HashSet as HashSet import qualified Data.Scientific as Scientific import qualified Data.Text.Encoding as Text import qualified Data.Vector as Vector-import qualified AesonValueParser.Vector as Vector-+import qualified Text.Megaparsec as Megaparsec -- * Value-------------------------- -{-|-JSON `Aeson.Value` AST parser.--Its `Alternative` instance implements the logic of choosing between the possible types of JSON values.--}-newtype Value a =- Value (ReaderT Aeson.Value (MaybeT (Either Error.Error)) a)+-- |+-- JSON `Aeson.Value` AST parser.+--+-- Its `Alternative` instance implements the logic of choosing between the possible types of JSON values.+newtype Value a+ = Value (ReaderT Aeson.Value (MaybeT (Either Error.Error)) a) deriving (Functor, Applicative) -{-|-Implements the logic of choosing between the possible types of JSON values.--If you have multiple parsers of the same type of JSON value composed,-only the leftmost will be affective.-The errors from deeper parsers do not trigger the alternation,-instead they get propagated to the top.--}+-- |+-- Implements the logic of choosing between the possible types of JSON values.+--+-- If you have multiple parsers of the same type of JSON value composed,+-- only the leftmost will be affective.+-- The errors from deeper parsers do not trigger the alternation,+-- instead they get propagated to the top. instance Alternative Value where empty = Value $ ReaderT $ const $ MaybeT $ return Nothing (<|>) (Value leftParser) (Value rightParser) = Value (leftParser <|> rightParser) {-# INLINE run #-} run :: Value a -> Aeson.Value -> Either Error.Error a-run = \ (Value parser) value -> (=<<) (maybe (Left (typeError value)) Right) $ runMaybeT $ runReaderT parser value where- typeError = \ case- Aeson.Array _ -> "Unexpected type: array"- Aeson.Object _ -> "Unexpected type: object"- Aeson.String _ -> "Unexpected type: string"- Aeson.Number _ -> "Unexpected type: number"- Aeson.Bool _ -> "Unexpected type: bool"- Aeson.Null -> "Unexpected type: null"+run = \(Value parser) value -> (=<<) (maybe (Left (typeError value)) Right) $ runMaybeT $ runReaderT parser value+ where+ typeError = \case+ Aeson.Array _ -> "Unexpected type: array"+ Aeson.Object _ -> "Unexpected type: object"+ Aeson.String _ -> "Unexpected type: string"+ Aeson.Number _ -> "Unexpected type: number"+ Aeson.Bool _ -> "Unexpected type: bool"+ Aeson.Null -> "Unexpected type: null" {-# INLINE runWithTextError #-} runWithTextError :: Value a -> Aeson.Value -> Either Text a@@ -106,68 +109,76 @@ runString (String a) b = first getLast (runExcept (runReaderT a b)) -- ** Definitions-------------------------- {-# INLINE array #-} array :: Array a -> Value a-array (Array parser) = Value $ ReaderT $ \ case- Aeson.Array x -> lift $ join $ runExcept $ runExceptT $ runReaderT parser x- _ -> empty+array (Array parser) = Value $+ ReaderT $ \case+ Aeson.Array x -> lift $ join $ runExcept $ runExceptT $ runReaderT parser x+ _ -> empty {-# INLINE object #-} object :: Object a -> Value a-object (Object parser) = Value $ ReaderT $ \ case- Aeson.Object x -> lift $ join $ runExcept $ runExceptT $ runReaderT parser x- _ -> empty+object (Object parser) = Value $+ ReaderT $ \case+ Aeson.Object x -> lift $ join $ runExcept $ runExceptT $ runReaderT parser x+ _ -> empty {-# INLINE null #-} null :: Value ()-null = Value $ ReaderT $ \ case- Aeson.Null -> pure ()- _ -> empty+null = Value $+ ReaderT $ \case+ Aeson.Null -> pure ()+ _ -> empty {-# INLINE nullable #-} nullable :: Value a -> Value (Maybe a)-nullable (Value parser) = Value $ ReaderT $ \ case- Aeson.Null -> pure Nothing- x -> fmap Just (runReaderT parser x)+nullable (Value parser) = Value $+ ReaderT $ \case+ Aeson.Null -> pure Nothing+ x -> fmap Just (runReaderT parser x) {-# INLINE nullableMonoid #-} nullableMonoid :: Monoid a => Value a -> Value a-nullableMonoid (Value parser) = Value $ ReaderT $ \ case- Aeson.Null -> pure mempty- x -> runReaderT parser x+nullableMonoid (Value parser) = Value $+ ReaderT $ \case+ Aeson.Null -> pure mempty+ x -> runReaderT parser x {-# INLINE string #-} string :: String a -> Value a-string (String parser) = Value $ ReaderT $ \ case- Aeson.String x -> lift $ left (Error.message . fromMaybe "No details" . getLast) $ runExcept $ runReaderT parser x- _ -> empty+string (String parser) = Value $+ ReaderT $ \case+ Aeson.String x -> lift $ left (Error.message . fromMaybe "No details" . getLast) $ runExcept $ runReaderT parser x+ _ -> empty {-# INLINE number #-} number :: Number a -> Value a-number (Number parser) = Value $ ReaderT $ \ case- Aeson.Number x -> lift $ left (Error.message . fromMaybe "No details" . getLast) $ runExcept $ runReaderT parser x- _ -> empty+number (Number parser) = Value $+ ReaderT $ \case+ Aeson.Number x -> lift $ left (Error.message . fromMaybe "No details" . getLast) $ runExcept $ runReaderT parser x+ _ -> empty {-# INLINE bool #-} bool :: Value Bool-bool = Value $ ReaderT $ \ case- Aeson.Bool x -> return x- _ -> empty+bool = Value $+ ReaderT $ \case+ Aeson.Bool x -> return x+ _ -> empty {-# INLINE fromJSON #-} fromJSON :: Aeson.FromJSON a => Value a-fromJSON = Value $ ReaderT $ Aeson.fromJSON >>> \ case- Aeson.Success r -> return r- Aeson.Error m -> lift $ Left $ fromString m-+fromJSON =+ Value $+ ReaderT $+ Aeson.fromJSON >>> \case+ Aeson.Success r -> return r+ Aeson.Error m -> lift $ Left $ fromString m -- * String parsers-------------------------- -newtype String a =- String (ReaderT Text (Except (Last Text)) a)+newtype String a+ = String (ReaderT Text (Except (Last Text)) a) deriving (Functor, Applicative, Alternative) {-# INLINE text #-}@@ -176,24 +187,25 @@ {-# INLINE mappedText #-} mappedText :: [(Text, a)] -> String a-mappedText mappingList = let- expectedValuesText = fromString (show (fmap fst mappingList))- match lookup text = case lookup text of- Just a -> Right a- _ -> Left ("Unexpected value: \"" <> text <> "\". Expecting one of: " <> expectedValuesText)- mappingListLength = length mappingList- in if mappingListLength > 512- then let- !hashMap = HashMap.fromList mappingList- in matchedText (match (flip HashMap.lookup hashMap))- else matchedText (match (flip lookup mappingList))+mappedText mappingList =+ let expectedValuesText = fromString (show (fmap fst mappingList))+ match lookup text = case lookup text of+ Just a -> Right a+ _ -> Left ("Unexpected value: \"" <> text <> "\". Expecting one of: " <> expectedValuesText)+ mappingListLength = length mappingList+ in if mappingListLength > 512+ then+ let !hashMap = HashMap.fromList mappingList+ in matchedText (match (flip HashMap.lookup hashMap))+ else matchedText (match (flip lookup mappingList)) {-# INLINE narrowedText #-} narrowedText :: (Text -> Maybe a) -> String a-narrowedText narrow = matchedText match where- match text = case narrow text of- Just a -> Right a- _ -> Left ("Unexpected value: \"" <> text <> "\"")+narrowedText narrow = matchedText match+ where+ match text = case narrow text of+ Just a -> Right a+ _ -> Left ("Unexpected value: \"" <> text <> "\"") {-# INLINE matchedText #-} matchedText :: (Text -> Either Text a) -> String a@@ -205,16 +217,15 @@ {-# INLINE megaparsedText #-} megaparsedText :: Megaparsec.Parsec Void Text a -> String a-megaparsedText = matchedText . matcher where- matcher :: Megaparsec.Parsec Void Text a -> Text -> Either Text a- matcher p = left (fromString . Megaparsec.errorBundlePretty) . Megaparsec.runParser (p <* Megaparsec.eof) ""-+megaparsedText = matchedText . matcher+ where+ matcher :: Megaparsec.Parsec Void Text a -> Text -> Either Text a+ matcher p = left (fromString . Megaparsec.errorBundlePretty) . Megaparsec.runParser (p <* Megaparsec.eof) "" -- * Number parsers-------------------------- -newtype Number a =- Number (ReaderT Scientific (Except (Last Text)) a)+newtype Number a+ = Number (ReaderT Scientific (Except (Last Text)) a) deriving (Functor, Applicative, Alternative) {-# INLINE scientific #-}@@ -223,19 +234,23 @@ {-# INLINE integer #-} integer :: (Integral a, Bounded a) => Number a-integer = Number $ ReaderT $ \ x -> if Scientific.isInteger x- then case Scientific.toBoundedInteger x of- Just int -> return int- Nothing -> throwError (Last (Just (fromString ("Number " <> show x <> " is out of integer range"))))- else throwError (Last (Just (fromString ("Number " <> show x <> " is not integer"))))+integer = Number $+ ReaderT $ \x ->+ if Scientific.isInteger x+ then case Scientific.toBoundedInteger x of+ Just int -> return int+ Nothing -> throwError (Last (Just (fromString ("Number " <> show x <> " is out of integer range"))))+ else throwError (Last (Just (fromString ("Number " <> show x <> " is not integer")))) {-# INLINE floating #-} floating :: RealFloat a => Number a-floating = Number $ ReaderT $ \ a -> case Scientific.toBoundedRealFloat a of- Right b -> return b- Left c -> if c == 0- then throwError (Last (Just (fromString ("Number " <> show a <> " is too small"))))- else throwError (Last (Just (fromString ("Number " <> show a <> " is too large"))))+floating = Number $+ ReaderT $ \a -> case Scientific.toBoundedRealFloat a of+ Right b -> return b+ Left c ->+ if c == 0+ then throwError (Last (Just (fromString ("Number " <> show a <> " is too small"))))+ else throwError (Last (Just (fromString ("Number " <> show a <> " is too large")))) {-# INLINE matchedScientific #-} matchedScientific :: (Scientific -> Either Text a) -> Number a@@ -251,15 +266,12 @@ matchedFloating matcher = Number $ case floating of Number parser -> parser >>= either (throwError . Last . Just) return . matcher - -- * Object parsers-------------------------- -{-|-JSON `Aeson.Object` parser.--}-newtype Object a =- Object (ReaderT (HashMap Text Aeson.Value) (ExceptT Error.Error (Except Error.Error)) a)+-- |+-- JSON `Aeson.Object` parser.+newtype Object a+ = Object (ReaderT (KeyMap.KeyMap Aeson.Value) (ExceptT Error.Error (Except Error.Error)) a) deriving (Functor, Applicative, Alternative, Monad, MonadPlus, MonadError Error.Error) instance MonadFail Object where@@ -267,15 +279,16 @@ {-# INLINE field #-} field :: Text -> Value a -> Object a-field name fieldParser = Object $ ReaderT $ \ object -> case HashMap.lookup name object of- Just value -> case run fieldParser value of- Right parsedValue -> return parsedValue- Left error -> lift $ throwE $ Error.named name error- Nothing -> throwE (Error.Error (pure name) message)- where- message =- "Object contains no field with this name. Fields available: " <>- fromString (show (HashMap.keys object))+field name fieldParser = Object $+ ReaderT $ \object -> case KeyMap.lookup (Key.fromText name) object of+ Just value -> case run fieldParser value of+ Right parsedValue -> return parsedValue+ Left error -> lift $ throwE $ Error.named name error+ Nothing -> throwE (Error.Error (pure name) message)+ where+ message =+ "Object contains no field with this name. Fields available: "+ <> fromString (show (KeyMap.keys object)) {-# INLINE oneOfFields #-} oneOfFields :: [Text] -> Value a -> Object a@@ -283,35 +296,36 @@ {-# INLINE fieldMap #-} fieldMap :: (Eq a, Hashable a) => String a -> Value b -> Object (HashMap a b)-fieldMap keyParser fieldParser = Object $ ReaderT $ fmap HashMap.fromList . traverse mapping . HashMap.toList where- mapping (keyText, ast) = - case runString keyParser keyText of- Right parsedKey -> case run fieldParser ast of- Right parsedField -> return (parsedKey, parsedField)- Left error -> lift (throwE (Error.named keyText error))- Left error -> lift (throwE (maybe mempty Error.message error))+fieldMap keyParser fieldParser = Object $ ReaderT $ fmap HashMap.fromList . traverse mapping . KeyMap.toList+ where+ mapping (key, ast) =+ case Key.toText key of+ keyText -> case runString keyParser keyText of+ Right parsedKey -> case run fieldParser ast of+ Right parsedField -> return (parsedKey, parsedField)+ Left error -> lift (throwE (Error.named keyText error))+ Left error -> lift (throwE (maybe mempty Error.message error)) {-# INLINE foldlFields #-} foldlFields :: (state -> key -> field -> state) -> state -> String key -> Value field -> Object state-foldlFields step state keyParser fieldParser = Object $ ReaderT $ \ object -> HashMap.foldlWithKey' newStep (pure state) object where- newStep stateE key fieldAst = - case runString keyParser key of- Right !parsedKey -> case run fieldParser fieldAst of- Right !parsedField -> do- !state <- stateE- return $ step state parsedKey parsedField- Left error -> lift (throwE (Error.named key error))- Left error -> lift (throwE (maybe mempty Error.message error))-+foldlFields step state keyParser fieldParser = Object $+ ReaderT $ \object ->+ KeyMap.foldrWithKey newStep pure object state+ where+ newStep key value next !state =+ case Key.toText key of+ key -> case runString keyParser key of+ Right parsedKey -> case run fieldParser value of+ Right parsedValue -> next (step state parsedKey parsedValue)+ Left error -> lift $ throwE $ Error.named key error+ Left error -> lift (throwE (maybe mempty Error.message error)) -- * Array parsers-------------------------- -{-|-JSON `Aeson.Array` parser.--}-newtype Array a =- Array (ReaderT (Vector Aeson.Value) (ExceptT Error.Error (Except Error.Error)) a)+-- |+-- JSON `Aeson.Array` parser.+newtype Array a+ = Array (ReaderT (Vector Aeson.Value) (ExceptT Error.Error (Except Error.Error)) a) deriving (Functor, Applicative, Alternative, Monad, MonadPlus, MonadError Error.Error) instance MonadFail Array where@@ -319,28 +333,32 @@ {-# INLINE element #-} element :: Int -> Value a -> Array a-element index elementParser = Array $ ReaderT $ \ array -> case array Vector.!? index of- Just element -> case run elementParser element of- Right result -> return result- Left error -> lift $ throwE $ Error.indexed index error- Nothing -> throwE $ Error.Error (pure (fromString (show index))) "Array contains no element by this index"+element index elementParser = Array $+ ReaderT $ \array -> case array Vector.!? index of+ Just element -> case run elementParser element of+ Right result -> return result+ Left error -> lift $ throwE $ Error.indexed index error+ Nothing -> throwE $ Error.Error (pure (fromString (show index))) "Array contains no element by this index" {-# INLINE elementVector #-} elementVector :: Value a -> Array (Vector a)-elementVector elementParser = Array $ ReaderT $ \ arrayAst -> flip Vector.imapM arrayAst $ \ index ast -> case run elementParser ast of- Right element -> return element- Left error -> lift $ throwE $ Error.indexed index error+elementVector elementParser = Array $+ ReaderT $ \arrayAst -> flip Vector.imapM arrayAst $ \index ast -> case run elementParser ast of+ Right element -> return element+ Left error -> lift $ throwE $ Error.indexed index error {-# INLINE foldlElements #-} foldlElements :: (state -> Int -> element -> state) -> state -> Value element -> Array state-foldlElements step state elementParser = Array $ ReaderT $ Vector.ifoldM' newStep state where- newStep state index ast = case run elementParser ast of- Right element -> return $ step state index element- Left error -> lift $ throwE $ Error.indexed index error+foldlElements step state elementParser = Array $ ReaderT $ Vector.ifoldM' newStep state+ where+ newStep state index ast = case run elementParser ast of+ Right element -> return $ step state index element+ Left error -> lift $ throwE $ Error.indexed index error {-# INLINE foldrElements #-} foldrElements :: (Int -> element -> state -> state) -> state -> Value element -> Array state-foldrElements step state elementParser = Array $ ReaderT $ Vector.ifoldrM newStep state where- newStep index ast nextState = case run elementParser ast of- Right element -> return $ step index element nextState- Left error -> lift $ throwE $ Error.indexed index error+foldrElements step state elementParser = Array $ ReaderT $ Vector.ifoldrM newStep state+ where+ newStep index ast nextState = case run elementParser ast of+ Right element -> return $ step index element nextState+ Left error -> lift $ throwE $ Error.indexed index error
library/AesonValueParser/Error.hs view
@@ -1,12 +1,14 @@-module AesonValueParser.Error-where+module AesonValueParser.Error where import AesonValueParser.Prelude import qualified Data.Text as Text-import qualified Text.Builder as TextBuilder --data Error = Error [Text] {-^ Path -} Text {-^ Message -}+data Error+ = Error+ [Text]+ -- ^ Path+ Text+ -- ^ Message instance Semigroup Error where (<>) _ b = b@@ -34,10 +36,8 @@ message = Error [] toText :: Error -> Text-toText = TextBuilder.run . toTextBuilder--toTextBuilder :: Error -> TextBuilder.Builder-toTextBuilder (Error path message) =- "AST parsing error at path " <>- foldMap (\ x -> "/" <> TextBuilder.text x) path <> ": " <>- TextBuilder.text message+toText (Error path message) =+ "AST parsing error at path "+ <> foldMap (\x -> "/" <> x) path+ <> ": "+ <> message
library/AesonValueParser/Prelude.hs view
@@ -1,26 +1,28 @@ module AesonValueParser.Prelude-(- module Exports,- showText,-)+ ( module Exports,+ showText,+ ) where ---- base-------------------------- import Control.Applicative as Exports import Control.Arrow as Exports hiding (first, second) import Control.Category as Exports import Control.Concurrent as Exports import Control.Exception as Exports-import Control.Monad as Exports hiding (fail, mapM_, sequence_, forM_, msum, mapM, sequence, forM)-import Control.Monad.IO.Class as Exports+import Control.Monad as Exports hiding (fail, forM, forM_, mapM, mapM_, msum, sequence, sequence_)+import Control.Monad.Error.Class as Exports hiding (Error) import Control.Monad.Fail as Exports import Control.Monad.Fix as Exports hiding (fix)+import Control.Monad.IO.Class as Exports import Control.Monad.ST as Exports+import Control.Monad.Trans.Class as Exports+import Control.Monad.Trans.Except as Exports hiding (liftCallCC, liftCatch)+import Control.Monad.Trans.Maybe as Exports hiding (liftCallCC, liftCatch, liftListen, liftPass)+import Control.Monad.Trans.Reader as Exports hiding (liftCallCC, liftCatch) import Data.Bifunctor as Exports import Data.Bits as Exports import Data.Bool as Exports+import Data.ByteString as Exports (ByteString) import Data.Char as Exports import Data.Coerce as Exports import Data.Complex as Exports@@ -32,22 +34,27 @@ import Data.Function as Exports hiding (id, (.)) import Data.Functor as Exports import Data.Functor.Identity as Exports-import Data.Int as Exports+import Data.HashMap.Strict as Exports (HashMap)+import Data.Hashable as Exports (Hashable) import Data.IORef as Exports+import Data.Int as Exports import Data.Ix as Exports-import Data.List as Exports hiding (sortOn, isSubsequenceOf, uncons, concat, foldr, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, find, maximumBy, minimumBy, mapAccumL, mapAccumR, foldl')-import Data.List.NonEmpty as Exports (NonEmpty(..))+import Data.List as Exports hiding (all, and, any, concat, concatMap, elem, find, foldl, foldl', foldl1, foldr, foldr1, isSubsequenceOf, mapAccumL, mapAccumR, maximum, maximumBy, minimum, minimumBy, notElem, or, product, sortOn, sum, uncons)+import Data.List.NonEmpty as Exports (NonEmpty (..)) import Data.Maybe as Exports import Data.Monoid as Exports hiding ((<>)) import Data.Ord as Exports import Data.Proxy as Exports import Data.Ratio as Exports-import Data.Semigroup as Exports hiding (Last(..), First(..)) import Data.STRef as Exports+import Data.Scientific as Exports (Scientific)+import Data.Semigroup as Exports hiding (First (..), Last (..)) import Data.String as Exports+import Data.Text as Exports (Text) import Data.Traversable as Exports import Data.Tuple as Exports import Data.Unique as Exports+import Data.Vector as Exports (Vector) import Data.Version as Exports import Data.Void as Exports import Data.Word as Exports@@ -55,13 +62,12 @@ import Foreign.ForeignPtr as Exports import Foreign.Ptr as Exports import Foreign.StablePtr as Exports-import Foreign.Storable as Exports hiding (sizeOf, alignment)-import GHC.Conc as Exports hiding (withMVar, threadWaitWriteSTM, threadWaitWrite, threadWaitReadSTM, threadWaitRead)-import GHC.Exts as Exports (lazy, inline, sortWith, groupWith, IsList(..))+import Foreign.Storable as Exports hiding (alignment, sizeOf)+import GHC.Conc as Exports hiding (threadWaitRead, threadWaitReadSTM, threadWaitWrite, threadWaitWriteSTM, withMVar)+import GHC.Exts as Exports (IsList (..), groupWith, inline, lazy, sortWith) import GHC.Generics as Exports (Generic) import GHC.IO.Exception as Exports import Numeric as Exports-import Prelude as Exports hiding (fail, concat, foldr, mapM_, sequence_, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, mapM, sequence, id, (.)) import System.Environment as Exports import System.Exit as Exports import System.IO as Exports@@ -71,46 +77,11 @@ import System.Mem.StableName as Exports import System.Timeout as Exports import Text.ParserCombinators.ReadP as Exports (ReadP, ReadS, readP_to_S, readS_to_P)-import Text.ParserCombinators.ReadPrec as Exports (ReadPrec, readPrec_to_P, readP_to_Prec, readPrec_to_S, readS_to_Prec)-import Text.Printf as Exports (printf, hPrintf)-import Text.Read as Exports (Read(..), readMaybe, readEither)+import Text.ParserCombinators.ReadPrec as Exports (ReadPrec, readP_to_Prec, readPrec_to_P, readPrec_to_S, readS_to_Prec)+import Text.Printf as Exports (hPrintf, printf)+import Text.Read as Exports (Read (..), readEither, readMaybe) import Unsafe.Coerce as Exports---- transformers---------------------------import Control.Monad.Trans.Class as Exports-import Control.Monad.Trans.Except as Exports hiding (liftCatch, liftCallCC)-import Control.Monad.Trans.Maybe as Exports hiding (liftCatch, liftCallCC, liftListen, liftPass)-import Control.Monad.Trans.Reader as Exports hiding (liftCatch, liftCallCC)---- mtl---------------------------import Control.Monad.Error.Class as Exports hiding (Error)---- bytestring---------------------------import Data.ByteString as Exports (ByteString)---- text---------------------------import Data.Text as Exports (Text)---- unordered-containers---------------------------import Data.HashMap.Strict as Exports (HashMap)---- vector---------------------------import Data.Vector as Exports (Vector)---- scientific---------------------------import Data.Scientific as Exports (Scientific)---- hashable---------------------------import Data.Hashable as Exports (Hashable)-+import Prelude as Exports hiding (all, and, any, concat, concatMap, elem, fail, foldl, foldl1, foldr, foldr1, id, mapM, mapM_, maximum, minimum, notElem, or, product, sequence, sequence_, sum, (.)) showText :: Show a => a -> Text showText = fromString . show
library/AesonValueParser/Vector.hs view
@@ -1,10 +1,8 @@-module AesonValueParser.Vector-where+module AesonValueParser.Vector where import AesonValueParser.Prelude hiding (Vector)-import Data.Vector.Generic import qualified Data.Vector.Fusion.Bundle.Monadic as BundleM-+import Data.Vector.Generic {-# INLINE ifoldrM #-} ifoldrM :: (Vector v a, Monad m) => (Int -> a -> b -> m b) -> b -> v a -> m b