Aleksey Khudyakov avatar Aleksey Khudyakov committed 222c956

Update documentation

Comments (0)

Files changed (1)

Data/Histogram/Fill.hs

 import Data.Histogram.Bin
 import Data.Histogram.ST
 
+
+
 ----------------------------------------------------------------
 -- Type class
 ----------------------------------------------------------------
 -- Monadic builder
 ----------------------------------------------------------------
 
--- | Stateful histogram builder. There is no direct way to construct
---   such builder. Only way to do it is to create 'HBuilder' and use
---   'toHBuilderST' or 'toHBuilderIO'.
+-- | Stateful histogram builder. Adding value to builder could be done
+--   with 'feedOne' and result could be extracted with
+--   'freezeHBuilderM'.
 --
---   It's useful when result should be extracted many times from the
---   same accumulator.
+--   There are two ways to obtain stateful builder. First and
+--   recommended is to thaw 'HBuilder' using 'toHBuilderIO' or
+--   'toHBuilderST'. Second is to use 'mkStatefulBuilder'.
 data HBuilderM m a b = HBuilderM { hbInput  :: a -> m ()
                                  , hbOutput :: m b
                                  }
 
+-- | Builders modified using 'HistBuilder' API will share same buffer.
 instance PrimMonad m => HistBuilder (HBuilderM m) where
     modifyIn    f h = h { hbInput  = hbInput h . f }
     addCut      f h = h { hbInput  = \x -> when (f x) (hbInput h x) }
 feedOne = hbInput
 {-# INLINE feedOne #-}
 
--- | Create stateful histogram from instructions. Histograms could
---   be filled either in the ST monad or with createHistograms
+-- | Extract result from histogram builder. It's safe to call this
+--   function multiple times and mutate builder afterwards.
 freezeHBuilderM :: PrimMonad m => HBuilderM m a b -> m b
 freezeHBuilderM = hbOutput
 {-# INLINE freezeHBuilderM #-}
 treeHBuilderM fs h = joinHBuilderM $ fmap ($ h) fs
 {-# INLINE treeHBuilderM #-}
 
+
+
 ----------------------------------------------------------------
 -- Stateless
 ----------------------------------------------------------------
 
 
 -- | Create histogram builder which just does ordinary pure fold. It
--- is intended for use when some fold should be performed together
--- with histogram filling
+--   is intended for use when some fold should be performed together
+--   with histogram filling
 mkFolder :: b -> (a -> b -> b) -> HBuilder a b
 mkFolder a f = HBuilder $ do
   ref <- newSTRef a
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.