repa-convert 4.2.3.2 → 4.2.4.0
raw patch · 4 files changed
+36/−35 lines, 4 filesdep ~basedep ~bytestringdep ~primitivesetup-changednew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, bytestring, primitive, repa-scalar, text, vector
API changes (from Hackage documentation)
- Data.Repa.Convert: type family Value f;
- Data.Repa.Convert.Format: type family Value f;
- Data.Repa.Convert.Formats: data (:*:) a b :: * -> * -> *
- Data.Repa.Convert.Formats: type family FormatAscii' a;
+ Data.Repa.Convert: -- | Get the type of a value with this format.
+ Data.Repa.Convert: type Value f;
+ Data.Repa.Convert.Format: -- | Get the type of a value with this format.
+ Data.Repa.Convert.Format: type Value f;
+ Data.Repa.Convert.Formats: -- | The format for values of this type.
+ Data.Repa.Convert.Formats: data () => a :*: b
+ Data.Repa.Convert.Formats: infixr 9 :*:
+ Data.Repa.Convert.Formats: type FormatAscii' a;
- Data.Repa.Convert: class Format f where type Value f where {
+ Data.Repa.Convert: class Format f where {
- Data.Repa.Convert: class Format format => Packable format where pack format value = Packer (packer format value)
+ Data.Repa.Convert: class Format format => Packable format
- Data.Repa.Convert: class Format format => Unpackable format where unpack format = Unpacker (unpacker format)
+ Data.Repa.Convert: class Format format => Unpackable format
- Data.Repa.Convert.Format: class Format f where type Value f where {
+ Data.Repa.Convert.Format: class Format f where {
- Data.Repa.Convert.Format: class Format format => Packable format where pack format value = Packer (packer format value)
+ Data.Repa.Convert.Format: class Format format => Packable format
- Data.Repa.Convert.Format: class Format format => Unpackable format where unpack format = Unpacker (unpacker format)
+ Data.Repa.Convert.Format: class Format format => Unpackable format
- Data.Repa.Convert.Formats: (:*:) :: ~a -> ~b -> (:*:) a b
+ Data.Repa.Convert.Formats: (:*:) :: !a -> !b -> (:*:) a b
- Data.Repa.Convert.Formats: class FormatAscii a where type FormatAscii' a where {
+ Data.Repa.Convert.Formats: class FormatAscii a where {
Files
- Data/Repa/Convert/Format/Object.hs +19/−20
- Data/Repa/Convert/Internal/Packer.hs +7/−4
- Setup.hs +0/−2
- repa-convert.cabal +10/−9
Data/Repa/Convert/Format/Object.hs view
@@ -12,7 +12,6 @@ import Data.Repa.Convert.Format.String import Data.Repa.Convert.Format.Binary import Data.Repa.Scalar.Product-import Data.Monoid import Data.Word import Data.Char import GHC.Exts@@ -30,16 +29,16 @@ -- | Resents the fields of a JSON object. data ObjectFields fields where - ObjectFieldsNil + ObjectFieldsNil :: ObjectFields () - ObjectFieldsCons + ObjectFieldsCons :: {-# UNPACK #-} !ObjectMeta -- Meta data about this format. -> !Text -- Name of head field -> !f -- Format of head field. -> Maybe (Value f -> Bool) -- Predicate to determine whether to emit value. -> ObjectFields fs -- Spec for rest of fields.- -> ObjectFields (f :*: fs) + -> ObjectFields (f :*: fs) -- | Precomputed information about this format.@@ -58,9 +57,9 @@ --------------------------------------------------------------------------------------------------- -- | Make an object format with the given labeled fields. For example: ----- @> let fmt = mkObject +-- @> let fmt = mkObject -- $ Field "index" IntAsc Nothing--- :*: Field "message" (VarCharString \'-\') Nothing +-- :*: Field "message" (VarCharString \'-\') Nothing -- :*: Field "value" (MaybeChars "NULL" DoubleAsc) (Just isJust) -- :*: () -- @@@ -71,14 +70,14 @@ -- > let Just str = packToString fmt (27 :*: "foo" :*: Nothing :*: ()) -- > putStrLn str -- > {"index":27,"message":"foo"}--- @ +-- @ -- -- Note that the encodings that this format can generate are a superset of -- the JavaScript Object Notation (JSON). With the Repa format, the fields -- of an object can directly encode dates and other values, wheras in JSON -- these values must be represented by strings. ---mkObject :: ObjectFormat f +mkObject :: ObjectFormat f => f -> Object (ObjectFormat' f) mkObject f = Object (mkObjectFields f)@@ -97,7 +96,7 @@ -- | A single field in an object. data Field f- = Field + = Field { fieldName :: String , fieldFormat :: f , fieldInclude :: Maybe (Value f -> Bool) }@@ -107,14 +106,14 @@ , ObjectFormat fs) => ObjectFormat (Field f1 :*: fs) where - type ObjectFormat' (Field f1 :*: fs) + type ObjectFormat' (Field f1 :*: fs) = f1 :*: ObjectFormat' fs - mkObjectFields (Field label f1 mKeep :*: fs) + mkObjectFields (Field label f1 mKeep :*: fs) = case mkObjectFields fs of ObjectFieldsNil -> ObjectFieldsCons- (ObjectMeta + (ObjectMeta { omFieldCount = 1 -- Smallest JSON object looks like:@@ -126,7 +125,7 @@ cc@(ObjectFieldsCons jm _ _ _ _) -> ObjectFieldsCons- (ObjectMeta + (ObjectMeta { omFieldCount = 1 + omFieldCount jm -- Adding a new field makes the object look like:@@ -146,18 +145,18 @@ instance ( Format (ObjectFields fs) , Value (ObjectFields fs) ~ Value fs) => Format (Object fs) where- type Value (Object fs) + type Value (Object fs) = Value fs - fieldCount (Object _) + fieldCount (Object _) = 1 {-# INLINE fieldCount #-} - minSize (Object fs) + minSize (Object fs) = 2 + minSize fs {-# INLINE minSize #-} - fixedSize (Object fs) + fixedSize (Object fs) = do sz <- fixedSize fs return (2 + sz) {-# INLINE fixedSize #-}@@ -226,7 +225,7 @@ , Value (ObjectFields f) ~ Value f , Packable (ObjectFields f)) => Packable (Object f) where- + pack (Object fs) xs = pack Word8be (w8 $ ord '{') <> pack fs xs@@ -260,11 +259,11 @@ , Value (ObjectFields fs) ~ Value fs) => Packable (ObjectFields (f1 :*: f2 :*: fs)) where - -- Pack a field into the object, + -- Pack a field into the object, -- only keeping it if the keep flag is true. pack (ObjectFieldsCons _jm l1 f1 mKeep jfs) (x1 :*: xs) = if (case mKeep of- Just keep -> keep x1 + Just keep -> keep x1 _ -> True) then here else rest
Data/Repa/Convert/Internal/Packer.hs view
@@ -13,7 +13,7 @@ data Packer = Packer { -- | Takes start of buffer; failure action; and a continuation.- -- + -- -- We try to pack data into the given buffer. -- If packing succeeds then we call the continuation with a pointer -- to the next byte after the packed value,@@ -26,9 +26,12 @@ -> IO () } +instance Semigroup Packer where+ (<>) = mappend + instance Monoid Packer where- mempty + mempty = Packer $ \buf _fail k -> k buf {-# INLINE mempty #-} @@ -38,12 +41,12 @@ -- | Pack data into the given buffer.--- +-- -- PRECONDITION: The buffer needs to be big enough to hold the packed data, -- otherwise you'll corrupt the heap (bad). Use `packedSize` to work out -- how big it needs to be. ---unsafeRunPacker +unsafeRunPacker :: Packer -- ^ Packer to run. -> F.Ptr Word8 -- ^ Start of buffer. -> IO (Maybe (F.Ptr Word8))
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
repa-convert.cabal view
@@ -1,11 +1,11 @@+Cabal-Version: 1.18 Name: repa-convert-Version: 4.2.3.2+Version: 4.2.4.0 License: BSD3 License-file: LICENSE Author: The Repa Development Team Maintainer: Ben Lippmeier <benl@ouroborus.net> Build-Type: Simple-Cabal-Version: >=1.6 Stability: experimental Category: Data Structures Homepage: http://repa.ouroborus.net@@ -18,14 +18,15 @@ location: https://github.com/DDCSF/repa.git Library+ default-language: Haskell2010 build-Depends:- base >= 4.9 && < 4.11,- primitive >= 0.6 && < 0.8,- vector >= 0.10 && < 0.13,- bytestring == 0.10.*,- text == 1.2.*,+ base >= 4.9 && < 4.21,+ primitive >= 0.6 && <0.10,+ vector >= 0.1 && <0.14,+ bytestring >= 0.10 && <0.13,+ text >= 1.2 && <2.2, double-conversion == 2.0.*,- repa-scalar == 4.2.3.*+ repa-scalar == 4.2.* exposed-modules: Data.Repa.Convert.Format@@ -62,7 +63,7 @@ -Wall -fno-warn-missing-signatures -O2 - extensions:+ default-extensions: CPP GADTs MagicHash