converter for Maybe type

This commit is contained in:
Scott R. Parish 2010-03-08 07:01:32 -06:00
parent 3c0b57db7c
commit 34599280f5

View file

@ -567,3 +567,9 @@ instance BsonConv [BsonDoc] where
toBson = BsonArray . List.map toBson toBson = BsonArray . List.map toBson
fromBson (BsonArray ss) = List.map fromBson ss fromBson (BsonArray ss) = List.map fromBson ss
fromBson _ = throwUnsupConv fromBson _ = throwUnsupConv
instance (BsonConv a) => BsonConv (Maybe a) where
toBson Nothing = BsonNull
toBson (Just a) = toBson a
fromBson BsonNull = Nothing
fromBson a = Just $ fromBson a