Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Document the Maybe instance for From/ToField

  • Loading branch information...
commit 4d255b8b11f7278329e98838b300fa037816cdfa 1 parent 1cee459
@tibbe authored
Showing with 2 additions and 0 deletions.
  1. +2 −0  Data/Csv/Conversion.hs
View
2  Data/Csv/Conversion.hs
@@ -377,12 +377,14 @@ class FromField a where
class ToField a where
toField :: a -> Field
+-- | 'Nothing' if the field is empty, 'Just' otherwise.
instance FromField a => FromField (Maybe a) where
parseField s
| B.null s = pure Nothing
| otherwise = Just <$> parseField s
{-# INLINE parseField #-}
+-- | 'Nothing' is encoded as an empty field.
instance ToField a => ToField (Maybe a) where
toField = maybe B.empty toField
{-# INLINE toField #-}
Please sign in to comment.
Something went wrong with that request. Please try again.