bson-mapping 0.1.2 → 0.1.3
raw patch · 2 files changed
+6/−4 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- bson-mapping.cabal +2/−2
- src/Data/Bson/Mapping.hs +4/−2
bson-mapping.cabal view
@@ -1,10 +1,10 @@ Name: bson-mapping-Version: 0.1.2+Version: 0.1.3 License: OtherLicense License-File: LICENSE Author: Francesco Mazzoli <f@mazzo.li> Maintainer: Francesco Mazzoli <f@mazzo.li>-homepage: +homepage: Stability: experimental Category: Data Synopsis: Mapping between BSON and algebraic data types.
src/Data/Bson/Mapping.hs view
@@ -13,13 +13,14 @@ > import Data.Bson.Mapping > import Data.Time.Clock+> import Data.Data (Data, Typeable) > > data Post = Post { time :: UTCTime > , author :: String > , content :: String > , votes :: Int > }-> deriving (Show, Read, Eq, Ord)+> deriving (Show, Read, Eq, Ord, Data, Typeable) > $(deriveBson ''Post) > > main :: IO ()@@ -140,10 +141,11 @@ deriveFromBson conss = do con <- newName "con" docN <- newName "doc"+ (SigE _ (ConT strtype)) <- runQ [| "" :: String |] let doc = varE docN lamE [varP docN] $ doE [ bindS (varP con) [| lookup consField $doc |]- , noBindS $ caseE (varE con) (map (genMatch doc) conss ++ noMatch)+ , noBindS $ caseE (sigE (varE con) (conT strtype)) (map (genMatch doc) conss ++ noMatch) ] noMatch = [match [p| _ |] (normalB [| fail "Couldn't find right constructor" |]) []]