{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}

-- |
-- Module     : Simulation.Aivika.Trans.Results.Transform
-- Copyright  : Copyright (c) 2009-2017, David Sorokin <david.sorokin@gmail.com>
-- License    : BSD3
-- Maintainer : David Sorokin <david.sorokin@gmail.com>
-- Stability  : experimental
-- Tested with: GHC 8.0.1
--
-- The module defines useful result transformations that can
-- be used in simulation experiments.
--
module Simulation.Aivika.Trans.Results.Transform
       (-- * Basic Class Type
        ResultTransformer(..),
        -- * Sampling Statistics
        SamplingStats(..),
        samplingStatsCount,
        samplingStatsMin,
        samplingStatsMax,
        samplingStatsMean,
        samplingStatsMean2,
        samplingStatsVariance,
        samplingStatsDeviation,
        -- * Time-dependent Statistics
        TimingStats(..),
        timingStatsCount,
        timingStatsMin,
        timingStatsMax,
        timingStatsMean,
        timingStatsVariance,
        timingStatsDeviation,
        timingStatsMinTime,
        timingStatsMaxTime,
        timingStatsStartTime,
        timingStatsLastTime,
        timingStatsSum,
        timingStatsSum2,
        -- * Sampling-based Counter
        SamplingCounter(..),
        samplingCounterValue,
        samplingCounterStats,
        -- * Time-dependent Counter
        TimingCounter(..),
        timingCounterValue,
        timingCounterStats,
        -- * Queue
        Queue(..),
        enqueueStrategy,
        enqueueStoringStrategy,
        dequeueStrategy,
        queueNull,
        queueFull,
        queueMaxCount,
        queueCount,
        queueCountStats,
        enqueueCount,
        enqueueLostCount,
        enqueueStoreCount,
        dequeueCount,
        dequeueExtractCount,
        queueLoadFactor,
        enqueueRate,
        enqueueStoreRate,
        dequeueRate,
        dequeueExtractRate,
        queueWaitTime,
        queueTotalWaitTime,
        enqueueWaitTime,
        dequeueWaitTime,
        queueRate,
        -- * Arrival Timer
        ArrivalTimer(..),
        arrivalProcessingTime,
        -- * Server
        Server(..),
        serverInitState,
        serverState,
        serverTotalInputWaitTime,
        serverTotalProcessingTime,
        serverTotalOutputWaitTime,
        serverTotalPreemptionTime,
        serverInputWaitTime,
        serverProcessingTime,
        serverOutputWaitTime,
        serverPreemptionTime,
        serverInputWaitFactor,
        serverProcessingFactor,
        serverOutputWaitFactor,
        serverPreemptionFactor,
        -- * Activity
        Activity(..),
        activityInitState,
        activityState,
        activityTotalUtilisationTime,
        activityTotalIdleTime,
        activityTotalPreemptionTime,
        activityUtilisationTime,
        activityIdleTime,
        activityPreemptionTime,
        activityUtilisationFactor,
        activityIdleFactor,
        activityPreemptionFactor,
        -- * Resource
        Resource(..),
        resourceCount,
        resourceCountStats,
        resourceUtilisationCount,
        resourceUtilisationCountStats,
        resourceQueueCount,
        resourceQueueCountStats,
        resourceTotalWaitTime,
        resourceWaitTime,
        -- * Operation
        Operation(..),
        operationTotalUtilisationTime,
        operationTotalPreemptionTime,
        operationUtilisationTime,
        operationPreemptionTime,
        operationUtilisationFactor,
        operationPreemptionFactor) where

import Control.Arrow

import Simulation.Aivika.Trans.DES
import Simulation.Aivika.Trans.Results
import Simulation.Aivika.Trans.Results.Locale

-- | Something that can transform the results.
class ResultTransformer t m where

  -- | Return the result transform.
  tr :: t m -> ResultTransform m

-- | Represents a statistics based upon observations.
newtype SamplingStats m = SamplingStats (ResultTransform m)

instance ResultTransformer SamplingStats m where
  tr :: SamplingStats m -> ResultTransform m
tr (SamplingStats ResultTransform m
a) = ResultTransform m
a

-- | The total number of samples.
samplingStatsCount :: MonadDES m => SamplingStats m -> ResultTransform m
samplingStatsCount :: SamplingStats m -> ResultTransform m
samplingStatsCount (SamplingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingStatsCountId

-- | The minimum value among the samples.
samplingStatsMin :: MonadDES m => SamplingStats m -> ResultTransform m
samplingStatsMin :: SamplingStats m -> ResultTransform m
samplingStatsMin (SamplingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingStatsMinId

-- | The maximum value among the samples.
samplingStatsMax :: MonadDES m => SamplingStats m -> ResultTransform m
samplingStatsMax :: SamplingStats m -> ResultTransform m
samplingStatsMax (SamplingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingStatsMaxId
  
-- | The average value.
samplingStatsMean :: MonadDES m => SamplingStats m -> ResultTransform m
samplingStatsMean :: SamplingStats m -> ResultTransform m
samplingStatsMean (SamplingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingStatsMeanId

-- | The average square value.
samplingStatsMean2 :: MonadDES m => SamplingStats m -> ResultTransform m
samplingStatsMean2 :: SamplingStats m -> ResultTransform m
samplingStatsMean2 (SamplingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingStatsMean2Id

-- | Return tha variance.
samplingStatsVariance :: MonadDES m => SamplingStats m -> ResultTransform m
samplingStatsVariance :: SamplingStats m -> ResultTransform m
samplingStatsVariance (SamplingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingStatsVarianceId

-- | Return the deviation.
samplingStatsDeviation :: MonadDES m => SamplingStats m -> ResultTransform m
samplingStatsDeviation :: SamplingStats m -> ResultTransform m
samplingStatsDeviation (SamplingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingStatsDeviationId

-- | A counter for which the statistics is collected too.
newtype SamplingCounter m = SamplingCounter (ResultTransform m)

instance ResultTransformer SamplingCounter m where
  tr :: SamplingCounter m -> ResultTransform m
tr (SamplingCounter ResultTransform m
a) = ResultTransform m
a

-- | The counter value.
samplingCounterValue :: SamplingCounter m -> ResultTransform m
samplingCounterValue :: SamplingCounter m -> ResultTransform m
samplingCounterValue (SamplingCounter ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingCounterValueId

-- | The counter statistics.
samplingCounterStats :: SamplingCounter m -> SamplingStats m
samplingCounterStats :: SamplingCounter m -> SamplingStats m
samplingCounterStats (SamplingCounter ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
SamplingCounterStatsId)

-- | The time-dependent statistics.
newtype TimingStats m = TimingStats (ResultTransform m)

instance ResultTransformer TimingStats m where
  tr :: TimingStats m -> ResultTransform m
tr (TimingStats ResultTransform m
a) = ResultTransform m
a

-- | Return the number of samples.
timingStatsCount :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsCount :: TimingStats m -> ResultTransform m
timingStatsCount (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsCountId

-- | Return the minimum value.
timingStatsMin :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsMin :: TimingStats m -> ResultTransform m
timingStatsMin (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsMinId

-- | Return the maximum value.
timingStatsMax :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsMax :: TimingStats m -> ResultTransform m
timingStatsMax (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsMaxId

-- | Return the average value.
timingStatsMean :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsMean :: TimingStats m -> ResultTransform m
timingStatsMean (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsMeanId

-- | Return the variance.
timingStatsVariance :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsVariance :: TimingStats m -> ResultTransform m
timingStatsVariance (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsVarianceId

-- | Return the deviation.
timingStatsDeviation :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsDeviation :: TimingStats m -> ResultTransform m
timingStatsDeviation (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsDeviationId

-- | Return the time at which the minimum is attained.
timingStatsMinTime :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsMinTime :: TimingStats m -> ResultTransform m
timingStatsMinTime (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsMinTimeId

-- | Return the time at which the maximum is attained.
timingStatsMaxTime :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsMaxTime :: TimingStats m -> ResultTransform m
timingStatsMaxTime (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsMaxTimeId

-- | Return the start time of sampling.
timingStatsStartTime :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsStartTime :: TimingStats m -> ResultTransform m
timingStatsStartTime (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsStartTimeId

-- | Return the last time of sampling.
timingStatsLastTime :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsLastTime :: TimingStats m -> ResultTransform m
timingStatsLastTime (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsLastTimeId

-- | Return the sum of values.
timingStatsSum :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsSum :: TimingStats m -> ResultTransform m
timingStatsSum (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsSumId

-- | Return the sum of square values.
timingStatsSum2 :: MonadDES m => TimingStats m -> ResultTransform m
timingStatsSum2 :: TimingStats m -> ResultTransform m
timingStatsSum2 (TimingStats ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultTransform m
forall (m :: * -> *). MonadDES m => ResultTransform m
expandResults ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingStatsSum2Id

-- | A time-dependent counter that collects the statistics too.
newtype TimingCounter m = TimingCounter (ResultTransform m)

instance ResultTransformer TimingCounter m where
  tr :: TimingCounter m -> ResultTransform m
tr (TimingCounter ResultTransform m
a) = ResultTransform m
a

-- | The counter value.
timingCounterValue :: TimingCounter m -> ResultTransform m
timingCounterValue :: TimingCounter m -> ResultTransform m
timingCounterValue (TimingCounter ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingCounterValueId

-- | The counter statistics.
timingCounterStats :: TimingCounter m -> TimingStats m
timingCounterStats :: TimingCounter m -> TimingStats m
timingCounterStats (TimingCounter ResultTransform m
a) =
  ResultTransform m -> TimingStats m
forall (m :: * -> *). ResultTransform m -> TimingStats m
TimingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
TimingCounterStatsId)

-- | Represents either finite or infinite queue.
newtype Queue m = Queue (ResultTransform m)

instance ResultTransformer Queue m where
  tr :: Queue m -> ResultTransform m
tr (Queue ResultTransform m
a) = ResultTransform m
a

-- | The strategy applied to the enqueueing (input) processes when the finite queue is full.
enqueueStrategy :: Queue m -> ResultTransform m
enqueueStrategy :: Queue m -> ResultTransform m
enqueueStrategy (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
EnqueueStrategyId

-- | The strategy applied when storing (in memory) items in the queue.
enqueueStoringStrategy :: Queue m -> ResultTransform m
enqueueStoringStrategy :: Queue m -> ResultTransform m
enqueueStoringStrategy (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
EnqueueStoringStrategyId

-- | The strategy applied to the dequeueing (output) processes when the queue is empty.
dequeueStrategy :: Queue m -> ResultTransform m
dequeueStrategy :: Queue m -> ResultTransform m
dequeueStrategy (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
DequeueStrategyId

-- | Test whether the queue is empty.
queueNull :: Queue m -> ResultTransform m
queueNull :: Queue m -> ResultTransform m
queueNull (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueNullId

-- | Test whether the finite queue is full.
queueFull :: Queue m -> ResultTransform m
queueFull :: Queue m -> ResultTransform m
queueFull (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueFullId

-- | The finite queue capacity.
queueMaxCount :: Queue m -> ResultTransform m
queueMaxCount :: Queue m -> ResultTransform m
queueMaxCount (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueMaxCountId

-- | Return the current queue size.
queueCount :: Queue m -> ResultTransform m
queueCount :: Queue m -> ResultTransform m
queueCount (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueCountId

-- | Return the queue size statistics.
queueCountStats :: Queue m -> TimingStats m
queueCountStats :: Queue m -> TimingStats m
queueCountStats (Queue ResultTransform m
a) =
  ResultTransform m -> TimingStats m
forall (m :: * -> *). ResultTransform m -> TimingStats m
TimingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueCountStatsId)

-- | Return the total number of input items that were enqueued in the finite queue.
enqueueCount :: Queue m -> ResultTransform m
enqueueCount :: Queue m -> ResultTransform m
enqueueCount (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
EnqueueCountId

-- | Return the number of lost items for the finite queue.
enqueueLostCount :: Queue m -> ResultTransform m
enqueueLostCount :: Queue m -> ResultTransform m
enqueueLostCount (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
EnqueueLostCountId

-- | Return the total number of input items that were stored.
enqueueStoreCount :: Queue m -> ResultTransform m
enqueueStoreCount :: Queue m -> ResultTransform m
enqueueStoreCount (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
EnqueueStoreCountId

-- | Return the total number of requests for dequeueing the items, not taking
-- into account the failed attempts to dequeue immediately without suspension.
dequeueCount :: Queue m -> ResultTransform m
dequeueCount :: Queue m -> ResultTransform m
dequeueCount (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
DequeueCountId

-- | Return the total number of output items that were actually dequeued.
dequeueExtractCount :: Queue m -> ResultTransform m
dequeueExtractCount :: Queue m -> ResultTransform m
dequeueExtractCount (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
DequeueExtractCountId

-- | Return the load factor: the finite queue size divided by its capacity.
queueLoadFactor :: Queue m -> ResultTransform m
queueLoadFactor :: Queue m -> ResultTransform m
queueLoadFactor (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueLoadFactorId

-- | Return the rate of the input items that were enqueued in the finite queue:
-- how many items per time.
enqueueRate :: Queue m -> ResultTransform m
enqueueRate :: Queue m -> ResultTransform m
enqueueRate (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
EnqueueRateId

-- | Return the rate of the items that were stored: how many items per time.
enqueueStoreRate :: Queue m -> ResultTransform m
enqueueStoreRate :: Queue m -> ResultTransform m
enqueueStoreRate (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
EnqueueStoreRateId

-- | Return the rate of the requests for dequeueing the items: how many
-- requests per time. It does not include the failed attempts to dequeue
-- immediately without suspension.
dequeueRate :: Queue m -> ResultTransform m
dequeueRate :: Queue m -> ResultTransform m
dequeueRate (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
DequeueRateId

-- | Return the rate of the output items that were dequeued: how many items per time.
dequeueExtractRate :: Queue m -> ResultTransform m
dequeueExtractRate :: Queue m -> ResultTransform m
dequeueExtractRate (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
DequeueExtractRateId

-- | Return the wait time from the time at which the item was stored in
-- the queue to the time at which it was dequeued.
queueWaitTime :: Queue m -> SamplingStats m
queueWaitTime :: Queue m -> SamplingStats m
queueWaitTime (Queue ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueWaitTimeId)

-- | Return the total wait time for the finite queue from the time at which
-- the enqueueing operation was initiated to the time at which the item was dequeued.
queueTotalWaitTime :: Queue m -> SamplingStats m
queueTotalWaitTime :: Queue m -> SamplingStats m
queueTotalWaitTime (Queue ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueTotalWaitTimeId)

-- | Return the wait time from the time at which the item was stored in
-- the queue to the time at which it was dequeued.
enqueueWaitTime :: Queue m -> SamplingStats m
enqueueWaitTime :: Queue m -> SamplingStats m
enqueueWaitTime (Queue ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
EnqueueWaitTimeId)

-- | Return the dequeue wait time from the time at which the item was requested
-- for dequeueing to the time at which it was actually dequeued.
dequeueWaitTime :: Queue m -> SamplingStats m
dequeueWaitTime :: Queue m -> SamplingStats m
dequeueWaitTime (Queue ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
DequeueWaitTimeId)

-- | Return a long-term average queue rate calculated as the average queue size
-- divided by the average wait time.
queueRate :: Queue m -> ResultTransform m
queueRate :: Queue m -> ResultTransform m
queueRate (Queue ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
QueueRateId

-- | Accumulates the statistics about that how long the arrived events are processed.
newtype ArrivalTimer m = ArrivalTimer (ResultTransform m)

instance ResultTransformer ArrivalTimer m where
  tr :: ArrivalTimer m -> ResultTransform m
tr (ArrivalTimer ResultTransform m
a) = ResultTransform m
a

-- | Return the statistics about that how long the arrived events were processed.
arrivalProcessingTime :: ArrivalTimer m -> SamplingStats m
arrivalProcessingTime :: ArrivalTimer m -> SamplingStats m
arrivalProcessingTime (ArrivalTimer ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ArrivalProcessingTimeId)

-- | It models the server that prodives a service.
newtype Server m = Server (ResultTransform m)

instance ResultTransformer Server m where
  tr :: Server m -> ResultTransform m
tr (Server ResultTransform m
a) = ResultTransform m
a

-- | The initial state of the server.
serverInitState :: Server m -> ResultTransform m
serverInitState :: Server m -> ResultTransform m
serverInitState (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerInitStateId

-- | Return the current state of the server.
serverState :: Server m -> ResultTransform m
serverState :: Server m -> ResultTransform m
serverState (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerStateId

-- | Return the counted total time when the server was locked while
-- awaiting the input.
serverTotalInputWaitTime :: Server m -> ResultTransform m
serverTotalInputWaitTime :: Server m -> ResultTransform m
serverTotalInputWaitTime (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerTotalInputWaitTimeId

-- | Return the counted total time spent by the server while
-- processing the tasks.
serverTotalProcessingTime :: Server m -> ResultTransform m
serverTotalProcessingTime :: Server m -> ResultTransform m
serverTotalProcessingTime (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerTotalProcessingTimeId

-- | Return the counted total time when the server was locked while
-- trying to deliver the output.
serverTotalOutputWaitTime :: Server m -> ResultTransform m
serverTotalOutputWaitTime :: Server m -> ResultTransform m
serverTotalOutputWaitTime (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerTotalOutputWaitTimeId

-- | Return the counted total time spent by the server while it was
-- preempted waiting for the further proceeding.
serverTotalPreemptionTime :: Server m -> ResultTransform m
serverTotalPreemptionTime :: Server m -> ResultTransform m
serverTotalPreemptionTime (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerTotalPreemptionTimeId

-- | Return the statistics of the time when the server was locked
-- while awaiting the input.
serverInputWaitTime :: Server m -> SamplingStats m
serverInputWaitTime :: Server m -> SamplingStats m
serverInputWaitTime (Server ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerInputWaitTimeId)

-- | Return the statistics of the time spent by the server while
-- processing the tasks.
serverProcessingTime :: Server m -> SamplingStats m
serverProcessingTime :: Server m -> SamplingStats m
serverProcessingTime (Server ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerProcessingTimeId)

-- | Return the statistics of the time when the server was locked
-- while trying to deliver the output.
serverOutputWaitTime :: Server m -> SamplingStats m
serverOutputWaitTime :: Server m -> SamplingStats m
serverOutputWaitTime (Server ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerOutputWaitTimeId)

-- | Return the statistics of the time spent by the server while
-- it was preempted waiting for the further proceeding.
serverPreemptionTime :: Server m -> SamplingStats m
serverPreemptionTime :: Server m -> SamplingStats m
serverPreemptionTime (Server ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerPreemptionTimeId)

-- | It returns the factor changing from 0 to 1, which estimates
-- how often the server was awaiting for the next input task.
serverInputWaitFactor :: Server m -> ResultTransform m
serverInputWaitFactor :: Server m -> ResultTransform m
serverInputWaitFactor (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerInputWaitFactorId

-- | It returns the factor changing from 0 to 1, which estimates
-- how often the server was busy with direct processing its tasks.
serverProcessingFactor :: Server m -> ResultTransform m
serverProcessingFactor :: Server m -> ResultTransform m
serverProcessingFactor (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerProcessingFactorId

-- | It returns the factor changing from 0 to 1, which estimates
-- how often the server was locked trying to deliver the output
-- after the task is finished.
serverOutputWaitFactor :: Server m -> ResultTransform m
serverOutputWaitFactor :: Server m -> ResultTransform m
serverOutputWaitFactor (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerOutputWaitFactorId

-- | It returns the factor changing from 0 to 1, which estimates
-- how often the server was preempted waiting for the further proceeding.
serverPreemptionFactor :: Server m -> ResultTransform m
serverPreemptionFactor :: Server m -> ResultTransform m
serverPreemptionFactor (Server ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ServerPreemptionFactorId

-- | It models an activity that can be utilised.
newtype Activity m = Activity (ResultTransform m)

instance ResultTransformer Activity m where
  tr :: Activity m -> ResultTransform m
tr (Activity ResultTransform m
a) = ResultTransform m
a

-- | The initial state of the activity.
activityInitState :: Activity m -> ResultTransform m
activityInitState :: Activity m -> ResultTransform m
activityInitState (Activity ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityInitStateId

-- | Return the current state of the activity.
activityState :: Activity m -> ResultTransform m
activityState :: Activity m -> ResultTransform m
activityState (Activity ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityStateId

-- | Return the counted total time when the activity was utilised.
activityTotalUtilisationTime :: Activity m -> ResultTransform m
activityTotalUtilisationTime :: Activity m -> ResultTransform m
activityTotalUtilisationTime (Activity ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityTotalUtilisationTimeId

-- | Return the counted total time when the activity was idle.
activityTotalIdleTime :: Activity m -> ResultTransform m
activityTotalIdleTime :: Activity m -> ResultTransform m
activityTotalIdleTime (Activity ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityTotalIdleTimeId

-- | Return the counted total time when the activity was preemted
-- waiting for the further proceeding.
activityTotalPreemptionTime :: Activity m -> ResultTransform m
activityTotalPreemptionTime :: Activity m -> ResultTransform m
activityTotalPreemptionTime (Activity ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityTotalPreemptionTimeId

-- | Return the statistics for the time when the activity was utilised.
activityUtilisationTime :: Activity m -> SamplingStats m
activityUtilisationTime :: Activity m -> SamplingStats m
activityUtilisationTime (Activity ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityUtilisationTimeId)

-- | Return the statistics for the time when the activity was idle.
activityIdleTime :: Activity m -> SamplingStats m
activityIdleTime :: Activity m -> SamplingStats m
activityIdleTime (Activity ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityIdleTimeId)

-- | Return the statistics for the time when the activity was preempted
-- waiting for the further proceeding.
activityPreemptionTime :: Activity m -> SamplingStats m
activityPreemptionTime :: Activity m -> SamplingStats m
activityPreemptionTime (Activity ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityPreemptionTimeId)

-- | It returns the factor changing from 0 to 1, which estimates how often
-- the activity was utilised.
activityUtilisationFactor :: Activity m -> ResultTransform m
activityUtilisationFactor :: Activity m -> ResultTransform m
activityUtilisationFactor (Activity ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityUtilisationFactorId

-- | It returns the factor changing from 0 to 1, which estimates how often
-- the activity was idle.
activityIdleFactor :: Activity m -> ResultTransform m
activityIdleFactor :: Activity m -> ResultTransform m
activityIdleFactor (Activity ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityIdleFactorId

-- | It returns the factor changing from 0 to 1, which estimates how often
-- the activity was preempted waiting for the further proceeding.
activityPreemptionFactor :: Activity m -> ResultTransform m
activityPreemptionFactor :: Activity m -> ResultTransform m
activityPreemptionFactor (Activity ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ActivityPreemptionFactorId

-- | The resource which can be acquired and then released.
newtype Resource m = Resource (ResultTransform m)

instance ResultTransformer Resource m where
  tr :: Resource m -> ResultTransform m
tr (Resource ResultTransform m
a) = ResultTransform m
a

-- | Return the current available count of the resource.
resourceCount :: Resource m -> ResultTransform m
resourceCount :: Resource m -> ResultTransform m
resourceCount (Resource ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ResourceCountId

-- | Return the statistics for the available count of the resource.
resourceCountStats :: Resource m -> TimingStats m
resourceCountStats :: Resource m -> TimingStats m
resourceCountStats (Resource ResultTransform m
a) =
  ResultTransform m -> TimingStats m
forall (m :: * -> *). ResultTransform m -> TimingStats m
TimingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ResourceCountStatsId)

-- | Return the current utilisation count of the resource.
resourceUtilisationCount :: Resource m -> ResultTransform m
resourceUtilisationCount :: Resource m -> ResultTransform m
resourceUtilisationCount (Resource ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ResourceUtilisationCountId

-- | Return the statistics for the utilisation count of the resource.
resourceUtilisationCountStats :: Resource m -> TimingStats m
resourceUtilisationCountStats :: Resource m -> TimingStats m
resourceUtilisationCountStats (Resource ResultTransform m
a) =
  ResultTransform m -> TimingStats m
forall (m :: * -> *). ResultTransform m -> TimingStats m
TimingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ResourceUtilisationCountStatsId)

-- | Return the current queue length of the resource.
resourceQueueCount :: Resource m -> ResultTransform m
resourceQueueCount :: Resource m -> ResultTransform m
resourceQueueCount (Resource ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ResourceQueueCountId

-- | Return the statistics for the queue length of the resource.
resourceQueueCountStats :: Resource m -> TimingStats m
resourceQueueCountStats :: Resource m -> TimingStats m
resourceQueueCountStats (Resource ResultTransform m
a) =
  ResultTransform m -> TimingStats m
forall (m :: * -> *). ResultTransform m -> TimingStats m
TimingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ResourceQueueCountStatsId)

-- | Return the total wait time of the resource.
resourceTotalWaitTime :: Resource m -> ResultTransform m
resourceTotalWaitTime :: Resource m -> ResultTransform m
resourceTotalWaitTime (Resource ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ResourceTotalWaitTimeId

-- | Return the statistics for the wait time of the resource.
resourceWaitTime :: Resource m -> SamplingStats m
resourceWaitTime :: Resource m -> SamplingStats m
resourceWaitTime (Resource ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
ResourceWaitTimeId)

-- | It models an opreation which actvity can be utilised.
newtype Operation m = Operation (ResultTransform m)

instance ResultTransformer Operation m where
  tr :: Operation m -> ResultTransform m
tr (Operation ResultTransform m
a) = ResultTransform m
a

-- | Return the counted total time when the operation activity was utilised.
operationTotalUtilisationTime :: Operation m -> ResultTransform m
operationTotalUtilisationTime :: Operation m -> ResultTransform m
operationTotalUtilisationTime (Operation ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
OperationTotalUtilisationTimeId

-- | Return the counted total time when the operation activity was preemted
-- waiting for the further proceeding.
operationTotalPreemptionTime :: Operation m -> ResultTransform m
operationTotalPreemptionTime :: Operation m -> ResultTransform m
operationTotalPreemptionTime (Operation ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
OperationTotalPreemptionTimeId

-- | Return the statistics for the time when the operation activity was utilised.
operationUtilisationTime :: Operation m -> SamplingStats m
operationUtilisationTime :: Operation m -> SamplingStats m
operationUtilisationTime (Operation ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
OperationUtilisationTimeId)

-- | Return the statistics for the time when the operation activity was preempted
-- waiting for the further proceeding.
operationPreemptionTime :: Operation m -> SamplingStats m
operationPreemptionTime :: Operation m -> SamplingStats m
operationPreemptionTime (Operation ResultTransform m
a) =
  ResultTransform m -> SamplingStats m
forall (m :: * -> *). ResultTransform m -> SamplingStats m
SamplingStats (ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
OperationPreemptionTimeId)

-- | It returns the factor changing from 0 to 1, which estimates how often
-- the operation activity was utilised.
operationUtilisationFactor :: Operation m -> ResultTransform m
operationUtilisationFactor :: Operation m -> ResultTransform m
operationUtilisationFactor (Operation ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
OperationUtilisationFactorId

-- | It returns the factor changing from 0 to 1, which estimates how often
-- the operation activity was preempted waiting for the further proceeding.
operationPreemptionFactor :: Operation m -> ResultTransform m
operationPreemptionFactor :: Operation m -> ResultTransform m
operationPreemptionFactor (Operation ResultTransform m
a) =
  ResultTransform m
a ResultTransform m -> ResultTransform m -> ResultTransform m
forall k (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
Category cat =>
cat a b -> cat b c -> cat a c
>>> ResultId -> ResultTransform m
forall (m :: * -> *). ResultId -> ResultTransform m
resultById ResultId
OperationPreemptionFactorId