happstack-ixset 0.3.2 → 0.4.1
raw patch · 2 files changed
+32/−7 lines, 2 filesdep ~happstack-datadep ~happstack-utildep ~syb-with-classnew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: happstack-data, happstack-util, syb-with-class
API changes (from Hackage documentation)
Files
- happstack-ixset.cabal +10/−4
- src/Happstack/Data/IxSet.hs +22/−3
happstack-ixset.cabal view
@@ -1,5 +1,5 @@ Name: happstack-ixset-Version: 0.3.2+Version: 0.4.1 Synopsis: Efficient relational queries on Haskell sets. Description: Just pick which parts of your data structures you want indexed using an easy to use template-haskell function. Spare yourself the need to write, run, and maintain code that marshalls your data to/from an external relational database just for efficient queries. happstack-ixset relies on generics and TH to spare you the boilerplate normally required for such tasks. License: BSD3@@ -14,7 +14,7 @@ source-repository head type: darcs subdir: happstack-ixset- location: http://patch-tag.com/publicrepos/happstack+ location: http://patch-tag.com/r/mae/happstack/pullrepo flag base4 @@ -28,9 +28,15 @@ else Build-Depends: base < 4 + if impl(ghc >= 6.12.1)+ Build-Depends: syb-with-class >= 0.6.1+ else+ Build-Depends: syb-with-class < 0.6.1++ Build-Depends: containers,- happstack-data >= 0.3.2 && < 0.4,- happstack-util >= 0.3.2 && < 0.4,+ happstack-data >= 0.4.1 && < 0.5,+ happstack-util >= 0.4.1 && < 0.5, mtl, syb-with-class, template-haskell
src/Happstack/Data/IxSet.hs view
@@ -168,16 +168,26 @@ @$(inferIxSet "FooDB" ''Foo 'noCalcs [''Int,''String])@ will build a type synonym @type FooDB = IxSet Foo@ with @Int@ and @String@ as indexes.++ WARNING: The type specified as the first index must be a type which+ appears in all values in the 'IxSet' or 'toList' and 'toSet' will+ not function properly. You can always use the element type+ itself. For example, + @$(inferIxSet "FooDB" ''Foo 'noCalcs [''Foo, ''Int,''String])@+ -} inferIxSet :: String -> TH.Name -> TH.Name -> [TH.Name] -> Q [Dec] inferIxSet ixset typeName calName entryPoints = do calInfo <- reify calName typeInfo <- reify typeName- let (context,names) = case typeInfo of+ let (context,binders) = case typeInfo of TyConI (DataD ctxt _ nms _ _) -> (ctxt,nms) TyConI (NewtypeD ctxt _ nms _ _) -> (ctxt,nms) TyConI (TySynD _ nms _) -> ([],nms) _ -> error "unexpected match"++ names = map tyVarBndrToName binders+ typeCon = foldl appT (conT typeName) (map varT names) case calInfo of VarI _ t _ _ ->@@ -185,7 +195,7 @@ getCalType (ForallT _names _ t') = getCalType t' getCalType (AppT (AppT ArrowT _) t') = t' getCalType t' = error ("Unexpected type: " ++ pprint t')- mkEntryPoint n = appE (conE 'Ix) (sigE (varE 'Map.empty) (forallT names (return context) $+ mkEntryPoint n = appE (conE 'Ix) (sigE (varE 'Map.empty) (forallT binders (return context) $ appT (appT (conT ''Map) (conT n)) (appT (conT ''Set) typeCon))) in do i <- instanceD' (return context) (appT (appT (conT ''Indexable) typeCon) (return calType)) [d| empty :: IxSet a@@ -193,9 +203,18 @@ calcs :: a -> b calcs = $(varE calName) |] let ixType = appT (conT ''IxSet) typeCon- ixType' <- tySynD (mkName ixset) names ixType+ ixType' <- tySynD (mkName ixset) binders ixType return $ [i, ixType'] -- ++ d _ -> error "unexpected match"++#if MIN_VERSION_template_haskell(2,4,0)+tyVarBndrToName (PlainTV nm) = nm+tyVarBndrToName (KindedTV nm _) = nm+#else+tyVarBndrToName = id+#endif++ -- modification operations