-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Library for histograms creation.
--   
--   This is library for histograms filling. Its aim to provide convenient
--   way to create and fill histograms.
@package histogram-fill
@version 0.9.0.0


-- | Type classes for binning algorithms. This is mapping from set of
--   interest to integer indices and approximate reverse.
module Data.Histogram.Bin.Classes

-- | This type represent some abstract data binning algorithms. It maps
--   sets/intervals of values of type 'BinValue b' to integer indices.
--   
--   Following invariant is expected to hold:
--   
--   <pre>
--   toIndex . fromIndex == id
--   </pre>
class Bin b where {
    type family BinValue b;
}

-- | Convert from value to index. Function must not fail for any input and
--   should produce out of range indices for invalid input.
toIndex :: Bin b => b -> BinValue b -> Int

-- | Convert from index to value. Returned value should correspond to
--   center of bin. Definition of center is left for definition of
--   instance. Funtion may fail for invalid indices but encouraged not to
--   do so.
fromIndex :: Bin b => b -> Int -> BinValue b

-- | Total number of bins. Must be non-negative.
nBins :: Bin b => b -> Int

-- | Check whether value in range. Have default implementation. Should
--   satisfy: inRange b x ⇔ toIndex b x ∈ [0,nBins b)
inRange :: Bin b => b -> BinValue b -> Bool

-- | Return vector of bin centers
binsCenters :: (Bin b, Vector v (BinValue b)) => b -> v (BinValue b)

-- | Approximate equality for bins. It's nessesary to define approximate
--   equality since exact equality is ill defined for bins which work with
--   floating point data. It's not safe to compare floating point numbers
--   for exact equality
class Bin b => BinEq b

-- | Approximate equality
binEq :: BinEq b => b -> b -> Bool

-- | For binning algorithms which work with bin values which have some
--   natural ordering and every bin is continous interval.
class (Bin b, Ord (BinValue b)) => IntervalBin b

-- | Interval for n'th bin
binInterval :: IntervalBin b => b -> Int -> (BinValue b, BinValue b)

-- | List of all bins. Could be overridden for efficiency.
binsList :: (IntervalBin b, Vector v (BinValue b, BinValue b)) => b -> v (BinValue b, BinValue b)

-- | <a>IntervalBin</a> which domain is single finite interval
class IntervalBin b => Bin1D b

-- | Minimal accepted value of histogram
lowerLimit :: Bin1D b => b -> BinValue b

-- | Maximal accepted value of histogram
upperLimit :: Bin1D b => b -> BinValue b

-- | Binning algorithm which support slicing.
class Bin b => SliceableBin b

-- | Slice bin by indices. This function doesn't perform any checks and may
--   produce invalid bin. Use <a>sliceBin</a> instead.
unsafeSliceBin :: SliceableBin b => Int -> Int -> b -> b

-- | Slice bin using indices
sliceBin :: SliceableBin b => Int -> Int -> b -> b

-- | Bin which support rebinning.
class Bin b => MergeableBin b

-- | <tt>N</tt> consecutive bins are joined into single bin. If number of
--   bins isn't multiple of <tt>N</tt> remaining bins with highest or
--   lowest index are dropped. This function doesn't do any checks. Use
--   <a>mergeBins</a> instead.
unsafeMergeBins :: MergeableBin b => CutDirection -> Int -> b -> b

-- | How index should be dropped
data CutDirection

-- | Drop bins with smallest index
CutLower :: CutDirection

-- | Drop bins with bigger index
CutHigher :: CutDirection

-- | <tt>N</tt> consecutive bins are joined into single bin. If number of
--   bins isn't multiple of <tt>N</tt> remaining bins with highest or
--   lowest index are dropped. If <tt>N</tt> is larger than number of bins
--   all bins are merged into single one.
mergeBins :: MergeableBin b => CutDirection -> Int -> b -> b

-- | 1D binning algorithms with variable bin size
class Bin b => VariableBin b

-- | Size of n'th bin.
binSizeN :: VariableBin b => b -> Int -> BinValue b

-- | 1D binning algorithms with constant size bins. Constant sized bins
--   could be thought as specialization of variable-sized bins therefore a
--   superclass constraint.
class VariableBin b => UniformBin b

-- | Size of bin. Default implementation just uses 0th bin.
binSize :: UniformBin b => b -> BinValue b

-- | Class for conversion between binning algorithms.
class (Bin b, Bin b') => ConvertBin b b'

-- | Convert bins
convertBin :: ConvertBin b b' => b -> b'
instance GHC.Generics.Generic Data.Histogram.Bin.Classes.CutDirection
instance Data.Data.Data Data.Histogram.Bin.Classes.CutDirection
instance GHC.Show.Show Data.Histogram.Bin.Classes.CutDirection


-- | Helper function for defining Read instances for bin data types.
module Data.Histogram.Bin.Read

-- | Whitespaces
ws :: ReadP String

-- | End of line
eol :: ReadP Char

-- | Key value pair
value :: Read a => String -> ReadPrec a

-- | Return optional value
maybeValue :: Read a => String -> ReadPrec (Maybe a)

-- | Keyword
keyword :: String -> ReadPrec ()

module Data.Histogram.Bin.LogBinD

-- | Uniform binning in logarithmic scale. For roundtripping use:
--   
--   <pre>
--   b = logBinDN (lowerLimit b) (logBinDIncrement b) (nBins b)
--   </pre>
data LogBinD

-- | Increment ratio for <a>LogBinD</a>
logBinDIncrement :: LogBinD -> Double

-- | Create log-scale binning algorithm.
logBinD :: Double -> Int -> Double -> LogBinD
logBinDN :: Double -> Double -> Int -> LogBinD
instance Data.Data.Data Data.Histogram.Bin.LogBinD.LogBinD
instance GHC.Classes.Eq Data.Histogram.Bin.LogBinD.LogBinD
instance Data.Histogram.Bin.Classes.Bin Data.Histogram.Bin.LogBinD.LogBinD
instance Data.Histogram.Bin.Classes.IntervalBin Data.Histogram.Bin.LogBinD.LogBinD
instance Data.Histogram.Bin.Classes.Bin1D Data.Histogram.Bin.LogBinD.LogBinD
instance Data.Histogram.Bin.Classes.SliceableBin Data.Histogram.Bin.LogBinD.LogBinD
instance Data.Histogram.Bin.Classes.MergeableBin Data.Histogram.Bin.LogBinD.LogBinD
instance Data.Histogram.Bin.Classes.VariableBin Data.Histogram.Bin.LogBinD.LogBinD
instance Data.Histogram.Bin.Classes.BinEq Data.Histogram.Bin.LogBinD.LogBinD
instance GHC.Show.Show Data.Histogram.Bin.LogBinD.LogBinD
instance GHC.Read.Read Data.Histogram.Bin.LogBinD.LogBinD
instance Control.DeepSeq.NFData Data.Histogram.Bin.LogBinD.LogBinD

module Data.Histogram.Bin.BinVar

-- | Bins of variable size. Bins are defined by a vector of <a>cuts</a>
--   marking the boundary between bins. This assumes that the entire range
--   is continuous. There are n+1 cuts for n bins. This also implies that
--   cuts are in ascending order.
newtype BinVarG v a
BinVarG :: v a -> BinVarG v a
[_cuts] :: BinVarG v a -> v a

-- | Type synonym for <tt>BinVarG</tt> specialized for unboxed vectors
type BinVar = BinVarG Vector

-- | Create variable bins unsafely
unsafeBinVar :: v a -> BinVarG v a

-- | Create variable bins unsafely
binVar :: (Vector v a, Vector v Bool, Ord a) => v a -> BinVarG v a

-- | access cuts
cuts :: BinVarG v a -> v a

-- | Delete a cut, which effectively reduces the entire range of the bins
--   (if the cut was the first or last one) or merges two bins (if the cut
--   was in the middle)
deleteCut :: (Vector v a, Ord a, Fractional a) => BinVarG v a -> Int -> BinVarG v a

-- | insert a new cut which effectively extends the range of the bins or
--   splits a bin
addCut :: (Vector v a, Ord a) => BinVarG v a -> a -> BinVarG v a
instance GHC.Classes.Eq (v a) => GHC.Classes.Eq (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Vector.Generic.Base.Vector v a, GHC.Classes.Ord a, GHC.Real.Fractional a) => Data.Histogram.Bin.Classes.Bin (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Vector.Generic.Base.Vector v a, GHC.Classes.Ord a, GHC.Real.Fractional a) => Data.Histogram.Bin.Classes.IntervalBin (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Vector.Generic.Base.Vector v a, GHC.Classes.Ord a, GHC.Real.Fractional a) => Data.Histogram.Bin.Classes.Bin1D (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Vector.Generic.Base.Vector v a, GHC.Classes.Ord a, GHC.Real.Fractional a) => Data.Histogram.Bin.Classes.SliceableBin (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Vector.Generic.Base.Vector v a, GHC.Classes.Ord a, GHC.Real.Fractional a) => Data.Histogram.Bin.Classes.VariableBin (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Vector.Generic.Base.Vector v a, Data.Vector.Generic.Base.Vector v GHC.Types.Bool, GHC.Classes.Ord a, GHC.Real.Fractional a) => Data.Histogram.Bin.Classes.BinEq (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Vector.Generic.Base.Vector v a, GHC.Show.Show a) => GHC.Show.Show (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Vector.Generic.Base.Vector v a, Data.Vector.Generic.Base.Vector v GHC.Types.Bool, GHC.Read.Read a, GHC.Classes.Ord a) => GHC.Read.Read (Data.Histogram.Bin.BinVar.BinVarG v a)
instance Control.DeepSeq.NFData (v a) => Control.DeepSeq.NFData (Data.Histogram.Bin.BinVar.BinVarG v a)
instance (Data.Histogram.Bin.Classes.Bin1D b, Data.Vector.Generic.Base.Vector v (Data.Histogram.Bin.Classes.BinValue b), Data.Vector.Generic.Base.Vector v GHC.Types.Bool, a ~ Data.Histogram.Bin.Classes.BinValue b, GHC.Real.Fractional a) => Data.Histogram.Bin.Classes.ConvertBin b (Data.Histogram.Bin.BinVar.BinVarG v a)

module Data.Histogram.Bin.BinInt

-- | Integer bins of equal size. For roundtripping use:
--   
--   <pre>
--   b = binIntStep (lowerLimit b) (binSize b) (nBins b)
--   </pre>
data BinInt
BinInt :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> BinInt

-- | Construct BinInt.
binInt :: Int -> Int -> Int -> BinInt

-- | Construct <a>BinInt</a>.
binIntN :: Int -> Int -> Int -> BinInt
binIntStep :: Int -> Int -> Int -> BinInt
instance Data.Data.Data Data.Histogram.Bin.BinInt.BinInt
instance GHC.Classes.Eq Data.Histogram.Bin.BinInt.BinInt
instance Data.Histogram.Bin.Classes.Bin Data.Histogram.Bin.BinInt.BinInt
instance Data.Histogram.Bin.Classes.IntervalBin Data.Histogram.Bin.BinInt.BinInt
instance Data.Histogram.Bin.Classes.Bin1D Data.Histogram.Bin.BinInt.BinInt
instance Data.Histogram.Bin.Classes.SliceableBin Data.Histogram.Bin.BinInt.BinInt
instance Data.Histogram.Bin.Classes.MergeableBin Data.Histogram.Bin.BinInt.BinInt
instance Data.Histogram.Bin.Classes.VariableBin Data.Histogram.Bin.BinInt.BinInt
instance Data.Histogram.Bin.Classes.UniformBin Data.Histogram.Bin.BinInt.BinInt
instance Data.Histogram.Bin.Classes.BinEq Data.Histogram.Bin.BinInt.BinInt
instance GHC.Show.Show Data.Histogram.Bin.BinInt.BinInt
instance GHC.Read.Read Data.Histogram.Bin.BinInt.BinInt
instance Control.DeepSeq.NFData Data.Histogram.Bin.BinInt.BinInt

module Data.Histogram.Bin.BinI

-- | Very simple binning algorithm. Each indices. Each number correcsponds
--   to different bin.
--   
--   For rountripping use <a>lowerLimit</a> and <a>upperLimit</a>
--   
--   <pre>
--   b = binI (lowerLimit b) (upperLimit b)
--   </pre>
data BinI

-- | Safe constructor for BinI. It checks that upper bound is greater or
--   equal than lower bound
binI :: Int -> Int -> BinI

-- | Construct BinI with n bins. Indexing starts from 0. n must be positive
binI0 :: Int -> BinI
instance Data.Data.Data Data.Histogram.Bin.BinI.BinI
instance GHC.Classes.Eq Data.Histogram.Bin.BinI.BinI
instance Data.Histogram.Bin.Classes.Bin Data.Histogram.Bin.BinI.BinI
instance Data.Histogram.Bin.Classes.IntervalBin Data.Histogram.Bin.BinI.BinI
instance Data.Histogram.Bin.Classes.Bin1D Data.Histogram.Bin.BinI.BinI
instance Data.Histogram.Bin.Classes.SliceableBin Data.Histogram.Bin.BinI.BinI
instance Data.Histogram.Bin.Classes.VariableBin Data.Histogram.Bin.BinI.BinI
instance Data.Histogram.Bin.Classes.UniformBin Data.Histogram.Bin.BinI.BinI
instance Data.Histogram.Bin.Classes.BinEq Data.Histogram.Bin.BinI.BinI
instance GHC.Show.Show Data.Histogram.Bin.BinI.BinI
instance GHC.Read.Read Data.Histogram.Bin.BinI.BinI
instance Control.DeepSeq.NFData Data.Histogram.Bin.BinI.BinI

module Data.Histogram.Bin.BinF

-- | Floating point bins of equal size. Use following function for
--   construction and inspection of value:
--   
--   <pre>
--   b = binFstep (lowerLimit b) (binSize b) (nBins b)
--   </pre>
--   
--   Performance note. Since <tt>BinF</tt> is parametric in its value it
--   could not be unpacked and every access to data will require pointer
--   indirection. <a>BinD</a> is binning specialized to <tt>Doubles</tt>
--   and it's always faster than <tt>BinF Double</tt>.
data BinF f

-- | Create bins.
binF :: RealFrac f => f -> Int -> f -> BinF f

-- | Create bins. Note that actual upper bound can differ from specified.
binFn :: RealFrac f => f -> f -> f -> BinF f

-- | Create bins
binFstep :: RealFrac f => f -> f -> Int -> BinF f

-- | 'scaleBinF a b' scales BinF using linear transform 'a+b*x'
scaleBinF :: (Show f, RealFrac f) => f -> f -> BinF f -> BinF f

-- | Floating point bins of equal sizes. If you work with Doubles this data
--   type should be used instead of <a>BinF</a>.
data BinD

-- | Create bins.
binD :: Double -> Int -> Double -> BinD

-- | Create bins. Note that actual upper bound can differ from specified.
binDn :: Double -> Double -> Double -> BinD

-- | Create bins
binDstep :: Double -> Double -> Int -> BinD

-- | 'scaleBinF a b' scales BinF using linear transform 'a+b*x'
scaleBinD :: Double -> Double -> BinD -> BinD
instance GHC.Classes.Eq Data.Histogram.Bin.BinF.BinD
instance Data.Data.Data Data.Histogram.Bin.BinF.BinD
instance GHC.Classes.Eq f => GHC.Classes.Eq (Data.Histogram.Bin.BinF.BinF f)
instance Data.Data.Data f => Data.Data.Data (Data.Histogram.Bin.BinF.BinF f)
instance Data.Histogram.Bin.Classes.Bin Data.Histogram.Bin.BinF.BinD
instance Data.Histogram.Bin.Classes.IntervalBin Data.Histogram.Bin.BinF.BinD
instance Data.Histogram.Bin.Classes.Bin1D Data.Histogram.Bin.BinF.BinD
instance Data.Histogram.Bin.Classes.SliceableBin Data.Histogram.Bin.BinF.BinD
instance Data.Histogram.Bin.Classes.MergeableBin Data.Histogram.Bin.BinF.BinD
instance Data.Histogram.Bin.Classes.VariableBin Data.Histogram.Bin.BinF.BinD
instance Data.Histogram.Bin.Classes.UniformBin Data.Histogram.Bin.BinF.BinD
instance Data.Histogram.Bin.Classes.BinEq Data.Histogram.Bin.BinF.BinD
instance GHC.Show.Show Data.Histogram.Bin.BinF.BinD
instance GHC.Read.Read Data.Histogram.Bin.BinF.BinD
instance Control.DeepSeq.NFData Data.Histogram.Bin.BinF.BinD
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.Bin (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.IntervalBin (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.Bin1D (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.SliceableBin (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.MergeableBin (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.VariableBin (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.UniformBin (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Float.RealFloat f => Data.Histogram.Bin.Classes.BinEq (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Show.Show f => GHC.Show.Show (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Read.Read f => GHC.Read.Read (Data.Histogram.Bin.BinF.BinF f)
instance Control.DeepSeq.NFData f => Control.DeepSeq.NFData (Data.Histogram.Bin.BinF.BinF f)

module Data.Histogram.Bin.BinEnum

-- | Bin for types which are instnaces of Enum type class. Value are
--   converted to <a>Int</a> using <a>fromEnum</a> first and then binned.
newtype BinEnum a
BinEnum :: BinI -> BinEnum a

-- | Create enum based bin
binEnum :: Enum a => a -> a -> BinEnum a

-- | Use full range of data
binEnumFull :: (Enum a, Bounded a) => BinEnum a
instance GHC.Enum.Enum a => Data.Histogram.Bin.Classes.BinEq (Data.Histogram.Bin.BinEnum.BinEnum a)
instance Data.Data.Data a => Data.Data.Data (Data.Histogram.Bin.BinEnum.BinEnum a)
instance GHC.Classes.Eq (Data.Histogram.Bin.BinEnum.BinEnum a)
instance GHC.Enum.Enum a => Data.Histogram.Bin.Classes.Bin (Data.Histogram.Bin.BinEnum.BinEnum a)
instance (GHC.Enum.Enum a, GHC.Classes.Ord a) => Data.Histogram.Bin.Classes.IntervalBin (Data.Histogram.Bin.BinEnum.BinEnum a)
instance (GHC.Enum.Enum a, GHC.Classes.Ord a) => Data.Histogram.Bin.Classes.Bin1D (Data.Histogram.Bin.BinEnum.BinEnum a)
instance (GHC.Enum.Enum a, GHC.Classes.Ord a) => Data.Histogram.Bin.Classes.SliceableBin (Data.Histogram.Bin.BinEnum.BinEnum a)
instance GHC.Show.Show (Data.Histogram.Bin.BinEnum.BinEnum a)
instance GHC.Read.Read (Data.Histogram.Bin.BinEnum.BinEnum a)
instance Control.DeepSeq.NFData (Data.Histogram.Bin.BinEnum.BinEnum a)

module Data.Histogram.Bin.Bin2D

-- | 2D bins. binX is binning along X axis and binY is one along Y axis.
--   Data is stored in row-major order
data Bin2D binX binY
Bin2D :: !binX -> !binY -> Bin2D binX binY

-- | Binning algorithm for X axis
[binX] :: Bin2D binX binY -> !binX

-- | Binning algorithm for Y axis
[binY] :: Bin2D binX binY -> !binY

-- | Alias for <a>Bin2D</a>.
(><) :: binX -> binY -> Bin2D binX binY

-- | Type alias for Bin2D
type :><: = Bin2D

-- | 2-dimensional size of binning algorithm
nBins2D :: (Bin bx, Bin by) => Bin2D bx by -> (Int, Int)

-- | Convert index into pair of indices for X and Y axes
toIndex2D :: (Bin binX) => Bin2D binX binY -> Int -> (Int, Int)

-- | Apply function to X binning algorithm. If new binning algorithm have
--   different number of bins will fail.
fmapBinX :: (Bin bx, Bin bx') => (bx -> bx') -> Bin2D bx by -> Bin2D bx' by

-- | Apply function to Y binning algorithm. If new binning algorithm have
--   different number of bins will fail.
fmapBinY :: (Bin by, Bin by') => (by -> by') -> Bin2D bx by -> Bin2D bx by'
instance (Data.Data.Data binX, Data.Data.Data binY) => Data.Data.Data (Data.Histogram.Bin.Bin2D.Bin2D binX binY)
instance (GHC.Classes.Eq binX, GHC.Classes.Eq binY) => GHC.Classes.Eq (Data.Histogram.Bin.Bin2D.Bin2D binX binY)
instance (Data.Histogram.Bin.Classes.Bin binX, Data.Histogram.Bin.Classes.Bin binY) => Data.Histogram.Bin.Classes.Bin (Data.Histogram.Bin.Bin2D.Bin2D binX binY)
instance (Data.Histogram.Bin.Classes.BinEq bx, Data.Histogram.Bin.Classes.BinEq by) => Data.Histogram.Bin.Classes.BinEq (Data.Histogram.Bin.Bin2D.Bin2D bx by)
instance (GHC.Show.Show bx, GHC.Show.Show by) => GHC.Show.Show (Data.Histogram.Bin.Bin2D.Bin2D bx by)
instance (GHC.Read.Read bx, GHC.Read.Read by) => GHC.Read.Read (Data.Histogram.Bin.Bin2D.Bin2D bx by)
instance (Control.DeepSeq.NFData bx, Control.DeepSeq.NFData by) => Control.DeepSeq.NFData (Data.Histogram.Bin.Bin2D.Bin2D bx by)


-- | Binning algorithms. This is a mapping from set of interest to integer
--   indices and an approximate reverse.
module Data.Histogram.Bin
instance Data.Histogram.Bin.Classes.ConvertBin Data.Histogram.Bin.BinI.BinI Data.Histogram.Bin.BinInt.BinInt
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.ConvertBin Data.Histogram.Bin.BinI.BinI (Data.Histogram.Bin.BinF.BinF f)
instance GHC.Real.RealFrac f => Data.Histogram.Bin.Classes.ConvertBin Data.Histogram.Bin.BinInt.BinInt (Data.Histogram.Bin.BinF.BinF f)
instance Data.Histogram.Bin.Classes.ConvertBin Data.Histogram.Bin.BinI.BinI Data.Histogram.Bin.BinF.BinD
instance Data.Histogram.Bin.Classes.ConvertBin Data.Histogram.Bin.BinInt.BinInt Data.Histogram.Bin.BinF.BinD
instance (Data.Histogram.Bin.Classes.ConvertBin bx bx', Data.Histogram.Bin.Classes.Bin by) => Data.Histogram.Bin.Classes.ConvertBin (Data.Histogram.Bin.Bin2D.Bin2D bx by) (Data.Histogram.Bin.Bin2D.Bin2D bx' by)
instance (Data.Histogram.Bin.Classes.ConvertBin by by', Data.Histogram.Bin.Classes.Bin bx) => Data.Histogram.Bin.Classes.ConvertBin (Data.Histogram.Bin.Bin2D.Bin2D bx by) (Data.Histogram.Bin.Bin2D.Bin2D bx by')
instance (Data.Histogram.Bin.Classes.ConvertBin bx bx', Data.Histogram.Bin.Classes.ConvertBin by by') => Data.Histogram.Bin.Classes.ConvertBin (Data.Histogram.Bin.Bin2D.Bin2D bx by) (Data.Histogram.Bin.Bin2D.Bin2D bx' by')


-- | Extra binning algorithms
module Data.Histogram.Bin.Extra

-- | Type class very similar to <a>Enum</a> but elements of type are
--   enumerated on 2-dimensional grid
class Enum2D a

-- | Convert value to index
fromEnum2D :: Enum2D a => a -> (Int, Int)

-- | Convert index to value
toEnum2D :: Enum2D a => (Int, Int) -> a

-- | Binning for 2D enumerations
data BinEnum2D i

-- | Construct indexed bin
binEnum2D :: Enum2D i => i -> i -> BinEnum2D i

-- | Direct permutation of indices.
data BinPermute b

-- | Constuct bin permutation from table
permuteByTable :: Bin b => b -> Vector Int -> Maybe (BinPermute b)

-- | Constuct bin permutation from function.
permuteBin :: Bin b => b -> (Int -> Int) -> Maybe (BinPermute b)
instance Data.Data.Data b => Data.Data.Data (Data.Histogram.Bin.Extra.BinPermute b)
instance GHC.Classes.Eq b => GHC.Classes.Eq (Data.Histogram.Bin.Extra.BinPermute b)
instance Data.Data.Data i => Data.Data.Data (Data.Histogram.Bin.Extra.BinEnum2D i)
instance GHC.Classes.Eq (Data.Histogram.Bin.Extra.BinEnum2D i)
instance Data.Histogram.Bin.Classes.Bin b => Data.Histogram.Bin.Classes.Bin (Data.Histogram.Bin.Extra.BinPermute b)
instance Data.Histogram.Bin.Classes.IntervalBin b => Data.Histogram.Bin.Classes.IntervalBin (Data.Histogram.Bin.Extra.BinPermute b)
instance Data.Histogram.Bin.Classes.VariableBin b => Data.Histogram.Bin.Classes.VariableBin (Data.Histogram.Bin.Extra.BinPermute b)
instance Data.Histogram.Bin.Classes.UniformBin b => Data.Histogram.Bin.Classes.UniformBin (Data.Histogram.Bin.Extra.BinPermute b)
instance GHC.Show.Show b => GHC.Show.Show (Data.Histogram.Bin.Extra.BinPermute b)
instance GHC.Read.Read Data.Histogram.Bin.BinI.BinI => GHC.Read.Read (Data.Histogram.Bin.Extra.BinPermute Data.Histogram.Bin.BinI.BinI)
instance Control.DeepSeq.NFData b => Control.DeepSeq.NFData (Data.Histogram.Bin.Extra.BinPermute b)
instance Data.Histogram.Bin.Extra.Enum2D i => Data.Histogram.Bin.Classes.Bin (Data.Histogram.Bin.Extra.BinEnum2D i)
instance (GHC.Show.Show i, Data.Histogram.Bin.Extra.Enum2D i) => GHC.Show.Show (Data.Histogram.Bin.Extra.BinEnum2D i)
instance (GHC.Read.Read i, Data.Histogram.Bin.Extra.Enum2D i) => GHC.Read.Read (Data.Histogram.Bin.Extra.BinEnum2D i)
instance Control.DeepSeq.NFData (Data.Histogram.Bin.Extra.BinEnum2D i)
instance (GHC.Enum.Enum a, GHC.Enum.Enum b) => Data.Histogram.Bin.Extra.Enum2D (a, b)


-- | Generic immutable histograms.
module Data.Histogram.Generic

-- | Immutable histogram. A histogram consists of a binning algorithm, an
--   optional number of under- and overflows, and data. Type parameters
--   have following meaning:
--   
--   <ul>
--   <li><i><tt>v</tt></i> type of vector used to store bin content.</li>
--   <li><i><tt>bin</tt></i> binning. It should be instance of <a>Bin</a>.
--   Check that type class description for details.</li>
--   <li><i><tt>a</tt></i> type of bin content.</li>
--   </ul>
data Histogram v bin a

-- | Create histogram from binning algorithm and a vector with data.
--   Overflows are set to Nothing.
--   
--   Number of bins and vector size must match.
histogram :: (Vector v a, Bin bin) => bin -> v a -> Histogram v bin a

-- | Create histogram from binning algorithm and vector with data.
--   
--   Number of bins and vector size must match.
histogramUO :: (Vector v a, Bin bin) => bin -> Maybe (a, a) -> v a -> Histogram v bin a

-- | Convert histogram data to list.
asList :: (Vector v a, Bin bin) => Histogram v bin a -> [(BinValue bin, a)]

-- | Convert histogram data to vector
asVector :: (Bin bin, Vector v a, Vector v (BinValue bin, a)) => Histogram v bin a -> v (BinValue bin, a)

-- | Convert a <a>String</a> to a histogram. Histogram does not have a
--   <a>Read</a> instance because of the slowness of ReadP
readHistogram :: (Read bin, Read a, Bin bin, Vector v a) => String -> Histogram v bin a

-- | Read histogram from file.
readFileHistogram :: (Read bin, Read a, Bin bin, Vector v a) => FilePath -> IO (Histogram v bin a)

-- | Histogram bins
bins :: Histogram v bin a -> bin

-- | Histogram data as vector
histData :: Histogram v bin a -> v a

-- | Number of underflows
underflows :: Histogram v bin a -> Maybe a

-- | Number of overflows
overflows :: Histogram v bin a -> Maybe a

-- | Underflows and overflows
outOfRange :: Histogram v bin a -> Maybe (a, a)

-- | Point inside histogram's domain. It could be either bin index or bin
--   value. <a>First</a> and <a>Last</a> constructors are useful for
--   histogram slicing.
data HistIndex b

-- | Index for a bin
Index :: Int -> HistIndex b

-- | Value
Value :: (BinValue b) -> HistIndex b

-- | Bin with index 0
First :: HistIndex b

-- | Bin maximum index.
Last :: HistIndex b

-- | Convert <a>HistIndex</a> to actual index
histIndex :: Bin b => b -> HistIndex b -> Int

-- | Index histogtam.
at :: (Bin bin, Vector v a) => Histogram v bin a -> HistIndex bin -> a

-- | Index histogram using bin value
atV :: (Bin bin, Vector v a) => Histogram v bin a -> BinValue bin -> a

-- | Index histogram using vector index
atI :: (Bin bin, Vector v a) => Histogram v bin a -> Int -> a

-- | fmap lookalike. It's not possible to create Functor instance because
--   of type class context.
map :: (Vector v a, Vector v b) => (a -> b) -> Histogram v bin a -> Histogram v bin b

-- | Map histogram using bin value and content. Overflows and underflows
--   are set to Nothing.
bmap :: (Vector v a, Vector v b, Bin bin) => (BinValue bin -> a -> b) -> Histogram v bin a -> Histogram v bin b
mapData :: (Vector v a, Vector u b, Bin bin) => (v a -> u b) -> Histogram v bin a -> Histogram u bin b

-- | Zip two histograms elementwise. Bins of histograms must be equal
--   otherwise error will be called.
zip :: (BinEq bin, Vector v a, Vector v b, Vector v c) => (a -> b -> c) -> Histogram v bin a -> Histogram v bin b -> Histogram v bin c

-- | Zip two histograms elementwise. If bins are not equal return
--   <a>Nothing</a>
zipSafe :: (BinEq bin, Vector v a, Vector v b, Vector v c) => (a -> b -> c) -> Histogram v bin a -> Histogram v bin b -> Maybe (Histogram v bin c)

-- | Convert between different vector types
convert :: (Vector v a, Vector w a) => Histogram v bin a -> Histogram w bin a

-- | Convert between binning types using <a>ConvertBin</a> type class.
convertBinning :: (ConvertBin bin bin', Vector v a) => Histogram v bin a -> Histogram v bin' a

-- | Strict fold over bin content in index order. Underflows and overflows
--   are ignored.
foldl :: (Vector v a) => (b -> a -> b) -> b -> Histogram v bin a -> b

-- | Strict fold over bin content in index order. Function is applied to
--   bin content and bin value. Underflows and overflows are ignored.
bfoldl :: (Bin bin, Vector v a) => (b -> BinValue bin -> a -> b) -> b -> Histogram v bin a -> b

-- | Sum contents of all bins
sum :: (Vector v a, Num a) => Histogram v bin a -> a

-- | Minimal bin content.
minimum :: (Vector v a, Ord a) => Histogram v bin a -> a

-- | Minimal bin content using custom comparison.
minimumBy :: (Vector v a) => (a -> a -> Ordering) -> Histogram v bin a -> a

-- | Maximal bin content.
maximum :: (Vector v a, Ord a) => Histogram v bin a -> a

-- | Maximal bin content using custom comparison.
maximumBy :: (Vector v a) => (a -> a -> Ordering) -> Histogram v bin a -> a

-- | Index of a bin with minimal content.
minIndex :: (Ord a, Vector v a) => Histogram v bin a -> Int

-- | Index of a bin with minimal content using custom comparison.
minIndexBy :: (Vector v a) => (a -> a -> Ordering) -> Histogram v bin a -> Int

-- | Index of a bin with maximal content.
maxIndex :: (Ord a, Vector v a) => Histogram v bin a -> Int

-- | Index of a bin with maximal content using custom comparison.
maxIndexBy :: (Vector v a) => (a -> a -> Ordering) -> Histogram v bin a -> Int

-- | Value of a bin with minimal content
minBin :: (Bin bin, Ord a, Vector v a) => Histogram v bin a -> BinValue bin

-- | Value bin with minimal content using custom comparison.
minBinBy :: (Bin bin, Vector v a) => (a -> a -> Ordering) -> Histogram v bin a -> BinValue bin

-- | Value of a bin with maximal content.
maxBin :: (Bin bin, Ord a, Vector v a) => Histogram v bin a -> BinValue bin

-- | Value of a bin with maximal content using custom comparison.
maxBinBy :: (Bin bin, Vector v a) => (a -> a -> Ordering) -> Histogram v bin a -> BinValue bin

-- | Slice a histogram. Values/indices specify inclusive variant.
--   Under/overflows are discarded. If requested value falls out of
--   histogram range, it will be truncated. Use <a>First</a> or <a>Last</a>
--   constructor if you need to slice from first or to last bin
--   correspondingly.
slice :: (SliceableBin bin, Vector v a) => HistIndex bin -> HistIndex bin -> Histogram v bin a -> Histogram v bin a

-- | Rebin histogram by joining <tt>n</tt> adjacent bins.
rebin :: (MergeableBin bin, Vector v a) => CutDirection -> Int -> (a -> a -> a) -> Histogram v bin a -> Histogram v bin a

-- | Rebin histogram by joining <tt>n</tt> adjacent bins.
rebinFold :: (MergeableBin bin, Vector v a, Vector v b) => CutDirection -> Int -> (b -> a -> b) -> b -> Histogram v bin a -> Histogram v bin b

-- | Get slice of 2D histogram along the X axis. This function is faster
--   than <a>sliceAlongY</a> since no array reallocations are required.
sliceAlongX :: (Vector v a, Bin bX, Bin bY) => Histogram v (Bin2D bX bY) a -> HistIndex bY -> Histogram v bX a

-- | Get slice of 2D histogram along X axis
sliceAlongY :: (Vector v a, Bin bX, Bin bY) => Histogram v (Bin2D bX bY) a -> HistIndex bX -> Histogram v bY a

-- | Slice 2D histogram along Y axis. This function is fast because it does
--   not require reallocations.
listSlicesAlongX :: (Vector v a, Bin bX, Bin bY) => Histogram v (Bin2D bX bY) a -> [(BinValue bY, Histogram v bX a)]

-- | Slice 2D histogram along X axis.
listSlicesAlongY :: (Vector v a, Bin bX, Bin bY) => Histogram v (Bin2D bX bY) a -> [(BinValue bX, Histogram v bY a)]

-- | Reduce along X axis. Information about under/overlows is lost.
reduceX :: (Vector v a, Vector v b, Bin bX, Bin bY) => (Histogram v bX a -> b) -> Histogram v (Bin2D bX bY) a -> Histogram v bY b

-- | Reduce along X axis. Information about under/overlows is lost.
breduceX :: (Vector v a, Vector v b, Bin bX, Bin bY) => (BinValue bY -> Histogram v bX a -> b) -> Histogram v (Bin2D bX bY) a -> Histogram v bY b

-- | Reduce along Y axis. Information about under/overflows is lost.
reduceY :: (Vector v a, Vector v b, Bin bX, Bin bY) => (Histogram v bY a -> b) -> Histogram v (Bin2D bX bY) a -> Histogram v bX b

-- | Reduce along Y axis. Information about under/overflows is lost.
breduceY :: (Vector v a, Vector v b, Bin bX, Bin bY) => (BinValue bX -> Histogram v bY a -> b) -> Histogram v (Bin2D bX bY) a -> Histogram v bX b

-- | Transform X slices of histogram.
liftX :: (Bin bX, Bin bY, Bin bX', BinEq bX', Vector v a, Vector v b) => (Histogram v bX a -> Histogram v bX' b) -> Histogram v (Bin2D bX bY) a -> Histogram v (Bin2D bX' bY) b

-- | Transform Y slices of histogram.
liftY :: (Bin bX, Bin bY, Bin bY', BinEq bY', Vector v a, Vector v b, Vector v Int) => (Histogram v bY a -> Histogram v bY' b) -> Histogram v (Bin2D bX bY) a -> Histogram v (Bin2D bX bY') b
instance (GHC.Classes.Eq bin, GHC.Classes.Eq a, GHC.Classes.Eq (v a)) => GHC.Classes.Eq (Data.Histogram.Generic.Histogram v bin a)
instance GHC.Base.Functor Data.Histogram.Generic.Overflows
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Histogram.Generic.Overflows a)
instance (GHC.Show.Show a, GHC.Show.Show (Data.Histogram.Bin.Classes.BinValue bin), GHC.Show.Show bin, Data.Histogram.Bin.Classes.Bin bin, Data.Vector.Generic.Base.Vector v a) => GHC.Show.Show (Data.Histogram.Generic.Histogram v bin a)
instance (Control.DeepSeq.NFData a, Control.DeepSeq.NFData bin, Control.DeepSeq.NFData (v a)) => Control.DeepSeq.NFData (Data.Histogram.Generic.Histogram v bin a)
instance GHC.Base.Functor v => GHC.Base.Functor (Data.Histogram.Generic.Histogram v bin)
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.Histogram.Generic.Overflows a)
instance GHC.Base.Applicative Data.Histogram.Generic.Overflows

module Data.Histogram.Bin.MaybeBin

-- | This binning algorithms adds special case of no value.
newtype MaybeBin bin
MaybeBin :: bin -> MaybeBin bin

-- | Drop bin with no events
fromMaybeBin :: (Bin b, Vector v a) => Histogram v (MaybeBin b) a -> Histogram v b a
instance GHC.Classes.Eq bin => GHC.Classes.Eq (Data.Histogram.Bin.MaybeBin.MaybeBin bin)
instance Data.Histogram.Bin.Classes.BinEq bin => Data.Histogram.Bin.Classes.BinEq (Data.Histogram.Bin.MaybeBin.MaybeBin bin)
instance Data.Histogram.Bin.Classes.Bin bin => Data.Histogram.Bin.Classes.Bin (Data.Histogram.Bin.MaybeBin.MaybeBin bin)
instance Data.Histogram.Bin.Classes.VariableBin bin => Data.Histogram.Bin.Classes.VariableBin (Data.Histogram.Bin.MaybeBin.MaybeBin bin)
instance GHC.Show.Show bin => GHC.Show.Show (Data.Histogram.Bin.MaybeBin.MaybeBin bin)
instance GHC.Read.Read bin => GHC.Read.Read (Data.Histogram.Bin.MaybeBin.MaybeBin bin)
instance Control.DeepSeq.NFData bin => Control.DeepSeq.NFData (Data.Histogram.Bin.MaybeBin.MaybeBin bin)


-- | Immutable histograms. This module exports the same API as
--   <a>Generic</a> but specialized to unboxed vectors. Refer to the
--   aforementioned module for documentation.
module Data.Histogram

-- | Immutable histogram. A histogram consists of a binning algorithm, an
--   optional number of under and overflows, and data.
type Histogram bin a = Histogram Vector bin a
histogram :: (Unbox a, Bin bin) => bin -> Vector a -> Histogram bin a
histogramUO :: (Unbox a, Bin bin) => bin -> Maybe (a, a) -> Vector a -> Histogram bin a
asList :: (Unbox a, Bin bin) => Histogram bin a -> [(BinValue bin, a)]
asVector :: (Bin bin, Unbox a, Unbox (BinValue bin, a)) => Histogram bin a -> Vector (BinValue bin, a)
readHistogram :: (Read bin, Read a, Bin bin, Unbox a) => String -> Histogram bin a
readFileHistogram :: (Read bin, Read a, Bin bin, Unbox a) => FilePath -> IO (Histogram bin a)
bins :: Histogram bin a -> bin
histData :: Histogram bin a -> Vector a
underflows :: Histogram bin a -> Maybe a
overflows :: Histogram bin a -> Maybe a
outOfRange :: Histogram bin a -> Maybe (a, a)

-- | Point inside histogram's domain. It could be either bin index or bin
--   value. <a>First</a> and <a>Last</a> constructors are useful for
--   histogram slicing.
data HistIndex b

-- | Index for a bin
Index :: Int -> HistIndex b

-- | Value
Value :: (BinValue b) -> HistIndex b

-- | Bin with index 0
First :: HistIndex b

-- | Bin maximum index.
Last :: HistIndex b

-- | Convert <a>HistIndex</a> to actual index
histIndex :: Bin b => b -> HistIndex b -> Int
at :: (Bin bin, Unbox a) => Histogram bin a -> HistIndex bin -> a
atV :: (Bin bin, Unbox a) => Histogram bin a -> BinValue bin -> a
atI :: (Bin bin, Unbox a) => Histogram bin a -> Int -> a
map :: (Unbox a, Unbox b) => (a -> b) -> Histogram bin a -> Histogram bin b
bmap :: (Unbox a, Unbox b, Bin bin) => (BinValue bin -> a -> b) -> Histogram bin a -> Histogram bin b
mapData :: (Unbox a, Unbox b, Bin bin) => (Vector a -> Vector b) -> Histogram bin a -> Histogram bin b
zip :: (BinEq bin, Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Histogram bin a -> Histogram bin b -> Histogram bin c
zipSafe :: (BinEq bin, Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Histogram bin a -> Histogram bin b -> Maybe (Histogram bin c)
convertBinning :: (ConvertBin bin bin', Unbox a) => Histogram bin a -> Histogram bin' a
foldl :: (Unbox a) => (b -> a -> b) -> b -> Histogram bin a -> b
bfoldl :: (Bin bin, Unbox a) => (b -> BinValue bin -> a -> b) -> b -> Histogram bin a -> b
sum :: (Unbox a, Num a) => Histogram bin a -> a
minimum :: (Unbox a, Ord a) => Histogram bin a -> a
minimumBy :: (Unbox a) => (a -> a -> Ordering) -> Histogram bin a -> a
maximum :: (Unbox a, Ord a) => Histogram bin a -> a
maximumBy :: (Unbox a) => (a -> a -> Ordering) -> Histogram bin a -> a
minIndex :: (Ord a, Unbox a) => Histogram bin a -> Int
minIndexBy :: (Unbox a) => (a -> a -> Ordering) -> Histogram bin a -> Int
maxIndex :: (Ord a, Unbox a) => Histogram bin a -> Int
maxIndexBy :: (Unbox a) => (a -> a -> Ordering) -> Histogram bin a -> Int
minBin :: (Bin bin, Ord a, Unbox a) => Histogram bin a -> BinValue bin
minBinBy :: (Bin bin, Unbox a) => (a -> a -> Ordering) -> Histogram bin a -> BinValue bin
maxBin :: (Bin bin, Ord a, Unbox a) => Histogram bin a -> BinValue bin
maxBinBy :: (Bin bin, Unbox a) => (a -> a -> Ordering) -> Histogram bin a -> BinValue bin
slice :: (SliceableBin bin, Unbox a) => HistIndex bin -> HistIndex bin -> Histogram bin a -> Histogram bin a
rebin :: (MergeableBin bin, Unbox a) => CutDirection -> Int -> (a -> a -> a) -> Histogram bin a -> Histogram bin a
rebinFold :: (MergeableBin bin, Unbox a, Unbox b) => CutDirection -> Int -> (b -> a -> b) -> b -> Histogram bin a -> Histogram bin b
sliceAlongX :: (Unbox a, Bin bX, Bin bY) => Histogram (Bin2D bX bY) a -> HistIndex bY -> Histogram bX a
sliceAlongY :: (Unbox a, Bin bX, Bin bY) => Histogram (Bin2D bX bY) a -> HistIndex bX -> Histogram bY a
listSlicesAlongX :: (Unbox a, Bin bX, Bin bY) => Histogram (Bin2D bX bY) a -> [(BinValue bY, Histogram bX a)]
listSlicesAlongY :: (Unbox a, Bin bX, Bin bY) => Histogram (Bin2D bX bY) a -> [(BinValue bX, Histogram bY a)]
reduceX :: (Unbox a, Unbox b, Bin bX, Bin bY) => (Histogram bX a -> b) -> Histogram (Bin2D bX bY) a -> Histogram bY b
breduceX :: (Unbox a, Unbox b, Bin bX, Bin bY) => (BinValue bY -> Histogram bX a -> b) -> Histogram (Bin2D bX bY) a -> Histogram bY b
reduceY :: (Unbox a, Unbox b, Bin bX, Bin bY) => (Histogram bY a -> b) -> Histogram (Bin2D bX bY) a -> Histogram bX b
breduceY :: (Unbox a, Unbox b, Bin bX, Bin bY) => (BinValue bX -> Histogram bY a -> b) -> Histogram (Bin2D bX bY) a -> Histogram bX b
liftX :: (Bin bX, Bin bY, BinEq bX', Unbox a, Unbox b) => (Histogram bX a -> Histogram bX' b) -> Histogram (Bin2D bX bY) a -> Histogram (Bin2D bX' bY) b
liftY :: (Bin bX, Bin bY, BinEq bY', Unbox a, Unbox b) => (Histogram bY a -> Histogram bY' b) -> Histogram (Bin2D bX bY) a -> Histogram (Bin2D bX bY') b


-- | Mutable histograms.
module Data.Histogram.ST

-- | Mutable histogram.
data MHistogram s v bin a

-- | Create new mutable histogram. All bins are set to zero element as
--   passed to function.
newMHistogram :: (PrimMonad m, Bin bin, MVector v a) => a -> bin -> m (MHistogram (PrimState m) v bin a)

-- | Generic fill. It could be seen as left fold with multiple accumulators
--   where accumulator is chosen by <tt>BinValue bin</tt>.
fill :: (PrimMonad m, MVector v a, Bin bin) => MHistogram (PrimState m) v bin a -> BinValue bin -> (a -> b -> a) -> b -> m ()

-- | Create immutable histogram from mutable one. This operation is unsafe!
--   Accumulator mustn't be used after that
unsafeFreezeHist :: (PrimMonad m, Vector v a, Bin bin) => MHistogram (PrimState m) (Mutable v) bin a -> m (Histogram v bin a)

-- | Create immutable histogram from mutable one.
freezeHist :: (PrimMonad m, Vector v a, Bin bin) => MHistogram (PrimState m) (Mutable v) bin a -> m (Histogram v bin a)


-- | Stateful and pure (still stateful under the hood) accumulators.
module Data.Histogram.Fill

-- | Type class for stateful accumulators. In this module they are called
--   builders. Every builder is parametrized by two types. First one is
--   type of values which are fed to accumulator and second one is type of
--   values which could be extracted from it.
--   
--   Every instance of <a>HBuilder</a> should be instance of <a>Functor</a>
--   too and satisfy <a>fmap</a> == <a>modifyOut</a>.
class HistBuilder h

-- | Apply function to output of histogram.
modifyOut :: HistBuilder h => (b -> b') -> h a b -> h a b'

-- | Change input of builder by applying function to it.
modifyIn :: HistBuilder h => (a' -> a) -> h a b -> h a' b

-- | Put all values in container into builder
fromContainer :: HistBuilder h => (forall m. Monad m => (a -> m ()) -> f a -> m ()) -> h a b -> h (f a) b

-- | Add cut to histogram. Value would be putted into histogram only if
--   condition is true.
addCut :: HistBuilder h => (a -> Bool) -> h a b -> h a b

-- | Modify input of builder
(<<-) :: HistBuilder h => h a b -> (a' -> a) -> h a' b
infixl 5 <<-

-- | Modify input of builder to use composite input
(<<-|) :: (HistBuilder h, Foldable f) => h a b -> (a' -> f a) -> h a' b
infixl 5 <<-|

-- | Add cut for input
(<<?) :: HistBuilder h => h a b -> (a -> Bool) -> h a b
infixl 5 <<?

-- | Apply function which modify builder
(<<-$) :: h a b -> (h a b -> h a' b) -> h a' b
infixl 5 <<-$

-- | Modify output of histogram. In fact it's same as <a>&lt;$&gt;</a> but
--   have opposite fixity
(-<<) :: HistBuilder h => (b -> b') -> h a b -> h a b'
infixr 4 -<<

-- | Stateful histogram builder. Adding a value to builder could be done
--   with <a>feedOne</a> and the result could be extracted with
--   <a>freezeHBuilderM</a>.
--   
--   There are two ways to obtain a stateful builder. First and recommended
--   way is to thaw <a>HBuilder</a> using <a>toHBuilderIO</a> or
--   <a>toHBuilderST</a>. Second possibility is to use
--   <a>mkStatefulBuilder</a>.
data HBuilderM m a b
HBuilderM :: a -> m () -> m b -> HBuilderM m a b
[hbInput] :: HBuilderM m a b -> a -> m ()
[hbOutput] :: HBuilderM m a b -> m b

-- | Put one item into the histogram
feedOne :: HBuilderM m a b -> a -> m ()

-- | Extract the result from a histogram builder. It's safe to call this
--   function multiple times, and mutate the builder afterwards.
freezeHBuilderM :: HBuilderM m a b -> m b

-- | Wrapper around the stateful histogram builder. It is much more
--   convenient to work with this one than with <a>HBuilderM</a>.
newtype HBuilder a b
HBuilder :: (forall m. PrimMonad m => m (HBuilderM m a b)) -> HBuilder a b

-- | Convert the builder to stateful builder in the ST monad
toHBuilderST :: HBuilder a b -> ST s (HBuilderM (ST s) a b)

-- | Convert the builder to builder in the IO monad
toHBuilderIO :: HBuilder a b -> IO (HBuilderM IO a b)

-- | Convert the builder to a stateful builder in a primitive monad
toHBuilderM :: PrimMonad m => HBuilder a b -> m (HBuilderM m a b)

-- | Create builder. Bin content will be incremented by 1 for each item put
--   into the histogram
mkSimple :: (Bin bin, Unbox val, Num val) => bin -> HBuilder (BinValue bin) (Histogram bin val)

-- | Create builder. Bin content will be incremented by the weight supplied
--   for each item put into the histogram
mkWeighted :: (Bin bin, Unbox val, Num val) => bin -> HBuilder (BinValue bin, val) (Histogram bin val)

-- | Create builder. New value will be mappended to current content of a
--   bin for each item put into the histogram
mkMonoidal :: (Bin bin, Unbox val, Monoid val) => bin -> HBuilder (BinValue bin, val) (Histogram bin val)

-- | Create a most generic histogram builder.
mkFoldBuilder :: (Bin bin, Unbox val) => bin -> val -> (val -> a -> val) -> HBuilder (BinValue bin, a) (Histogram bin val)

-- | Create builder. Bin content will be incremented by 1 for each item put
--   into the histogram
mkSimpleG :: (Bin bin, Vector v val, Num val) => bin -> HBuilder (BinValue bin) (Histogram v bin val)

-- | Create builder. Bin content will incremented by the weight supplied
--   for each item put into the histogram
mkWeightedG :: (Bin bin, Vector v val, Num val) => bin -> HBuilder (BinValue bin, val) (Histogram v bin val)

-- | Create builder. New value will be mappended to current content of a
--   bin for each item put into the histogram
mkMonoidalG :: (Bin bin, Vector v val, Monoid val) => bin -> HBuilder (BinValue bin, val) (Histogram v bin val)

-- | Create most generic histogram builder.
mkFoldBuilderG :: (Bin bin, Vector v val) => bin -> val -> (val -> a -> val) -> HBuilder (BinValue bin, a) (Histogram v bin val)

-- | Create histogram builder which just does ordinary pure fold. It is
--   intended for use when some fold should be performed together with
--   histogram filling.
mkFolder :: b -> (a -> b -> b) -> HBuilder a b

-- | Create stateful histogram builder. The output function should be safe
--   to call multiple times and the builder could be modified afterwards.
--   So functions like <tt>unsafeFreeze</tt> from <tt>vector</tt> couldn't
--   be used.
mkStatefulBuilder :: (a -> m ()) -> m b -> HBuilderM m a b

-- | Fill histogram builder.
fillBuilder :: Foldable f => HBuilder a b -> f a -> b

-- | Fill histogram builder.
fillBuilderVec :: Vector v a => HBuilder a b -> v a -> b
forceInt :: Histogram v bin Int -> Histogram v bin Int
forceDouble :: Histogram v bin Double -> Histogram v bin Double
forceFloat :: Histogram v bin Float -> Histogram v bin Float

-- | Join histogram builders in a container.

-- | <i>Deprecated: Use Data.Traversable.sequenceA instead</i>
joinHBuilder :: Traversable f => f (HBuilder a b) -> HBuilder a (f b)

-- | Join histogram builders in a container

-- | <i>Deprecated: Use Data.Traversable.sequenceA instead</i>
joinHBuilderM :: (Traversable f, Monad m) => f (HBuilderM m a b) -> HBuilderM m a (f b)

-- | Apply functions to the builder

-- | <i>Deprecated: Use Data.Traversable.traverse. treeHBuilderM fs h =
--   F.traverse ($ h) fs</i>
treeHBuilderM :: (Monad m, Traversable f) => f (HBuilderM m a b -> HBuilderM m a' b') -> HBuilderM m a b -> HBuilderM m a' (f b')

-- | Apply function to a builder

-- | <i>Deprecated: Use Data.Traversable.traverse. treeHBuilderM fs h =
--   F.traverse ($ h) fs</i>
treeHBuilder :: Traversable f => f (HBuilder a b -> HBuilder a' b') -> HBuilder a b -> HBuilder a' (f b')
instance Data.Histogram.Fill.HistBuilder Data.Histogram.Fill.HBuilder
instance GHC.Base.Functor (Data.Histogram.Fill.HBuilder a)
instance GHC.Base.Applicative (Data.Histogram.Fill.HBuilder a)
instance GHC.Base.Semigroup b => GHC.Base.Semigroup (Data.Histogram.Fill.HBuilder a b)
instance GHC.Base.Monoid b => GHC.Base.Monoid (Data.Histogram.Fill.HBuilder a b)
instance GHC.Base.Monad m => Data.Histogram.Fill.HistBuilder (Data.Histogram.Fill.HBuilderM m)
instance GHC.Base.Monad m => GHC.Base.Functor (Data.Histogram.Fill.HBuilderM m a)
instance GHC.Base.Monad m => GHC.Base.Applicative (Data.Histogram.Fill.HBuilderM m a)
instance (GHC.Base.Monad m, GHC.Base.Semigroup b) => GHC.Base.Semigroup (Data.Histogram.Fill.HBuilderM m a b)
instance (GHC.Base.Monad m, GHC.Base.Monoid b) => GHC.Base.Monoid (Data.Histogram.Fill.HBuilderM m a b)
