Scalar changes in data-object

This commit is contained in:
Michael Snoyman 2009-09-24 01:28:38 +03:00
parent b7c07c88ad
commit 5addbf8465
2 changed files with 5 additions and 5 deletions

View File

@ -21,7 +21,6 @@ module Data.Object.Instances
import Data.Object import Data.Object
import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString as BS
import Data.ByteString.Class import Data.ByteString.Class
import Web.Encodings (encodeJson) import Web.Encodings (encodeJson)
import Text.Yaml (encode) import Text.Yaml (encode)
@ -35,7 +34,7 @@ instance SafeFromObject Json where
helper :: Object -> B.ByteString helper :: Object -> B.ByteString
helper (Scalar s) = B.concat helper (Scalar s) = B.concat
[ toLazyByteString "\"" [ toLazyByteString "\""
, encodeJson $ fromStrictByteString s , encodeJson $ fromLazyByteString s
, toLazyByteString "\"" , toLazyByteString "\""
] ]
helper (Sequence s) = B.concat helper (Sequence s) = B.concat
@ -48,10 +47,10 @@ instance SafeFromObject Json where
, B.intercalate (toLazyByteString ",") $ map helper2 m , B.intercalate (toLazyByteString ",") $ map helper2 m
, toLazyByteString "}" , toLazyByteString "}"
] ]
helper2 :: (BS.ByteString, Object) -> B.ByteString helper2 :: (B.ByteString, Object) -> B.ByteString
helper2 (k, v) = B.concat helper2 (k, v) = B.concat
[ toLazyByteString "\"" [ toLazyByteString "\""
, encodeJson $ fromStrictByteString k , encodeJson $ fromLazyByteString k
, toLazyByteString "\":" , toLazyByteString "\":"
, helper v , helper v
] ]
@ -89,7 +88,7 @@ instance SafeFromObject Html where
toLazyByteString "<dl>" : toLazyByteString "<dl>" :
map helper2 m ++ map helper2 m ++
[ toLazyByteString "</dl>" ] [ toLazyByteString "</dl>" ]
helper2 :: (BS.ByteString, Object) -> B.ByteString helper2 :: (B.ByteString, Object) -> B.ByteString
helper2 (k, v) = B.concat $ helper2 (k, v) = B.concat $
[ toLazyByteString "<dt>" [ toLazyByteString "<dt>"
, toLazyByteString k , toLazyByteString k

View File

@ -1,4 +1,5 @@
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Response -- Module : Web.Restful.Response