git.iko.soy/typeable/attoparsec
on master help sign in
Merge from 0.11
7600fe9Bryan O'Sullivan
attoparsec.cabal−1
@@ -111,7 +111,6 @@ benchmark benchmarks
111 ghc-options: -Werror
111 ghc-options: -Werror
112
112
113 build-depends:
113 build-depends:
114− aeson,
115 array,
114 array,
116 base == 4.*,
115 base == 4.*,
117 bytestring >= 0.10.4.0,
116 bytestring >= 0.10.4.0,
benchmarks/Aeson.hs+31−2
@@ -11,8 +11,8 @@ import Data.ByteString.Builder
11 (Builder, byteString, toLazyByteString, charUtf8, word8)
11 (Builder, byteString, toLazyByteString, charUtf8, word8)
12
12
13import Control.Applicative ((*>), (<$>), (<*), liftA2, pure)
13import Control.Applicative ((*>), (<$>), (<*), liftA2, pure)
14+import Control.DeepSeq (NFData(..))
14import Control.Monad (forM)
15import Control.Monad (forM)
15−import Data.Aeson.Types (Result(..), Value(..))
16import Data.Attoparsec.ByteString.Char8 (Parser, char, endOfInput, scientific,
16import Data.Attoparsec.ByteString.Char8 (Parser, char, endOfInput, scientific,
17 skipSpace, string)
17 skipSpace, string)
18import Data.Bits ((.|.), shiftL)
18import Data.Bits ((.|.), shiftL)
@@ -20,9 +20,10 @@ import Data.ByteString (ByteString)
20import Data.Char (chr)
20import Data.Char (chr)
21import Data.List (sort)
21import Data.List (sort)
22import Data.Monoid (mappend, mempty)
22import Data.Monoid (mappend, mempty)
23+import Data.Scientific (Scientific)
23import Data.Text (Text)
24import Data.Text (Text)
24import Data.Text.Encoding (decodeUtf8')
25import Data.Text.Encoding (decodeUtf8')
25−import Data.Vector as Vector (Vector, fromList)
26+import Data.Vector as Vector (Vector, foldl', fromList)
26import Data.Word (Word8)
27import Data.Word (Word8)
27import System.Directory (getDirectoryContents)
28import System.Directory (getDirectoryContents)
28import System.FilePath ((</>), dropExtension)
29import System.FilePath ((</>), dropExtension)
@@ -51,6 +52,34 @@ import Criterion.Main
51#define C_n 110
52#define C_n 110
52#define C_t 116
53#define C_t 116
53
54
55+data Result a = Error String
56+ | Success a
57+ deriving (Eq, Show)
58+
59+
60+-- | A JSON \"object\" (key\/value map).
61+type Object = H.HashMap Text Value
62+
63+-- | A JSON \"array\" (sequence).
64+type Array = Vector Value
65+
66+-- | A JSON value represented as a Haskell value.
67+data Value = Object !Object
68+ | Array !Array
69+ | String !Text
70+ | Number !Scientific
71+ | Bool !Bool
72+ | Null
73+ deriving (Eq, Show)
74+
75+instance NFData Value where
76+ rnf (Object o) = rnf o
77+ rnf (Array a) = Vector.foldl' (\x y -> rnf y `seq` x) () a
78+ rnf (String s) = rnf s
79+ rnf (Number n) = rnf n
80+ rnf (Bool b) = rnf b
81+ rnf Null = ()
82+
54-- | Parse a top-level JSON value. This must be either an object or
83-- | Parse a top-level JSON value. This must be either an object or
55-- an array, per RFC 4627.
84-- an array, per RFC 4627.
56--
85--
benchmarks/attoparsec-benchmarks.cabal−1
@@ -17,7 +17,6 @@ executable attoparsec-benchmarks
17 hs-source-dirs: .. .
17 hs-source-dirs: .. .
18 ghc-options: -O2 -Wall
18 ghc-options: -O2 -Wall
19 build-depends:
19 build-depends:
20− aeson,
21 array,
20 array,
22 base == 4.*,
21 base == 4.*,
23 bytestring >= 0.10.4.0,
22 bytestring >= 0.10.4.0,