hyperloglog 0.2.3.2 → 0.2.3.3
raw patch · 3 files changed
+44/−13 lines, 3 filesdep ~lens
Dependency ranges changed: lens
Files
- hyperloglog.cabal +2/−2
- src/Data/HyperLogLog/Config.hs +37/−9
- src/Data/HyperLogLog/Type.hs +5/−2
hyperloglog.cabal view
@@ -1,6 +1,6 @@ name: hyperloglog category: Numeric-version: 0.2.3.2+version: 0.2.3.3 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -61,7 +61,7 @@ generic-deriving >= 1.4 && < 1.7, hashable >= 1.1.2.3 && < 1.3, hashable-extras >= 0.1 && < 1,- lens >= 4 && < 5,+ lens >= 4 && < 4.5, reflection >= 1.3 && < 2, semigroupoids >= 4 && < 5, semigroups >= 0.8.4 && < 1,
src/Data/HyperLogLog/Config.hs view
@@ -8,7 +8,6 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-}@@ -18,12 +17,20 @@ {-# OPTIONS_GHC -fno-float-in #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 707+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 705 {-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} #define USE_TYPE_LITS 1 #endif +#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 707+#define USE_NEW_TYPE_LITS 1+#endif++#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 705 && __GLASGOW_HASKELL__ < 707+#define USE_OLD_TYPE_LITS 1+#endif+ {-# OPTIONS_GHC -fno-warn-missing-signatures #-} -------------------------------------------------------------------- -- |@@ -40,7 +47,6 @@ Config , HasConfig(..) , hll- , numBits, numBuckets, smallRange, interRange, rawFact, alpha, bucketMask -- * ReifiesConfig , ReifiesConfig(..) , reifyConfig@@ -83,13 +89,29 @@ } deriving (Eq, Show, Generic) class HasConfig t where- config :: Getter t Config+ config :: Getter t Config -makeLensesWith ?? ''Config $ classyRules- & generateSignatures .~ False- & createClass .~ False- & createInstance .~ False+ numBits :: Getter t Int+ numBits = config . to _numBits + numBuckets :: Getter t Int+ numBuckets = config . to _numBuckets++ smallRange :: Getter t Double+ smallRange = config . to _smallRange++ interRange :: Getter t Double+ interRange = config . to _interRange++ rawFact :: Getter t Double+ rawFact = config . to _rawFact++ alpha :: Getter t Double+ alpha = config . to _alpha++ bucketMask :: Getter t Word32+ bucketMask = config . to _bucketMask+ instance HasConfig Config where config = id {-# INLINE config #-}@@ -119,9 +141,15 @@ class ReifiesConfig o where reflectConfig :: p o -> Config -#ifdef USE_TYPE_LITS+#ifdef USE_NEW_TYPE_LITS instance KnownNat n => ReifiesConfig (n :: Nat) where reflectConfig _ = hll $ fromInteger $ natVal (Proxy :: Proxy n)+ {-# INLINE reflectConfig #-}+#endif++#ifdef USE_OLD_TYPE_LITS+instance SingRep n Integer => ReifiesConfig (n :: Nat) where+ reflectConfig _ = hll $ fromInteger $ withSing $ \(x :: Sing n) -> fromSing x {-# INLINE reflectConfig #-} #endif
src/Data/HyperLogLog/Type.hs view
@@ -9,7 +9,6 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -fno-cse #-}@@ -104,7 +103,11 @@ instance Serialize (HyperLogLog p) -makeClassy ''HyperLogLog+class HasHyperLogLog a p | a -> p where+ hyperLogLog :: Lens' a (HyperLogLog p)++instance HasHyperLogLog (HyperLogLog p) p where+ hyperLogLog = id _HyperLogLog :: Iso' (HyperLogLog p) (V.Vector Rank) _HyperLogLog = iso runHyperLogLog HyperLogLog