diff --git a/Data/Csv/Streaming.hs b/Data/Csv/Streaming.hs index 51c98fc..e8e94d5 100644 --- a/Data/Csv/Streaming.hs +++ b/Data/Csv/Streaming.hs @@ -106,6 +106,7 @@ foldrRecords :: (a -> b -> b) -> b -> Records a -> b foldrRecords f = go where go z (Cons (Right x) rs) = f x (go z rs) + go z (Cons (Left _) rs) = go z rs go z _ = z {-# INLINE foldrRecords #-} diff --git a/tests/UnitTests.hs b/tests/UnitTests.hs index daa8c42..474940a 100644 --- a/tests/UnitTests.hs +++ b/tests/UnitTests.hs @@ -13,6 +13,7 @@ import Data.Int import qualified Data.Text as T import qualified Data.Text.Lazy as LT import qualified Data.Vector as V +import qualified Data.Foldable as F import Data.Word import Test.HUnit import Test.Framework as TF @@ -361,6 +362,21 @@ customOptionsTests = [ testProperty "customDelim" customDelim ] +------------------------------------------------------------------------ +-- Instance tests + +instanceTests :: [TF.Test] +instanceTests = + [ + testGroup "Records instances" + [ testCase "foldr Foldable" (expected @=? F.foldr (:) [] input) + ] + ] + where + input = S.Cons (Left "empty") ( + S.Cons (Right ("a" :: String)) (S.Nil Nothing BL8.empty)) + expected = ["a" :: String] + ------------------------------------------------------------------------ -- Test harness @@ -369,6 +385,7 @@ allTests = [ testGroup "positional" positionalTests , testGroup "named" nameBasedTests , testGroup "conversion" conversionTests , testGroup "custom-options" customOptionsTests + , testGroup "instances" instanceTests ] main :: IO ()