Permalink
Browse files

Document the Maybe instance for From/ToField

  • Loading branch information...
1 parent 1cee459 commit 4d255b8b11f7278329e98838b300fa037816cdfa @tibbe committed Nov 17, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 Data/Csv/Conversion.hs
View
@@ -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 #-}

0 comments on commit 4d255b8

Please sign in to comment.