packages feed

special-keys 0.1.0.1 → 0.1.0.2

raw patch · 2 files changed

+24/−2 lines, 2 filesdep +aesonPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependencies added: aeson

API changes (from Hackage documentation)

+ Keys.Constraints: instance FromJSON Text1024
+ Keys.Constraints: instance FromJSON Text128
+ Keys.Constraints: instance FromJSON Text2048
+ Keys.Constraints: instance FromJSON Text256
+ Keys.Constraints: instance FromJSON Text4096
+ Keys.Constraints: instance FromJSON Text512
+ Keys.Constraints: instance ToJSON Text1024
+ Keys.Constraints: instance ToJSON Text128
+ Keys.Constraints: instance ToJSON Text2048
+ Keys.Constraints: instance ToJSON Text256
+ Keys.Constraints: instance ToJSON Text4096
+ Keys.Constraints: instance ToJSON Text512

Files

Keys/Constraints.hs view
@@ -18,11 +18,14 @@ import Data.Data import Data.String import Data.Monoid+import Control.Monad import Control.DeepSeq import Data.SafeCopy import Data.Serialize import Data.Text.Encoding import Data.Hashable+import Data.Aeson+import qualified Data.Aeson as Aeson  -- | Text with a maximum of 128 characters newtype Text128 = Text128 T.Text deriving(Eq, Data, Ord, Read, Show, Typeable, IsString, Monoid, NFData)@@ -88,6 +91,24 @@ instance SafeCopy Text4096 where putCopy (Text4096 t) = putCopy t                                  getCopy = contain $ Text4096 `fmap` safeGet +instance FromJSON Text128 where parseJSON (Aeson.String s) = return $ t128 s+                                parseJSON _ = mzero+instance FromJSON Text256 where parseJSON (Aeson.String s) = return $ t256 s+                                parseJSON _ = mzero+instance FromJSON Text512 where parseJSON (Aeson.String s) = return $ t512 s+                                parseJSON _ = mzero+instance FromJSON Text1024 where parseJSON (Aeson.String s) = return $ t1024 s+                                 parseJSON _ = mzero+instance FromJSON Text2048 where parseJSON (Aeson.String s) = return $ t2048 s+                                 parseJSON _ = mzero+instance FromJSON Text4096 where parseJSON (Aeson.String s) = return $ t4096 s+                                 parseJSON _ = mzero+instance ToJSON Text128 where toJSON s = Aeson.String (getTxt s)+instance ToJSON Text256 where toJSON s = Aeson.String (getTxt s)+instance ToJSON Text512 where toJSON s = Aeson.String (getTxt s)+instance ToJSON Text1024 where toJSON s = Aeson.String (getTxt s)+instance ToJSON Text2048 where toJSON s = Aeson.String (getTxt s)+instance ToJSON Text4096 where toJSON s = Aeson.String (getTxt s)  t128 :: T.Text -> Text128 t128 = Text128 . T.take 128
special-keys.cabal view
@@ -1,5 +1,5 @@ name:                special-keys-version:             0.1.0.1+version:             0.1.0.2 synopsis:            Simple data types that help me here and there.  description:         Datatypes that I use as keys to index other data types. Here you will find a wrap of UUID and also constraints on Text so that it never exceeds a given number of characters. license:             BSD3@@ -28,4 +28,5 @@                     primitive >= 0.5,                     bytestring >= 0.10,                     uuid >= 1.2,-                    mwc-random >= 0.12+                    mwc-random >= 0.12,+                    aeson >= 0.6.1.0