packages feed

extensible-data 0.1.0.3 → 0.1.0.4

raw patch · 2 files changed

+11/−18 lines, 2 filesdep ~hashabledep ~template-haskell

Dependency ranges changed: hashable, template-haskell

Files

Data/Extensible/Product.lhs view
@@ -37,22 +37,15 @@ ExtProd} type, which is used to tell what kind of record it is.
 
 > data ExtProd p where {
->   ExtProd :: p -> HashMap FieldSelector Any -> ExtProd p;
+>   ExtProd :: p -> HashMap TypeRep Any -> ExtProd p;
 > } deriving Typeable;
 
-This implements hashable type representations in private, so that it will
-not conflict with other modules.
-
-> newtype FieldSelector = FieldSelector TypeRep deriving Eq;
-
-> instance Hashable FieldSelector where {
->   hash (FieldSelector x) = hash (show x);
-> };
-
 Instances should ignore the value of the first parameter of the {\tt
 defaultExtProd} method; it is used only for knowing the type (so it will
 be OK to pass {\tt undefined} as the first parameter).
 
+The second parameter should be used to set default values.
+
 > class Typeable x => ExtProdC p x | x -> p where {
 >   type ExtProdF x :: *;
 >   defaultExtProd :: x -> p -> ExtProdF x;
@@ -80,13 +73,13 @@ 
 > getExtProd :: ExtProdC p x => ExtProd p -> x -> ExtProdF x;
 > getExtProd (ExtProd p m) f = unsafeCoerce $ H.lookupDefault
->  (unsafeCoerce $ defaultExtProd f p) (FieldSelector $ typeOf f) m;
+>  (unsafeCoerce $ defaultExtProd f p) (typeOf f) m;
 
 {\tt putExtProd}: Set the value of a field.
 
 > putExtProd :: ExtProdC p x => ExtProd p -> x -> ExtProdF x -> ExtProd p;
-> putExtProd (ExtProd p m) f v = ExtProd p $ H.insert
->  (FieldSelector $ typeOf f) (unsafeCoerce v) m;
+> putExtProd (ExtProd p m) f v = ExtProd p $ H.insert (typeOf f)
+>  (unsafeCoerce v) m;
 
 {\tt lensExtProd}: Make a lens of an extensible product type.
 
@@ -98,8 +91,8 @@ > constructExtProd :: p -> [ProdConstructor p] -> ExtProd p;
 > constructExtProd p l = ExtProd p $ H.fromList (constructorToKV <$> l);
 
-> constructorToKV :: ProdConstructor p -> (FieldSelector, Any);
-> constructorToKV (k :*= v) = (FieldSelector $ typeOf k, unsafeCoerce v);
+> constructorToKV :: ProdConstructor p -> (TypeRep, Any);
+> constructorToKV (k :*= v) = (typeOf k, unsafeCoerce v);
 
 % End of document (final "}" is suppressed from printout)
 \medskip\centerline{The End}
extensible-data.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy
 -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
 -- standards guiding when and how versions should be incremented.
-Version:             0.1.0.3
+Version:             0.1.0.4
 
 -- A short (one-line) description of the package.
 Synopsis:            Sums/products/lists/trees which can be extended in other modules
@@ -55,6 +55,6 @@   Build-depends:
     base >= 4.3 && < 5.0,
     data-lens >= 2.0.1 && < 2.2, 
-    hashable >= 1.0.1.1 && < 1.2,
-    template-haskell >= 2.5.0.0 && < 2.7,
+    hashable >= 1.1.2.3 && < 1.2,
+    template-haskell >= 2.5.0.0 && < 2.8,
     unordered-containers >= 0.1.4.6 && < 0.2