Skip to content
Browse files

Add support for Data.Map and fix up .cabal file

  • Loading branch information...
1 parent 03ba86d commit dc966714910e9b532f2cb3ba3629c27402f49bc9 @lpsmith committed Feb 25, 2011
Showing with 9 additions and 2 deletions.
  1. +4 −2 json-builder.cabal
  2. +5 −0 src/Json.hs
View
6 json-builder.cabal
@@ -17,9 +17,11 @@ Library
Exposed-modules: Json
-- Packages needed in order to build this package.
- Build-depends: base,
+ Build-depends: base >= 4 && < 5,
+ blaze-builder,
bytestring,
- blaze-builder
+ containers,
+ utf8-string
-- Modules not exported by this package.
-- Other-modules:
View
5 src/Json.hs
@@ -11,6 +11,7 @@
-----------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE BangPatterns #-}
module Json
@@ -31,6 +32,7 @@ import qualified Data.ByteString.UTF8 as BU
import Data.ByteString.Char8()
import Data.ByteString.Internal (w2c, c2w)
import qualified Data.Char as Char
+import qualified Data.Map as Map
import Data.Word (Word16, Word8)
import Data.Bits (shiftL, shiftR)
@@ -155,3 +157,6 @@ instance Value a => Value (Maybe a) where
instance Value a => Value [a] where
toBuilder = toBuilder . mconcat . map element
+
+instance Value a => Value (Map.Map BS.ByteString a) where
+ toBuilder = toBuilder . Map.foldWithKey (\k a b -> row k a `mappend` b) mempty

0 comments on commit dc96671

Please sign in to comment.
Something went wrong with that request. Please try again.