ekmett / hyperloglog

A constant-memory approximation of set membership
Other
24 stars 14 forks source link

Support less typish configuration situations #13

Closed treeowl closed 9 years ago

treeowl commented 9 years ago

Is there a good argument against providing something like this?

coerceConfig :: forall p q . (HLL.ReifiesConfig p, HLL.ReifiesConfig q) =>
                HLL.HyperLogLog p -> Maybe (HLL.HyperLogLog q)
coerceConfig hll
    | HLLC.reflectConfig (Proxy :: Proxy p) == HLLC.reflectConfig (Proxy :: Proxy q) =
        Just $ unsafeCoerce hll
    | otherwise = Nothing
treeowl commented 9 years ago

Also in that code, I think Config deserves a custom Eq instance, recognizing that the first field is sufficient, or at least seems to be. It might also be good to offer a serializable global configuration version constant somewhere.

treeowl commented 9 years ago

Fixed by #15