From 34599280f5caeb0a565370f8a369eb3c8588df5a Mon Sep 17 00:00:00 2001 From: "Scott R. Parish" Date: Mon, 8 Mar 2010 07:01:32 -0600 Subject: [PATCH] converter for Maybe type --- Database/MongoDB/BSON.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Database/MongoDB/BSON.hs b/Database/MongoDB/BSON.hs index 22a820a..5793c2d 100644 --- a/Database/MongoDB/BSON.hs +++ b/Database/MongoDB/BSON.hs @@ -567,3 +567,9 @@ instance BsonConv [BsonDoc] where toBson = BsonArray . List.map toBson fromBson (BsonArray ss) = List.map fromBson ss 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