json-bytes-builder 0.2.1.1 → 0.2.1.2
raw patch · 2 files changed
+77/−2 lines, 2 filesdep +json-bytes-builderdep ~base-preludedep ~bytestringdep ~textPVP ok
version bump matches the API change (PVP)
Dependencies added: json-bytes-builder
Dependency ranges changed: base-prelude, bytestring, text
API changes (from Hackage documentation)
Files
- demo/Main.hs +52/−0
- json-bytes-builder.cabal +25/−2
+ demo/Main.hs view
@@ -0,0 +1,52 @@+{-# LANGUAGE NoImplicitPrelude #-}++import BasePrelude+import Data.ByteString (ByteString)+import Data.Text (Text)+import qualified JSONBytesBuilder.Builder as A+import qualified JSONBytesBuilder.Interpreters.ByteString as B+import qualified Data.ByteString.Char8 as C+++-- |+-- Outputs the following:+-- +-- >{"name":"Metallica","genres":[{"name":"Metal"},{"name":"Rock"},{"name":"Blues"}]}+main =+ C.putStrLn (B.compactJSON metallica)+++-- * Model+-------------------------++data Artist =+ Artist { artist_name :: Text, artist_genres :: [Genre] }++data Genre =+ Genre { genre_name :: Text }+++-- * Builders+-------------------------++artist :: Artist -> A.JSON+artist (Artist name genres) =+ A.object rows+ where+ rows =+ A.row "name" (A.string name) <>+ A.row "genres" (A.array genresElements)+ where+ genresElements =+ foldMap (A.element . genre) genres++genre :: Genre -> A.JSON+genre (Genre name) =+ A.object rows+ where+ rows =+ A.row "name" (A.string name)++metallica :: A.JSON+metallica =+ artist (Artist "Metallica" [Genre "Metal", Genre "Rock", Genre "Blues"])
json-bytes-builder.cabal view
@@ -1,12 +1,15 @@ name: json-bytes-builder version:- 0.2.1.1+ 0.2.1.2 synopsis: Direct-to-bytes JSON Builder description: An API for encoding of arbitrary data-structures into JSON byte-arrays,- which is faster than \"aeson\".+ which is faster and simpler than \"aeson\".+ .+ Check out+ <http://hackage.haskell.org/package/json-bytes-builder-0.2.1.2/src/demo/Main.hs the demo>. category: JSON, Codecs homepage:@@ -60,3 +63,23 @@ base-prelude < 2, base >= 4.7 && < 5 ++-- Well, it's not a benchmark actually, +-- but Cabal provides no better way to specify an executable, +-- which is not intended for distribution.+benchmark demo+ type: + exitcode-stdio-1.0+ hs-source-dirs:+ demo+ main-is:+ Main.hs+ default-extensions:+ Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+ default-language:+ Haskell2010+ build-depends:+ json-bytes-builder,+ text,+ bytestring,+ base-prelude