Commits

Bryan O'Sullivan  committed b44e92b Merge

Merge from 0.11

  • Participants
  • Parent commits 62944b6, e0d31a3

Comments (0)

Files changed (3)

File attoparsec.cabal

     ghc-options: -Werror
 
   build-depends:
-    aeson,
     array,
     base == 4.*,
     bytestring >= 0.10.4.0,

File benchmarks/Aeson.hs

   (Builder, byteString, toLazyByteString, charUtf8, word8)
 
 import Control.Applicative ((*>), (<$>), (<*), liftA2, pure)
+import Control.DeepSeq (NFData(..))
 import Control.Monad (forM)
-import Data.Aeson.Types (Result(..), Value(..))
 import Data.Attoparsec.ByteString.Char8 (Parser, char, endOfInput, scientific,
                                          skipSpace, string)
 import Data.Bits ((.|.), shiftL)
 import Data.Char (chr)
 import Data.List (sort)
 import Data.Monoid (mappend, mempty)
+import Data.Scientific (Scientific)
 import Data.Text (Text)
 import Data.Text.Encoding (decodeUtf8')
-import Data.Vector as Vector (Vector, fromList)
+import Data.Vector as Vector (Vector, foldl', fromList)
 import Data.Word (Word8)
 import System.Directory (getDirectoryContents)
 import System.FilePath ((</>), dropExtension)
 #define C_n 110
 #define C_t 116
 
+data Result a = Error String
+              | Success a
+                deriving (Eq, Show)
+
+
+-- | A JSON \"object\" (key\/value map).
+type Object = H.HashMap Text Value
+
+-- | A JSON \"array\" (sequence).
+type Array = Vector Value
+
+-- | A JSON value represented as a Haskell value.
+data Value = Object !Object
+           | Array !Array
+           | String !Text
+           | Number !Scientific
+           | Bool !Bool
+           | Null
+             deriving (Eq, Show)
+
+instance NFData Value where
+    rnf (Object o) = rnf o
+    rnf (Array a)  = Vector.foldl' (\x y -> rnf y `seq` x) () a
+    rnf (String s) = rnf s
+    rnf (Number n) = rnf n
+    rnf (Bool b)   = rnf b
+    rnf Null       = ()
+
 -- | Parse a top-level JSON value.  This must be either an object or
 -- an array, per RFC 4627.
 --

File benchmarks/attoparsec-benchmarks.cabal

   hs-source-dirs: .. .
   ghc-options: -O2 -Wall
   build-depends:
-    aeson,
     array,
     base == 4.*,
     bytestring >= 0.10.4.0,