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


-- | Measure allocations of a Haskell functions/values
--   
--   Please see README.md
@package weigh
@version 0.0.16


-- | Framework for seeing how much a function allocates.
--   
--   WARNING: weigh is incompatible with profiling. It reports much more
--   allocations with profiling turned on.
--   
--   Example:
--   
--   <pre>
--   import Weigh
--   main =
--     mainWith (do func "integers count 0" count 0
--                  func "integers count 1" count 1
--                  func "integers count 2" count 2
--                  func "integers count 3" count 3
--                  func "integers count 10" count 10
--                  func "integers count 100" count 100)
--     where count :: Integer -&gt; ()
--           count 0 = ()
--           count a = count (a - 1)
--   </pre>
--   
--   Use <a>wgroup</a> to group sets of tests.
module Weigh

-- | Just run the measuring and print a report. Uses <a>weighResults</a>.
mainWith :: Weigh a -> IO ()

-- | Run the measuring and return all the results, each one may have an
--   error.
weighResults :: Weigh a -> IO ([Grouped (Weight, Maybe String)], Config)

-- | Set the columns to display in the config
setColumns :: [Column] -> Weigh ()

-- | Table column.
data Column

-- | Case name for the column
Case :: Column

-- | Total bytes allocated
Allocated :: Column

-- | Total number of GCs
GCs :: Column

-- | Total amount of live data in the heap
Live :: Column

-- | Table column indicating about the test status
Check :: Column

-- | Maximum residency memory in use
Max :: Column

-- | Maximum memory in use by the RTS. Valid only for GHC &gt;= 8.2.2. For
--   unsupported GHC, this is reported as 0.
MaxOS :: Column

-- | Set the output format in the config
setFormat :: Format -> Weigh ()
data Format
Plain :: Format
Markdown :: Format

-- | Set the config. Default is: <a>defaultConfig</a>.
setConfig :: Config -> Weigh ()

-- | Weigh configuration.
data Config
Config :: [Column] -> String -> !Format -> Config
[configColumns] :: Config -> [Column]
[configPrefix] :: Config -> String
[configFormat] :: Config -> !Format

-- | Default config.
defaultConfig :: Config

-- | Weigh a function applied to an argument.
--   
--   Implemented in terms of <a>validateFunc</a>.
func :: NFData a => String -> (b -> a) -> b -> Weigh ()

-- | Weigh a function applied to an argument. Unlike <a>func</a>, the
--   argument is evaluated to normal form before the function is applied.
func' :: (NFData a, NFData b) => String -> (b -> a) -> b -> Weigh ()

-- | Weigh an action applied to an argument.
--   
--   Implemented in terms of <a>validateAction</a>.
io :: NFData a => String -> (b -> IO a) -> b -> Weigh ()

-- | Weigh a value.
--   
--   Implemented in terms of <a>action</a>.
value :: NFData a => String -> a -> Weigh ()

-- | Weigh an IO action.
--   
--   Implemented in terms of <a>validateAction</a>.
action :: NFData a => String -> IO a -> Weigh ()

-- | Make a grouping of tests.
wgroup :: String -> Weigh () -> Weigh ()

-- | Weigh an IO action, validating the result.
validateAction :: NFData a => String -> (b -> IO a) -> b -> (Weight -> Maybe String) -> Weigh ()

-- | Weigh a function, validating the result
validateFunc :: NFData a => String -> (b -> a) -> b -> (Weight -> Maybe String) -> Weigh ()

-- | Make a validator that set sthe maximum allocations.
maxAllocs :: Word64 -> Weight -> Maybe String

-- | Weigh specification monad.
data Weigh a

-- | How much a computation weighed in at.
data Weight
Weight :: !String -> !Word64 -> !Word32 -> !Word64 -> !Word64 -> !Word64 -> Weight
[weightLabel] :: Weight -> !String
[weightAllocatedBytes] :: Weight -> !Word64
[weightGCs] :: Weight -> !Word32
[weightLiveBytes] :: Weight -> !Word64
[weightMaxBytes] :: Weight -> !Word64
[weightMaxOSBytes] :: Weight -> !Word64

-- | Formatting an integral number to 1,000,000, etc.
commas :: (Num a, Integral a, Show a) => a -> String
reportGroup :: Config -> [Char] -> [Grouped (Weight, Maybe String)] -> [Char]

-- | Weigh a set of actions. The value of the actions are forced completely
--   to ensure they are fully allocated.
weighDispatch :: Maybe String -> [Grouped Action] -> IO (Maybe [Grouped Weight])

-- | Weigh a pure function. This function is built on top of
--   <a>weighFuncResult</a>, which is heavily documented inside
weighFunc :: NFData a => (b -> a) -> b -> IO (Word64, Word32, Word64, Word64, Word64)

-- | Weigh a pure function and return the result. This function is heavily
--   documented inside.
weighFuncResult :: NFData a => (b -> a) -> b -> IO (a, (Word64, Word32, Word64, Word64, Word64))

-- | Weigh an IO action. This function is based on
--   <a>weighActionResult</a>, which is heavily documented inside.
weighAction :: NFData a => (b -> IO a) -> b -> IO (Word64, Word32, Word64, Word64, Word64)

-- | Weigh an IO action, and return the result. This function is heavily
--   documented inside.
weighActionResult :: NFData a => (b -> IO a) -> b -> IO (a, (Word64, Word32, Word64, Word64, Word64))

-- | Some grouped thing.
data Grouped a
Grouped :: String -> [Grouped a] -> Grouped a
Singleton :: a -> Grouped a
instance GHC.Enum.Enum Weigh.Column
instance GHC.Classes.Eq Weigh.Column
instance GHC.Show.Show Weigh.Column
instance GHC.Show.Show Weigh.Format
instance GHC.Show.Show Weigh.Config
instance GHC.Show.Show Weigh.Weight
instance GHC.Read.Read Weigh.Weight
instance GHC.Generics.Generic (Weigh.Grouped a)
instance Data.Foldable.Foldable Weigh.Grouped
instance Data.Traversable.Traversable Weigh.Grouped
instance GHC.Base.Functor Weigh.Grouped
instance GHC.Show.Show a => GHC.Show.Show (Weigh.Grouped a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Weigh.Grouped a)
instance GHC.Base.Applicative Weigh.Weigh
instance GHC.Base.Functor Weigh.Weigh
instance GHC.Base.Monad Weigh.Weigh
instance Control.DeepSeq.NFData Weigh.Action
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Weigh.Grouped a)
