rest-types 1.9.0.2 → 1.10
raw patch · 4 files changed
+15/−44 lines, 4 filesdep +rest-stringmapdep −tostring
Dependencies added: rest-stringmap
Dependencies removed: tostring
Files
- CHANGELOG.md +5/−0
- rest-types.cabal +4/−3
- src/Rest/Types/Container.hs +3/−37
- src/Rest/Types/Container/Resource.hs +3/−4
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Changelog++## 1.10++* Removed `Rest.Container.StringMap` in favor of `rest-stringmap`. `KeyValues` is now an alias for `Rest.StringMap.HashMap.Strict String Value`.
rest-types.cabal view
@@ -1,5 +1,5 @@ Name: rest-types-Version: 1.9.0.2+Version: 1.10 Description: Silk Rest Framework Types Synopsis: Silk Rest Framework Types Maintainer: code@silk.co@@ -9,11 +9,12 @@ License: BSD3 License-File: LICENSE +Extra-Source-Files: CHANGELOG.md+ Library GHC-Options: -Wall Hs-Source-Dirs: src Build-Depends:- base == 4.* , aeson >= 0.7 && < 0.8 , bytestring >= 0.9 && < 0.11@@ -24,8 +25,8 @@ , mtl >= 2.0 && < 2.2 , regular == 0.3.* , regular-xmlpickler == 0.2.*+ , rest-stringmap == 0.1.* , text >= 0.11 && < 1.2- , tostring == 0.2.* , unordered-containers == 0.2.* , utf8-string == 0.3.* , uuid >= 1.2 && < 1.4
src/Rest/Types/Container.hs view
@@ -15,20 +15,13 @@ #-} module Rest.Types.Container ( List(..)- , StringMap(..)- , fromStringMap- , toStringMap , SomeOutput(..) ) where -import Control.Applicative-import Data.Aeson+import Prelude hiding (mapM)++import Data.Aeson.Types import Data.JSON.Schema hiding (Object, Value)-import Data.JSON.Schema.Combinators (field)-import Data.Map (Map)-import Data.String-import Data.String.ToString-import Data.Text (pack, unpack) import Data.Typeable import GHC.Generics import Generics.Generic.Aeson@@ -37,8 +30,6 @@ import Text.XML.HXT.Arrow.Pickle import Text.XML.HXT.Arrow.Pickle.Schema import Text.XML.HXT.Arrow.Pickle.Xml-import qualified Data.HashMap.Strict as H-import qualified Data.Map as M ------------------------------------------------------------------------------- @@ -55,31 +46,6 @@ instance ToJSON a => ToJSON (List a) where toJSON = gtoJson instance FromJSON a => FromJSON (List a) where parseJSON = gparseJson instance JSONSchema a => JSONSchema (List a) where schema = gSchema-----------------------------------------------------------------------------------newtype StringMap a b = StringMap { unMap :: [(a, b)] } deriving (Show, Typeable)--deriveAll ''StringMap "PFStringMap"-type instance PF (StringMap a b) = PFStringMap a b--instance (IsString a, ToString a, XmlPickler b) => XmlPickler (StringMap a b) where- xpickle = xpElem "map" (xpWrap (StringMap, unMap) (xpList (xpPair (xpElem "key" (xpWrap (fromString,toString) xpText)) xpickle)))--instance (ToString a, ToJSON b) => ToJSON (StringMap a b) where- toJSON = toJSON . Object . H.fromList . map (\(a,b) -> pack (toString a) .= b) . unMap--instance (IsString a, FromJSON b) => FromJSON (StringMap a b) where- parseJSON = withObject "StringMap" (fmap StringMap . mapM (\(k,v) -> (fromString . unpack $ k,) <$> parseJSON v) . H.toList)--instance (IsString a, ToString a, JSONSchema b) => JSONSchema (StringMap a b) where- schema _ = field "key" False (schema (Proxy :: Proxy b))--fromStringMap :: (Ord a, IsString a, ToString a) => StringMap a b -> Map a b-fromStringMap = M.fromList . unMap--toStringMap :: (Ord a, IsString a, ToString a) => Map a b -> StringMap a b-toStringMap = StringMap . M.toList -------------------------------------------------------------------------------
src/Rest/Types/Container/Resource.hs view
@@ -1,9 +1,9 @@ {-# LANGUAGE DeriveDataTypeable , DeriveGeneric+ , EmptyDataDecls , TemplateHaskell , TypeFamilies- , EmptyDataDecls #-} module Rest.Types.Container.Resource ( Resource (..)@@ -20,12 +20,11 @@ import Generics.Generic.Aeson import Generics.Regular (PF, deriveAll) import Generics.Regular.XmlPickler (gxpickle)+import Rest.StringMap.HashMap.Strict (StringHashMap) import Text.XML.HXT.Arrow.Pickle import qualified Data.JSON.Schema as Json -import Rest.Types.Container--type KeyValues = StringMap String Value+type KeyValues = StringHashMap String Value newtype Value = Value { unValue :: String } deriving (Show, Typeable)