module Data.TDigest.Internal where

-- TODO: make newtypes
type Mean = Double
type Weight = Double
type Centroid = (Mean, Weight)
type Size = Int

-------------------------------------------------------------------------------
-- Assert
-------------------------------------------------------------------------------

{-# INLINE assert #-}
assert :: Bool -> String -> a -> a
assert :: forall a. Bool -> String -> a -> a
assert Bool
_ String
_ = forall a. a -> a
id
{-
assert False msg _ = error msg
assert True  _   x = x
-}

-------------------------------------------------------------------------------
-- Double helpers
-------------------------------------------------------------------------------

eq :: Double -> Double -> Bool
eq :: Double -> Double -> Bool
eq Double
a Double
b = forall a. Num a => a -> a
abs (Double
aforall a. Num a => a -> a -> a
-Double
b) forall a. Ord a => a -> a -> Bool
< Double
1e-6

negInf :: Double
negInf :: Double
negInf = forall a. Num a => a -> a
negate Double
posInf

posInf :: Double
posInf :: Double
posInf = Double
1forall a. Fractional a => a -> a -> a
/Double
0