packages feed

cassava 0.4.1.0 → 0.4.2.0

raw patch · 2 files changed

+63/−9 lines, 2 filesdep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: text

API changes (from Hackage documentation)

Files

Data/Csv/Conversion.hs view
@@ -108,7 +108,7 @@ -- >         | otherwise     = mzero class FromRecord a where     parseRecord :: Record -> Parser a-  + #ifdef GENERICS     default parseRecord :: (Generic a, GFromRecord (Rep a)) => Record -> Parser a     parseRecord r = to <$> gparseRecord r@@ -253,6 +253,53 @@         toField a, toField b, toField c, toField d, toField e, toField f,         toField g] +instance (FromField a, FromField b, FromField c, FromField d, FromField e,+          FromField f, FromField g, FromField h) =>+         FromRecord (a, b, c, d, e, f, g, h) where+    parseRecord v+        | n == 8    = (,,,,,,,) <$> unsafeIndex v 0+                                <*> unsafeIndex v 1+                                <*> unsafeIndex v 2+                                <*> unsafeIndex v 3+                                <*> unsafeIndex v 4+                                <*> unsafeIndex v 5+                                <*> unsafeIndex v 6+                                <*> unsafeIndex v 7+        | otherwise = lengthMismatch 8 v+          where+            n = V.length v++instance (ToField a, ToField b, ToField c, ToField d, ToField e, ToField f,+          ToField g, ToField h) =>+         ToRecord (a, b, c, d, e, f, g, h) where+    toRecord (a, b, c, d, e, f, g, h) = V.fromList [+        toField a, toField b, toField c, toField d, toField e, toField f,+        toField g, toField h]++instance (FromField a, FromField b, FromField c, FromField d, FromField e,+          FromField f, FromField g, FromField h, FromField i) =>+         FromRecord (a, b, c, d, e, f, g, h, i) where+    parseRecord v+        | n == 9    = (,,,,,,,,) <$> unsafeIndex v 0+                                 <*> unsafeIndex v 1+                                 <*> unsafeIndex v 2+                                 <*> unsafeIndex v 3+                                 <*> unsafeIndex v 4+                                 <*> unsafeIndex v 5+                                 <*> unsafeIndex v 6+                                 <*> unsafeIndex v 7+                                 <*> unsafeIndex v 8+        | otherwise = lengthMismatch 9 v+          where+            n = V.length v++instance (ToField a, ToField b, ToField c, ToField d, ToField e, ToField f,+          ToField g, ToField h, ToField i) =>+         ToRecord (a, b, c, d, e, f, g, h, i) where+    toRecord (a, b, c, d, e, f, g, h, i) = V.fromList [+        toField a, toField b, toField c, toField d, toField e, toField f,+        toField g, toField h, toField i]+ lengthMismatch :: Int -> Record -> Parser a lengthMismatch expected v =     fail $ "cannot unpack array of length " ++@@ -636,11 +683,18 @@ parseOnly :: A8.Parser a -> B.ByteString -> Either String a parseOnly parser input = go (A8.parse parser input) where   go (A8.Fail _ _ err) = Left err-  go (A8.Partial f)    = go (f B.empty)+  go (A8.Partial f)    = go2 (f B.empty)   go (A8.Done leftover result)     | B.null leftover = Right result     | otherwise = Left ("incomplete field parse, leftover: "                         ++ show (B.unpack leftover))++  go2 (A8.Fail _ _ err) = Left err+  go2 (A8.Partial _)    = error "parseOnly: impossible error!"+  go2 (A8.Done leftover result)+    | B.null leftover = Right result+    | otherwise = Left ("incomplete field parse, leftover: "+                        ++ show (B.unpack leftover)) {-# INLINE parseOnly #-}  typeError :: String -> B.ByteString -> Maybe String -> Parser a@@ -797,9 +851,9 @@     gparseRecord :: Record -> Parser (f p)  instance GFromRecordSum f Record => GFromRecord (M1 i n f) where-    gparseRecord v = +    gparseRecord v =         case (IM.lookup n gparseRecordSum) of-            Nothing -> lengthMismatch n v +            Nothing -> lengthMismatch n v             Just p -> M1 <$> p v       where         n = V.length v@@ -808,15 +862,15 @@     gparseNamedRecord :: NamedRecord -> Parser (f p)  instance GFromRecordSum f NamedRecord => GFromNamedRecord (M1 i n f) where-    gparseNamedRecord v = +    gparseNamedRecord v =         foldr (\f p -> p <|> M1 <$> f v) empty (IM.elems gparseRecordSum)  class GFromRecordSum f r where     gparseRecordSum :: IM.IntMap (r -> Parser (f p))  instance (GFromRecordSum a r, GFromRecordSum b r) => GFromRecordSum (a :+: b) r where-    gparseRecordSum = -        IM.unionWith (\a b r -> a r <|> b r) +    gparseRecordSum =+        IM.unionWith (\a b r -> a r <|> b r)             (fmap (L1 <$>) <$> gparseRecordSum)             (fmap (R1 <$>) <$> gparseRecordSum) 
cassava.cabal view
@@ -1,5 +1,5 @@ Name:                cassava-Version:             0.4.1.0+Version:             0.4.2.0 Synopsis:            A CSV parsing and encoding library Description:   A CSV parsing and encoding library optimized for ease of use and high@@ -42,7 +42,7 @@     bytestring < 0.11,     containers < 0.6,     deepseq < 1.4,-    text < 1.2,+    text < 1.3,     unordered-containers < 0.3,     vector < 0.11