Permalink
Browse files

Add note about failing on invalid UTF-8

  • Loading branch information...
1 parent f5e9c01 commit e35f987f6cb7d7fba2c697463458e4c16273761f @tibbe committed Feb 26, 2013
Showing with 3 additions and 4 deletions.
  1. +3 −4 Data/Csv/Conversion.hs
View
@@ -575,8 +575,7 @@ instance ToField L.ByteString where
toField = toStrict
{-# INLINE toField #-}
--- TODO: Add comment about failure on invalid UTF-8 data.
--- | Assumes UTF-8 encoding.
+-- | Assumes UTF-8 encoding. Fails on invalid byte sequences.
instance FromField T.Text where
parseField = either (fail . show) pure . T.decodeUtf8'
{-# INLINE parseField #-}
@@ -586,7 +585,7 @@ instance ToField T.Text where
toField = toField . T.encodeUtf8
{-# INLINE toField #-}
--- | Assumes UTF-8 encoding.
+-- | Assumes UTF-8 encoding. Fails on invalid byte sequences.
instance FromField LT.Text where
parseField = either (fail . show) (pure . LT.fromStrict) . T.decodeUtf8'
{-# INLINE parseField #-}
@@ -596,7 +595,7 @@ instance ToField LT.Text where
toField = toField . toStrict . LT.encodeUtf8
{-# INLINE toField #-}
--- | Assumes UTF-8 encoding.
+-- | Assumes UTF-8 encoding. Fails on invalid byte sequences.
instance FromField [Char] where
parseField = fmap T.unpack . parseField
{-# INLINE parseField #-}

0 comments on commit e35f987

Please sign in to comment.