    {-# LANGUAGE CPP #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE ViewPatterns #-}
    {-# LANGUAGE TypeApplications #-}
    module GHC.RTS.Events.Binary
      ( -- * Readers
        getHeader
      , getEvent
      , standardParsers
      , mercuryParsers
      , perfParsers
      , heapProfParsers
      , timeProfParsers
      , parRTSParsers
      , binaryEventParsers
      , tickyParsers

      -- * Writers
      , putEventLog
      , putHeader
      , putEvent

      -- * Perf events
      , nEVENT_PERF_NAME
      , nEVENT_PERF_COUNTER
      , nEVENT_PERF_TRACEPOINT

      ) where
    import Control.Exception (assert)
    import Control.Monad
    import Data.List (intersperse)
    import Data.Maybe
    import Data.Int
    import Prelude hiding (gcd, rem, id)

    import Data.Array
    import Data.Binary
    import Data.Binary.Put
    import qualified Data.Binary.Get as G
    import qualified Data.ByteString as B
    import qualified Data.Text as T
    import qualified Data.Text.Read as TR
    import qualified Data.Text.Encoding as TE
    import qualified Data.Vector.Unboxed as VU

    import GHC.RTS.EventTypes
    import GHC.RTS.EventParserUtils

    #define EVENTLOG_CONSTANTS_ONLY
    #include "EventLogFormat.h"

    getEventType :: Get EventType
    getEventType :: Get EventType
    getEventType = do
               etNum <- Get EventTypeNum
    forall t. Binary t => Get t
    get
               size <- get :: Get EventTypeSize
               let etSize = if EventTypeNum
    size EventTypeNum -> EventTypeNum -> Bool
    forall a. Eq a => a -> a -> Bool
    == EventTypeNum
    0xffff then Maybe EventTypeNum
    forall a. Maybe a
    Nothing else EventTypeNum -> Maybe EventTypeNum
    forall a. a -> Maybe a
    Just EventTypeNum
    size
               -- 0xffff indicates variable-sized event
               etDescLen <- get :: Get EventTypeDescLen
               etDesc <- getText etDescLen
               etExtraLen <- get :: Get Word32
               G.skip (fromIntegral etExtraLen)
               ete <- get :: Get Marker
               when (ete /= EVENT_ET_END) $
                  fail "Event Type end marker not found."
               return (EventType etNum etDesc etSize)

    getHeader :: Get Header
    getHeader :: Get Header
    getHeader = do
                hdrb <- Get Word32
    forall t. Binary t => Get t
    get :: Get Marker
                when (hdrb /= EVENT_HEADER_BEGIN) $
                     fail "Header begin marker not found"
                hetm <- get :: Get Marker
                when (hetm /= EVENT_HET_BEGIN) $
                     fail "Header Event Type begin marker not found"
                ets <- getEventTypes
                emark <- get :: Get Marker
                when (emark /= EVENT_HEADER_END) $
                     fail "Header end marker not found"
                db <- get :: Get Marker
                when (db /= EVENT_DATA_BEGIN) $
                      fail "My Data begin marker not found"
                return $ Header ets
         where
          getEventTypes :: Get [EventType]
          getEventTypes :: Get [EventType]
    getEventTypes = do
              m <- Get Word32
    forall t. Binary t => Get t
    get :: Get Marker
              case m of
                 EVENT_ET_BEGIN -> do
                      et <- getEventType
                      nextET <- getEventTypes
                      return (et : nextET)
                 EVENT_HET_END ->
                      return []
                 Word32
    _ ->
                      String -> Get [EventType]
    forall a. String -> Get a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail String
    "Malformed list of Event Types in header"

    getEvent :: EventParsers -> Get (Maybe Event)
    getEvent :: EventParsers -> Get (Maybe Event)
    getEvent (EventParsers Array Int (Get EventInfo)
    parsers) = do
      etRef <- Get EventTypeNum
    forall t. Binary t => Get t
    get :: Get EventTypeNum
      if etRef == EVENT_DATA_END
         then return Nothing
         else do !evTime   <- get
                 evSpec <- parsers ! fromIntegral etRef
                 return $ Just Event { evCap = undefined, .. }

    --
    -- standardEventParsers.
    --
    standardParsers :: [EventParser EventInfo]
    standardParsers :: [EventParser EventInfo]
    standardParsers = [
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_STARTUP sz_cap (do -- (n_caps)
          c <- get :: Get CapNo
          return Startup{ n_caps = fromIntegral c }
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_BLOCK_MARKER (sz_block_size + sz_time + sz_cap) (do -- (size, end_time, cap)
          block_size <- get :: Get BlockSize
          end_time <- get :: Get Timestamp
          c <- get :: Get CapNo
          return EventBlock { end_time   = end_time,
                              cap        = fromIntegral c,
                              block_size = ((fromIntegral block_size) -
                                            (fromIntegral sz_block_event))
                            }
       )),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_REQUEST_SEQ_GC RequestSeqGC),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_REQUEST_PAR_GC RequestParGC),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_GC_START StartGC),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_GC_WORK GCWork),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_GC_IDLE GCIdle),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_GC_DONE GCDone),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_GC_END EndGC),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_GC_GLOBAL_SYNC GlobalSyncGC),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_GC_STATS_GHC (sz_capset + 2 + 5*8 + 4) (do  -- (heap_capset, generation, copied_bytes, slop_bytes, frag_bytes, par_n_threads, par_max_copied, par_tot_copied)
          heapCapset   <- Get Word32
    forall t. Binary t => Get t
    get
          gen          <- get :: Get Word16
          copied       <- get :: Get Word64
          slop         <- get :: Get Word64
          frag         <- get :: Get Word64
          parNThreads  <- get :: Get Word32
          parMaxCopied <- get :: Get Word64
          parTotCopied <- get :: Get Word64
          return GCStatsGHC{ gen = fromIntegral gen
                           , parNThreads = fromIntegral parNThreads
                           , parBalancedCopied = Nothing
                           , ..}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_GC_STATS_GHC (sz_capset + 2 + 5*8 + 4 + 8) (do  -- (heap_capset, generation, copied_bytes, slop_bytes, frag_bytes, par_n_threads, par_max_copied, par_tot_copied, par_balanced_copied)
          heapCapset   <- Get Word32
    forall t. Binary t => Get t
    get
          gen          <- get :: Get Word16
          copied       <- get :: Get Word64
          slop         <- get :: Get Word64
          frag         <- get :: Get Word64
          parNThreads  <- get :: Get Word32
          parMaxCopied <- get :: Get Word64
          parTotCopied <- get :: Get Word64
          parBalancedCopied <- get :: Get Word64
          return GCStatsGHC{ gen = fromIntegral gen
                           , parNThreads = fromIntegral parNThreads
                           , parBalancedCopied = Just parBalancedCopied
                           , ..}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MEM_RETURN (sz_capset + 3*4) (do
          heapCapset   <- get
          current      <- get :: Get Word32
          needed       <- get :: Get Word32
          returned     <- get :: Get Word32
          return $! MemReturn{ current = current
                           , needed = needed
                           , returned = returned
                           , ..}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_HEAP_ALLOCATED (sz_capset + 8) (do  -- (heap_capset, alloc_bytes)
          heapCapset <- get
          allocBytes <- get
          return HeapAllocated{..}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_HEAP_SIZE (sz_capset + 8) (do  -- (heap_capset, size_bytes)
          heapCapset <- get
          sizeBytes  <- get
          return HeapSize{..}
     )),
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_BLOCKS_SIZE (sz_capset + 8) (do  -- (heap_capset, blocks_size)
          heapCapset <- get
          blocksSize  <- get
          return $! BlocksSize{..}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_HEAP_LIVE (sz_capset + 8) (do  -- (heap_capset, live_bytes)
          heapCapset <- get
          liveBytes  <- get
          return HeapLive{..}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_HEAP_INFO_GHC (sz_capset + 2 + 4*8) (do  -- (heap_capset, n_generations, max_heap_size, alloc_area_size, mblock_size, block_size)
          heapCapset    <- get
          gens          <- get :: Get Word16
          maxHeapSize   <- get :: Get Word64
          allocAreaSize <- get :: Get Word64
          mblockSize    <- get :: Get Word64
          blockSize     <- get :: Get Word64
          return HeapInfoGHC{gens = fromIntegral gens, ..}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CAP_CREATE (sz_cap) (do  -- (cap)
          cap <- get :: Get CapNo
          return CapCreate{cap = fromIntegral cap}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CAP_DELETE (sz_cap) (do  -- (cap)
          cap <- get :: Get CapNo
          return CapDelete{cap = fromIntegral cap}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CAP_DISABLE (sz_cap) (do  -- (cap)
          cap <- get :: Get CapNo
          return CapDisable{cap = fromIntegral cap}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CAP_ENABLE (sz_cap) (do  -- (cap)
          cap <- get :: Get CapNo
          return CapEnable{cap = fromIntegral cap}
     )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CAPSET_CREATE (sz_capset + sz_capset_type) (do -- (capset, capset_type)
          cs <- Get Word32
    forall t. Binary t => Get t
    get
          ct <- fmap mkCapsetType get
          return CapsetCreate{capset=cs,capsetType=ct}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CAPSET_DELETE sz_capset (do -- (capset)
          cs <- get
          return CapsetDelete{capset=cs}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CAPSET_ASSIGN_CAP (sz_capset + sz_cap) (do -- (capset, cap)
          cs <- Get Word32
    forall t. Binary t => Get t
    get
          cp <- get :: Get CapNo
          return CapsetAssignCap{capset=cs,cap=fromIntegral cp}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CAPSET_REMOVE_CAP (sz_capset + sz_cap) (do -- (capset, cap)
          cs <- Get Word32
    forall t. Binary t => Get t
    get
          cp <- get :: Get CapNo
          return CapsetRemoveCap{capset=cs,cap=fromIntegral cp}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_OSPROCESS_PID (sz_capset + sz_pid) (do -- (capset, pid)
          cs <- get
          pd <- get
          return OsProcessPid{capset=cs,pid=pd}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_OSPROCESS_PPID (sz_capset + sz_pid) (do -- (capset, ppid)
          cs <- get
          pd <- get
          return OsProcessParentPid{capset=cs,ppid=pd}
      )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_WALL_CLOCK_TIME (sz_capset + 8 + 4) (do -- (capset, unix_epoch_seconds, nanoseconds)
          cs <- get
          s  <- get
          ns <- get
          return WallClockTime{capset=cs,sec=s,nsec=ns}
      )),

     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_LOG_MSG (do -- (msg)
          num <- get :: Get Word16
          string <- getText num
          return Message{ msg = string }
       )),
     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_USER_MSG (do -- (msg)
          num <- get :: Get Word16
          string <- getText num
          return UserMessage{ msg = string }
       )),
        (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_USER_MARKER (do -- (markername)
          num <- get :: Get Word16
          string <- getText num
          return UserMarker{ markername = string }
       )),
     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_PROGRAM_ARGS (do -- (capset, [arg])
          num <- get :: Get Word16
          cs <- get
          string <- getText (num - sz_capset)
          return ProgramArgs
            { capset = cs
            , args = T.splitOn "\0" $ T.dropWhileEnd (== '\0') string }
       )),
     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_PROGRAM_ENV (do -- (capset, [arg])
          num <- get :: Get Word16
          cs <- get
          string <- getText (num - sz_capset)
          return ProgramEnv
            { capset = cs
            , env = T.splitOn "\0" $ T.dropWhileEnd (== '\0') string }
       )),
     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_RTS_IDENTIFIER (do -- (capset, str)
          num <- get :: Get Word16
          cs <- get
          string <- getText (num - sz_capset)
          return RtsIdentifier{ capset = cs
                              , rtsident = string }
       )),

     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_INTERN_STRING (do -- (str, id)
          num <- get :: Get Word16
          string <- getString (num - sz_string_id)
          sId <- get :: Get StringId
          return (InternString string sId)
        )),

     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_THREAD_LABEL (do -- (thread, str)
          num <- get :: Get Word16
          tid <- get
          str <- getText (num - sz_tid)
          return ThreadLabel{ thread      = tid
                            , threadlabel = str }
        )),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_CONC_MARK_BEGIN ConcMarkBegin),
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CONC_MARK_END 4 (do -- (marked_object_count)
          num <- get :: Get Word32
          return ConcMarkEnd{ concMarkedObjectCount = num }
        )),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_CONC_SYNC_BEGIN ConcSyncBegin),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_CONC_SYNC_END ConcSyncEnd),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_CONC_SWEEP_BEGIN ConcSweepBegin),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_CONC_SWEEP_END ConcSweepEnd),
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CONC_UPD_REM_SET_FLUSH sz_cap (do -- (cap)
          cap <- get :: Get CapNo
          return ConcUpdRemSetFlush{ cap = fromIntegral cap }
        )),
     -- Before GHC issue 23340 event where we are given the logarithm of the block size
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_NONMOVING_HEAP_CENSUS 13 (do -- (blk_size, active_segs, filled_segs, live_blks)
          nonmovingCensusLogBlkSize <- get :: Get Word8
          let nonmovingCensusBlkSize = 2^nonmovingCensusLogBlkSize
          nonmovingCensusActiveSegs <- get :: Get Word32
          nonmovingCensusFilledSegs <- get :: Get Word32
          nonmovingCensusLiveBlocks <- get :: Get Word32
          return NonmovingHeapCensus{..}
        )),
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_NONMOVING_HEAP_CENSUS 14 (do -- (blk_size, active_segs, filled_segs, live_blks)
          nonmovingCensusBlkSize <- get :: Get Word16
          nonmovingCensusActiveSegs <- get :: Get Word32
          nonmovingCensusFilledSegs <- get :: Get Word32
          nonmovingCensusLiveBlocks <- get :: Get Word32
          return NonmovingHeapCensus{..}
        )),
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_NONMOVING_PRUNED_SEGMENTS 8 (do -- (pruned_segments, free_segments)
          nonmovingPrunedSegments <- get :: Get Word32
          nonmovingFreeSegments <- get :: Get Word32
          return NonmovingPrunedSegments{..}
        )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CREATE_THREAD sz_tid (do  -- (thread)
          t <- get
          return CreateThread{thread=t}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_RUN_THREAD sz_tid (do  --  (thread)
          t <- get
          return RunThread{thread=t}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_THREAD_RUNNABLE sz_tid (do  -- (thread)
          t <- get
          return ThreadRunnable{thread=t}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MIGRATE_THREAD (sz_tid + sz_cap) (do  --  (thread, newCap)
          t  <- Get Word32
    forall t. Binary t => Get t
    get
          nc <- get :: Get CapNo
          return MigrateThread{thread=t,newCap=fromIntegral nc}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CREATE_SPARK_THREAD sz_tid (do  -- (sparkThread)
          st <- get :: Get ThreadId
          return CreateSparkThread{sparkThread=st}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_SPARK_COUNTERS (7*8) (do -- (crt,dud,ovf,cnv,gcd,fiz,rem)
          crt <- get :: Get Word64
          dud <- get :: Get Word64
          ovf <- get :: Get Word64
          cnv <- get :: Get Word64
          gcd <- get :: Get Word64
          fiz <- get :: Get Word64
          rem <- get :: Get Word64
          return SparkCounters{sparksCreated    = crt, sparksDud       = dud,
                               sparksOverflowed = ovf, sparksConverted = cnv,
                               -- Warning: order of fiz and gcd reversed!
                               sparksFizzled    = fiz, sparksGCd       = gcd,
                               sparksRemaining  = rem}
       )),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_SPARK_CREATE   SparkCreate),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_SPARK_DUD      SparkDud),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_SPARK_OVERFLOW SparkOverflow),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_SPARK_RUN      SparkRun),
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_SPARK_STEAL sz_cap (do  -- (victimCap)
          vc <- get :: Get CapNo
          return SparkSteal{victimCap=fromIntegral vc}
       )),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_SPARK_FIZZLE   SparkFizzle),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_SPARK_GC       SparkGC),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_TASK_CREATE (sz_taskid + sz_cap + sz_kernel_tid) (do  -- (taskID, cap, tid)
          taskId <- get :: Get TaskId
          cap    <- get :: Get CapNo
          tid    <- get :: Get KernelThreadId
          return TaskCreate{ taskId, cap = fromIntegral cap, tid }
       )),
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_TASK_MIGRATE (sz_taskid + sz_cap*2) (do  -- (taskID, cap, new_cap)
          taskId  <- get :: Get TaskId
          cap     <- get :: Get CapNo
          new_cap <- get :: Get CapNo
          return TaskMigrate{ taskId, cap = fromIntegral cap
                                    , new_cap = fromIntegral new_cap
                            }
       )),
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_TASK_DELETE (sz_taskid) (do  -- (taskID)
          taskId <- get :: Get TaskId
          return TaskDelete{ taskId }
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_THREAD_WAKEUP (sz_tid + sz_cap) (do  -- (thread, other_cap)
          t <- Get Word32
    forall t. Binary t => Get t
    get
          oc <- get :: Get CapNo
          return WakeupThread{thread=t,otherCap=fromIntegral oc}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_STOP_THREAD (sz_tid + sz_th_stop_status + sz_tid)
        (do
          -- (thread, status, info)
          t <- Get Word32
    forall t. Binary t => Get t
    get
          s <- get :: Get RawThreadStopStatus
          i <- get :: Get ThreadId
          return StopThread{thread = t,
                            status = case () of
                                      ()
    _ | EventTypeNum
    s EventTypeNum -> EventTypeNum -> Bool
    forall a. Ord a => a -> a -> Bool
    > EventTypeNum
    maxThreadStopStatus
                                        -> ThreadStopStatus
    NoStatus
                                        | EventTypeNum
    s EventTypeNum -> EventTypeNum -> Bool
    forall a. Eq a => a -> a -> Bool
    == EventTypeNum
    8 {- XXX yeuch -}
                                          -- post-7.8.2: 8==BlockedOnBlackhole
                                        -> Word32 -> ThreadStopStatus
    BlockedOnBlackHoleOwnedBy Word32
    i
                                        | Bool
    otherwise
                                        -> EventTypeNum -> ThreadStopStatus
    mkStopStatus EventTypeNum
    s}
        ))
     ]

    -- Parsers for parallel events. Parameter is the thread_id size, to create
    -- ghc6-parsers (using the wrong size) where necessary.
    parRTSParsers :: EventTypeSize -> [EventParser EventInfo]
    parRTSParsers :: EventTypeNum -> [EventParser EventInfo]
    parRTSParsers EventTypeNum
    sz_tid' = [
     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_VERSION (do -- (version)
          num <- get :: Get Word16
          string <- getString num
          return Version{ version = string }
       )),

     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_PROGRAM_INVOCATION (do -- (cmd. line)
          num <- get :: Get Word16
          string <- getString num
          return ProgramInvocation{ commandline = string }
       )),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_EDEN_START_RECEIVE EdenStartReceive),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_EDEN_END_RECEIVE   EdenEndReceive),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CREATE_PROCESS sz_procid
        (do p <- Get Word32
    forall t. Binary t => Get t
    get
            return CreateProcess{ process = p })
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_KILL_PROCESS sz_procid
        (do p <- Get Word32
    forall t. Binary t => Get t
    get
            return KillProcess{ process = p })
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_ASSIGN_THREAD_TO_PROCESS (sz_tid' + sz_procid)
        (do t <- Get Word32
    forall t. Binary t => Get t
    get
            p <- get
            return AssignThreadToProcess { thread = t, process = p })
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_CREATE_MACHINE (sz_mid + sz_realtime)
        (do m <- Get EventTypeNum
    forall t. Binary t => Get t
    get
            t <- get
            return CreateMachine { machine = m, realtime = t })
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_KILL_MACHINE sz_mid
        (do m <- Get EventTypeNum
    forall t. Binary t => Get t
    get :: Get MachineId
            return KillMachine { machine = m })
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_SEND_MESSAGE
        (EventTypeNum
    sz_msgtag EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    2EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    *EventTypeNum
    sz_procid EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    2EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    *EventTypeNum
    sz_tid' EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_mid)
        (do tag <- Get RawMsgTag
    forall t. Binary t => Get t
    get :: Get RawMsgTag
            sP  <- get :: Get ProcessId
            sT  <- get :: Get ThreadId
            rM  <- get :: Get MachineId
            rP  <- get :: Get ProcessId
            rIP <- get :: Get PortId
            return SendMessage { mesTag = toMsgTag tag,
                                 senderProcess = sP,
                                 senderThread = sT,
                                 receiverMachine = rM,
                                 receiverProcess = rP,
                                 receiverInport = rIP
                               })
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_RECEIVE_MESSAGE
        (EventTypeNum
    sz_msgtag EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    2EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    *EventTypeNum
    sz_procid EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    2EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    *EventTypeNum
    sz_tid' EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_mid EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_mes)
        (do tag <- Get RawMsgTag
    forall t. Binary t => Get t
    get :: Get Word8
            rP  <- get :: Get ProcessId
            rIP <- get :: Get PortId
            sM  <- get :: Get MachineId
            sP  <- get :: Get ProcessId
            sT  <- get :: Get ThreadId
            mS  <- get :: Get MessageSize
            return  ReceiveMessage { mesTag = toMsgTag tag,
                                     receiverProcess = rP,
                                     receiverInport = rIP,
                                     senderMachine = sM,
                                     senderProcess = sP,
                                     senderThread= sT,
                                     messageSize = mS
                                   })
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_SEND_RECEIVE_LOCAL_MESSAGE
        (EventTypeNum
    sz_msgtag EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    2EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    *EventTypeNum
    sz_procid EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    2EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    *EventTypeNum
    sz_tid')
        (do tag <- Get RawMsgTag
    forall t. Binary t => Get t
    get :: Get Word8
            sP  <- get :: Get ProcessId
            sT  <- get :: Get ThreadId
            rP  <- get :: Get ProcessId
            rIP <- get :: Get PortId
            return SendReceiveLocalMessage { mesTag = toMsgTag tag,
                                             senderProcess = sP,
                                             senderThread = sT,
                                             receiverProcess = rP,
                                             receiverInport = rIP
                                           })
     )]

    mercuryParsers :: [EventParser EventInfo]
    mercuryParsers :: [EventParser EventInfo]
    mercuryParsers = [
     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_START_PAR_CONJUNCTION
        (EventTypeNum
    sz_par_conj_dyn_id EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_par_conj_static_id)
        (do dyn_id <- Get Timestamp
    forall t. Binary t => Get t
    get
            static_id <- get
            return (MerStartParConjunction dyn_id static_id))
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_STOP_PAR_CONJUNCTION sz_par_conj_dyn_id
        (do dyn_id <- Get Timestamp
    forall t. Binary t => Get t
    get
            return (MerEndParConjunction dyn_id))
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_STOP_PAR_CONJUNCT sz_par_conj_dyn_id
        (do dyn_id <- Get Timestamp
    forall t. Binary t => Get t
    get
            return (MerEndParConjunct dyn_id))
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_CREATE_SPARK (sz_par_conj_dyn_id + sz_spark_id)
        (do dyn_id <- Get Timestamp
    forall t. Binary t => Get t
    get
            spark_id <- get
            return (MerCreateSpark dyn_id spark_id))
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_FUT_CREATE (sz_future_id + sz_string_id)
        (do future_id <- Get Timestamp
    forall t. Binary t => Get t
    get
            name_id <- get
            return (MerFutureCreate future_id name_id))
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_FUT_WAIT_NOSUSPEND (sz_future_id)
        (do future_id <- Get Timestamp
    forall t. Binary t => Get t
    get
            return (MerFutureWaitNosuspend future_id))
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_FUT_WAIT_SUSPENDED (sz_future_id)
        (do future_id <- Get Timestamp
    forall t. Binary t => Get t
    get
            return (MerFutureWaitSuspended future_id))
     ),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_FUT_SIGNAL (sz_future_id)
        (do future_id <- Get Timestamp
    forall t. Binary t => Get t
    get
            return (MerFutureSignal future_id))
     ),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_MER_LOOKING_FOR_GLOBAL_CONTEXT MerLookingForGlobalThread),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_MER_WORK_STEALING MerWorkStealing),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_MER_LOOKING_FOR_LOCAL_SPARK MerLookingForLocalSpark),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_MER_RELEASE_CONTEXT sz_tid
        (do thread_id <- Get Word32
    forall t. Binary t => Get t
    get
            return (MerReleaseThread thread_id))
     ),

     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_MER_ENGINE_SLEEPING MerCapSleeping),
     (Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_MER_CALLING_MAIN MerCallingMain)

     ]

    perfParsers :: [EventParser EventInfo]
    perfParsers :: [EventParser EventInfo]
    perfParsers = [
     (Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_PERF_NAME (do -- (perf_num, name)
          num     <- get :: Get Word16
          perfNum <- get
          name    <- getText (num - sz_perf_num)
          return PerfName{perfNum, name}
       )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_PERF_COUNTER (sz_perf_num + sz_kernel_tid + 8) (do -- (perf_num, tid, period)
          perfNum <- get
          tid     <- get
          period  <- get
          return PerfCounter{perfNum, tid, period}
      )),

     (Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_PERF_TRACEPOINT (sz_perf_num + sz_kernel_tid) (do -- (perf_num, tid)
          perfNum <- Get Word32
    forall t. Binary t => Get t
    get
          tid     <- get
          return PerfTracepoint{perfNum, tid}
      ))
     ]

    heapProfParsers :: [EventParser EventInfo]
    heapProfParsers :: [EventParser EventInfo]
    heapProfParsers =
      [ Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_HEAP_PROF_BEGIN $ do
        payloadLen <- get :: Get Word16
        heapProfId <- get
        heapProfSamplingPeriod <- get
        heapProfBreakdown <- get
        heapProfModuleFilter <- getTextNul
        heapProfClosureDescrFilter <- getTextNul
        heapProfTypeDescrFilter <- getTextNul
        heapProfCostCentreFilter <- getTextNul
        heapProfCostCentreStackFilter <- getTextNul
        heapProfRetainerFilter <- getTextNul
        heapProfBiographyFilter <- getTextNul
        assert
          (fromIntegral payloadLen == sum
            [ 1 -- heapProfId
            , 8 -- heapProfSamplingPeriod
            , 4 -- heapProfBreakdown
            , textByteLen heapProfModuleFilter
            , textByteLen heapProfClosureDescrFilter
            , textByteLen heapProfTypeDescrFilter
            , textByteLen heapProfCostCentreFilter
            , textByteLen heapProfCostCentreStackFilter
            , textByteLen heapProfRetainerFilter
            , textByteLen heapProfBiographyFilter
            ])
          (return ())
        return $! HeapProfBegin {..}
      , Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_HEAP_PROF_COST_CENTRE $ do
        payloadLen <- get :: Get Word16
        heapProfCostCentreId <- get
        heapProfLabel <- getTextNul
        heapProfModule <- getTextNul
        heapProfSrcLoc <- getTextNul
        heapProfFlags <- get
        assert
          (fromIntegral payloadLen == sum
            [ 4 -- heapProfCostCentreId
            , textByteLen heapProfLabel
            , textByteLen heapProfModule
            , textByteLen heapProfSrcLoc
            , 1 -- heapProfFlags
            ])
          (return ())
        return $! HeapProfCostCentre {..}
      , Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_IPE $ do
        payloadLen <- get :: Get Word16
        itInfo <- get
        itTableName <- getTextNul
        itClosureDescText <- getTextNul
        itClosureDesc <- either fail (return . fst) (TR.decimal itClosureDescText)
        itTyDesc <- getTextNul
        itLabel <- getTextNul
        itModule <- getTextNul
        itSrcLoc <- getTextNul
        assert
          (fromIntegral payloadLen == sum
            [ 8 -- itInfo
            , textByteLen itTableName
            , textByteLen itClosureDescText
            , textByteLen itTyDesc
            , textByteLen itLabel
            , textByteLen itModule
            , textByteLen itSrcLoc
            ])
          (return ())
        return $! InfoTableProv {..}
      , Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_HEAP_PROF_SAMPLE_BEGIN 8 $ do
        heapProfSampleEra <- get
        return $! HeapProfSampleBegin {..}
      , Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_HEAP_PROF_SAMPLE_END 8 $ do
        heapProfSampleEra <- get
        return $! HeapProfSampleEnd {..}
      , Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN 16 $ do
        heapProfSampleEra <- get
        heapProfSampleTime <- get
        return $! HeapBioProfSampleBegin {..}
      , Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_HEAP_PROF_SAMPLE_COST_CENTRE $ do
        payloadLen <- get :: Get Word16
        heapProfId <- get
        heapProfResidency <- get
        heapProfStackDepth <- get
        heapProfStack <- VU.replicateM (fromIntegral heapProfStackDepth) get
        assert
          ((fromIntegral payloadLen :: Int) == sum
            [ 1 -- heapProfId
            , 8 -- heapProfResidency
            , 1 -- heapProfStackDepth
            , fromIntegral heapProfStackDepth * 4
            ])
          (return ())
        return $! HeapProfSampleCostCentre {..}
      , Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_HEAP_PROF_SAMPLE_STRING $ do
        payloadLen <- get :: Get Word16
        heapProfId <- get
        heapProfResidency <- get
        heapProfLabel <- getTextNul
        assert
          (fromIntegral payloadLen == sum
            [ 1 -- heapProfId
            , 8 -- heapProfResidency
            , textByteLen heapProfLabel
            ])
          (return ())
        return $! HeapProfSampleString {..}
      ]

    timeProfParsers :: [EventParser EventInfo]
    timeProfParsers :: [EventParser EventInfo]
    timeProfParsers = [
      Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_PROF_BEGIN 8 $ do
        profTickInterval <- get
        return $! ProfBegin{..}
      , Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_PROF_SAMPLE_COST_CENTRE $ do
        payloadLen <- get :: Get Word16
        profCap <- fromIntegral @Int32 @CapNo <$> get
        profTicks <- get
        profStackDepth <- get
        profCcsStack <- VU.replicateM (fromIntegral profStackDepth) get
        assert
          ((fromIntegral payloadLen :: Int) == sum
            [ 4
            , 8 -- ticks
            , 1 -- stack depth
            , fromIntegral profStackDepth * 4
            ])
          (return ())
        return $! ProfSampleCostCentre {..} ]

    binaryEventParsers :: [EventParser EventInfo]
    binaryEventParsers :: [EventParser EventInfo]
    binaryEventParsers =
      [ Int -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser EVENT_USER_BINARY_MSG $ do
        payloadLen <- get :: Get Word16
        payload <- G.getByteString $ fromIntegral payloadLen
        return $! UserBinaryMessage { payload }
      ]

    -- | Reads the `a` object, and if that didn't consume the complete
    -- event skip over the leftover data.
    skipExtra :: Word16 -> Get a -> Get a
    skipExtra :: forall a. EventTypeNum -> Get a -> Get a
    skipExtra EventTypeNum
    expected_size Get a
    get_body = do
      bytes_read <- Get Int64
    G.bytesRead
      res <- get_body
      bytes_read_end <- G.bytesRead
      let total_size = Int64
    bytes_read_end Int64 -> Int64 -> Int64
    forall a. Num a => a -> a -> a
    - Int64
    bytes_read
          to_skip  = EventTypeNum -> Int64
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral EventTypeNum
    expected_size Int64 -> Int64 -> Int64
    forall a. Num a => a -> a -> a
    - Int64
    total_size
      when (to_skip < 0) (fail "Negative to_skip")
      skip to_skip
      return res

    -- | Skip extra stuff at the end of a variable sized event
    -- For forwards compatability (allowing newer events to be read with older versions)
    variableSizeParser :: Int -- ^ The identifier for the event
                       -> (Word16 -> Int64 -> Get a) -- ^ A continuation to parse the body of the event
                       -> EventParser a
    variableSizeParser :: forall a. Int -> (EventTypeNum -> Int64 -> Get a) -> EventParser a
    variableSizeParser Int
    event_type EventTypeNum -> Int64 -> Get a
    body_parser = do
      Int -> Get a -> EventParser a
    forall a. Int -> Get a -> EventParser a
    VariableSizeParser Int
    event_type (Get a -> EventParser a) -> Get a -> EventParser a
    forall a b. (a -> b) -> a -> b
    $ do
        payloadLen         <- Get EventTypeNum
    forall t. Binary t => Get t
    get :: Get Word16
        bytes_read <- G.bytesRead
        skipExtra payloadLen (body_parser payloadLen (fromIntegral bytes_read))

    -- | If we have already got everything then return the default value, otherwise get
    -- For backwards compatability (to allow older events to be read with newer versions)
    optionalGet :: (Binary b)
                => Word16 -- ^ Expected size
                -> Int64  -- ^ Starting byte offset
                -> b      -- ^ Default value
                -> Get b
                -> Get b
    optionalGet :: forall b. Binary b => EventTypeNum -> Int64 -> b -> Get b -> Get b
    optionalGet EventTypeNum
    expected_size Int64
    bytes_read b
    def Get b
    get_this = do
      bytes_read_end <- Get Int64
    G.bytesRead
      let total_size = Int64
    bytes_read_end Int64 -> Int64 -> Int64
    forall a. Num a => a -> a -> a
    - Int64
    bytes_read
      if fromIntegral expected_size == total_size then return def else get_this

    tickyParsers :: [EventParser EventInfo]
    tickyParsers :: [EventParser EventInfo]
    tickyParsers =
      [ Int
    -> (EventTypeNum -> Int64 -> Get EventInfo)
    -> EventParser EventInfo
    forall a. Int -> (EventTypeNum -> Int64 -> Get a) -> EventParser a
    variableSizeParser EVENT_TICKY_COUNTER_DEF $ \payloadLen start_bytes -> do
        tickyCtrDefId      <- get
        tickyCtrDefArity   <- get
        tickyCtrDefKinds   <- getTextNul
        tickyCtrDefName    <- getTextNul
        tickyCtrInfoTbl    <- optionalGet payloadLen start_bytes (0 :: Word64) get
        tickyCtrJsonDesc   <- optionalGet payloadLen start_bytes Nothing (Just <$> getTextNul)
        assert (fromIntegral payloadLen ==
          (sum
            [ 8 -- tickyCtrDefId
            , 2 -- tickyCtrDefArity
            , textByteLen tickyCtrDefKinds
            , textByteLen tickyCtrDefName
            , 8 -- tickyCtrInfoTbl
            , maybe 0 textByteLen tickyCtrJsonDesc
            ]))
            (return ())
        return $! TickyCounterDef{..}
      , Int -> EventTypeNum -> Get EventInfo -> EventParser EventInfo
    forall a. Int -> EventTypeNum -> Get a -> EventParser a
    FixedSizeParser EVENT_TICKY_COUNTER_SAMPLE (8*4) $ do
        tickyCtrSampleId         <- get
        tickyCtrSampleEntryCount <- get
        tickyCtrSampleAllocs     <- get
        tickyCtrSampleAllocd     <- get
        return $! TickyCounterSample{..}
      , Int -> EventInfo -> EventParser EventInfo
    forall a. Int -> a -> EventParser a
    simpleEvent EVENT_TICKY_BEGIN_SAMPLE TickyBeginSample
      ]

    -- | String byte length in the event log format. It includes
    -- 1 byte for NUL.
    textByteLen :: T.Text -> Int
    textByteLen :: Text -> Int
    textByteLen = (Int -> Int -> Int
    forall a. Num a => a -> a -> a
    +Int
    1) (Int -> Int) -> (Text -> Int) -> Text -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ByteString -> Int
    B.length (ByteString -> Int) -> (Text -> ByteString) -> Text -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> ByteString
    TE.encodeUtf8

    -----------------------------------------------------------

    putE :: Binary a => a -> PutM ()
    putE :: forall a. Binary a => a -> PutM ()
    putE = a -> PutM ()
    forall a. Binary a => a -> PutM ()
    put

    putType :: EventTypeNum -> PutM ()
    putType :: EventTypeNum -> PutM ()
    putType = EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE

    putCap :: Int -> PutM ()
    putCap :: Int -> PutM ()
    putCap Int
    c = EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    c :: CapNo)

    putMarker :: Word32 -> PutM ()
    putMarker :: Word32 -> PutM ()
    putMarker = Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE

    putEventLog :: EventLog -> PutM ()
    putEventLog :: EventLog -> PutM ()
    putEventLog (EventLog Header
    hdr Data
    es) = do
        Header -> PutM ()
    putHeader Header
    hdr
        Data -> PutM ()
    putData Data
    es

    putHeader :: Header -> PutM ()
    putHeader :: Header -> PutM ()
    putHeader (Header [EventType]
    ets) = do
        Word32 -> PutM ()
    putMarker EVENT_HEADER_BEGIN
        Word32 -> PutM ()
    putMarker EVENT_HET_BEGIN
        (EventType -> PutM ()) -> [EventType] -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ EventType -> PutM ()
    putEventType [EventType]
    ets
        Word32 -> PutM ()
    putMarker EVENT_HET_END
        Word32 -> PutM ()
    putMarker EVENT_HEADER_END
     where
        putEventType :: EventType -> PutM ()
    putEventType (EventType EventTypeNum
    n (Text -> ByteString
    TE.encodeUtf8 -> ByteString
    d) Maybe EventTypeNum
    msz) = do
            Word32 -> PutM ()
    putMarker EVENT_ET_BEGIN
            EventTypeNum -> PutM ()
    putType EventTypeNum
    n
            EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (EventTypeNum -> PutM ()) -> EventTypeNum -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ EventTypeNum -> Maybe EventTypeNum -> EventTypeNum
    forall a. a -> Maybe a -> a
    fromMaybe EventTypeNum
    0xffff Maybe EventTypeNum
    msz
            Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> Word32
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Int -> Word32) -> Int -> Word32
    forall a b. (a -> b) -> a -> b
    $ ByteString -> Int
    B.length ByteString
    d :: EventTypeDescLen)
            ByteString -> PutM ()
    putByteString ByteString
    d
            -- the event type header allows for extra data, which we don't use:
            Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Word32
    0 :: Word32)
            Word32 -> PutM ()
    putMarker EVENT_ET_END

    putData :: Data -> PutM ()
    putData :: Data -> PutM ()
    putData (Data [Event]
    es) = do
        Word32 -> PutM ()
    putMarker EVENT_DATA_BEGIN -- Word32
        (Event -> PutM ()) -> [Event] -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ Event -> PutM ()
    putEvent [Event]
    es
        EventTypeNum -> PutM ()
    putType EVENT_DATA_END -- Word16

    eventTypeNum :: EventInfo -> EventTypeNum
    eventTypeNum :: EventInfo -> EventTypeNum
    eventTypeNum EventInfo
    e = case EventInfo
    e of
        CreateThread {} -> EVENT_CREATE_THREAD
        RunThread {} -> EVENT_RUN_THREAD
        StopThread {} -> EVENT_STOP_THREAD
        ThreadRunnable {} -> EVENT_THREAD_RUNNABLE
        MigrateThread {} -> EVENT_MIGRATE_THREAD
        Shutdown {} -> EVENT_SHUTDOWN
        WakeupThread {} -> EVENT_THREAD_WAKEUP
        ThreadLabel {}  -> EVENT_THREAD_LABEL
        StartGC {} -> EVENT_GC_START
        EndGC {} -> EVENT_GC_END
        GlobalSyncGC {} -> EVENT_GC_GLOBAL_SYNC
        RequestSeqGC {} -> EVENT_REQUEST_SEQ_GC
        RequestParGC {} -> EVENT_REQUEST_PAR_GC
        CreateSparkThread {} -> EVENT_CREATE_SPARK_THREAD
        SparkCounters {} -> EVENT_SPARK_COUNTERS
        SparkCreate   {} -> EVENT_SPARK_CREATE
        SparkDud      {} -> EVENT_SPARK_DUD
        SparkOverflow {} -> EVENT_SPARK_OVERFLOW
        SparkRun      {} -> EVENT_SPARK_RUN
        SparkSteal    {} -> EVENT_SPARK_STEAL
        SparkFizzle   {} -> EVENT_SPARK_FIZZLE
        SparkGC       {} -> EVENT_SPARK_GC
        TaskCreate  {} -> EVENT_TASK_CREATE
        TaskMigrate {} -> EVENT_TASK_MIGRATE
        TaskDelete  {} -> EVENT_TASK_DELETE
        Message {} -> EVENT_LOG_MSG
        Startup {} -> EVENT_STARTUP
        EventBlock {} -> EVENT_BLOCK_MARKER
        UserMessage {} -> EVENT_USER_MSG
        UserMarker  {} -> EVENT_USER_MARKER
        GCIdle {} -> EVENT_GC_IDLE
        GCWork {} -> EVENT_GC_WORK
        GCDone {} -> EVENT_GC_DONE
        GCStatsGHC{} -> EVENT_GC_STATS_GHC
        HeapAllocated{} -> EVENT_HEAP_ALLOCATED
        HeapSize{} -> EVENT_HEAP_SIZE
        BlocksSize{} -> EVENT_BLOCKS_SIZE
        HeapLive{} -> EVENT_HEAP_LIVE
        HeapInfoGHC{} -> EVENT_HEAP_INFO_GHC
        CapCreate{} -> EVENT_CAP_CREATE
        CapDelete{} -> EVENT_CAP_DELETE
        CapDisable{} -> EVENT_CAP_DISABLE
        CapEnable{} -> EVENT_CAP_ENABLE
        CapsetCreate {} -> EVENT_CAPSET_CREATE
        CapsetDelete {} -> EVENT_CAPSET_DELETE
        CapsetAssignCap {} -> EVENT_CAPSET_ASSIGN_CAP
        CapsetRemoveCap {} -> EVENT_CAPSET_REMOVE_CAP
        RtsIdentifier {} -> EVENT_RTS_IDENTIFIER
        ProgramArgs {} -> EVENT_PROGRAM_ARGS
        ProgramEnv {} -> EVENT_PROGRAM_ENV
        OsProcessPid {} -> EVENT_OSPROCESS_PID
        OsProcessParentPid{} -> EVENT_OSPROCESS_PPID
        WallClockTime{} -> EVENT_WALL_CLOCK_TIME
        UnknownEvent {} -> String -> EventTypeNum
    forall a. HasCallStack => String -> a
    error String
    "eventTypeNum UnknownEvent"
        InternString {} -> EVENT_INTERN_STRING
        Version {} -> EVENT_VERSION
        ProgramInvocation {} -> EVENT_PROGRAM_INVOCATION
        EdenStartReceive {} -> EVENT_EDEN_START_RECEIVE
        EdenEndReceive {} -> EVENT_EDEN_END_RECEIVE
        CreateProcess {} -> EVENT_CREATE_PROCESS
        KillProcess {} -> EVENT_KILL_PROCESS
        AssignThreadToProcess {} -> EVENT_ASSIGN_THREAD_TO_PROCESS
        CreateMachine {} -> EVENT_CREATE_MACHINE
        KillMachine {} -> EVENT_KILL_MACHINE
        SendMessage {} -> EVENT_SEND_MESSAGE
        ReceiveMessage {} -> EVENT_RECEIVE_MESSAGE
        SendReceiveLocalMessage {} -> EVENT_SEND_RECEIVE_LOCAL_MESSAGE
        MerStartParConjunction {} -> EVENT_MER_START_PAR_CONJUNCTION
        MerEndParConjunction Timestamp
    _ -> EVENT_MER_STOP_PAR_CONJUNCTION
        MerEndParConjunct Timestamp
    _ -> EVENT_MER_STOP_PAR_CONJUNCT
        MerCreateSpark {} -> EVENT_MER_CREATE_SPARK
        MerFutureCreate {} -> EVENT_MER_FUT_CREATE
        MerFutureWaitNosuspend Timestamp
    _ -> EVENT_MER_FUT_WAIT_NOSUSPEND
        MerFutureWaitSuspended Timestamp
    _ -> EVENT_MER_FUT_WAIT_SUSPENDED
        MerFutureSignal Timestamp
    _ -> EVENT_MER_FUT_SIGNAL
        EventInfo
    MerLookingForGlobalThread -> EVENT_MER_LOOKING_FOR_GLOBAL_CONTEXT
        EventInfo
    MerWorkStealing -> EVENT_MER_WORK_STEALING
        EventInfo
    MerLookingForLocalSpark -> EVENT_MER_LOOKING_FOR_LOCAL_SPARK
        MerReleaseThread Word32
    _ -> EVENT_MER_RELEASE_CONTEXT
        EventInfo
    MerCapSleeping -> EVENT_MER_ENGINE_SLEEPING
        EventInfo
    MerCallingMain -> EVENT_MER_CALLING_MAIN
        PerfName       {} -> EventTypeNum
    nEVENT_PERF_NAME
        PerfCounter    {} -> EventTypeNum
    nEVENT_PERF_COUNTER
        PerfTracepoint {} -> EventTypeNum
    nEVENT_PERF_TRACEPOINT
        HeapProfBegin {} -> EVENT_HEAP_PROF_BEGIN
        HeapProfCostCentre {} -> EVENT_HEAP_PROF_COST_CENTRE
        HeapProfSampleBegin {} -> EVENT_HEAP_PROF_SAMPLE_BEGIN
        HeapProfSampleEnd {} -> EVENT_HEAP_PROF_SAMPLE_END
        HeapBioProfSampleBegin {} -> EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN
        HeapProfSampleCostCentre {} -> EVENT_HEAP_PROF_SAMPLE_COST_CENTRE
        HeapProfSampleString {} -> EVENT_HEAP_PROF_SAMPLE_STRING
        ProfSampleCostCentre {} -> EVENT_PROF_SAMPLE_COST_CENTRE
        ProfBegin {}            -> EVENT_PROF_BEGIN
        UserBinaryMessage {} -> EVENT_USER_BINARY_MSG
        ConcMarkBegin {} -> EVENT_CONC_MARK_BEGIN
        ConcMarkEnd {} -> EVENT_CONC_MARK_END
        ConcSyncBegin {} -> EVENT_CONC_SYNC_BEGIN
        ConcSyncEnd {} -> EVENT_CONC_SYNC_END
        ConcSweepBegin {} -> EVENT_CONC_SWEEP_BEGIN
        ConcSweepEnd {} -> EVENT_CONC_SWEEP_END
        ConcUpdRemSetFlush {} -> EVENT_CONC_UPD_REM_SET_FLUSH
        NonmovingHeapCensus {} -> EVENT_NONMOVING_HEAP_CENSUS
        NonmovingPrunedSegments {} -> EVENT_NONMOVING_PRUNED_SEGMENTS
        TickyCounterDef {} -> EVENT_TICKY_COUNTER_DEF
        TickyCounterSample {} -> EVENT_TICKY_COUNTER_SAMPLE
        InfoTableProv {} -> EVENT_IPE
        MemReturn {} -> EVENT_MEM_RETURN
        TickyBeginSample {} -> EVENT_TICKY_BEGIN_SAMPLE

    nEVENT_PERF_NAME, nEVENT_PERF_COUNTER, nEVENT_PERF_TRACEPOINT :: EventTypeNum
    nEVENT_PERF_NAME :: EventTypeNum
    nEVENT_PERF_NAME = EVENT_PERF_NAME
    nEVENT_PERF_COUNTER :: EventTypeNum
    nEVENT_PERF_COUNTER = EVENT_PERF_COUNTER
    nEVENT_PERF_TRACEPOINT :: EventTypeNum
    nEVENT_PERF_TRACEPOINT = EVENT_PERF_TRACEPOINT

    putEvent :: Event -> PutM ()
    putEvent :: Event -> PutM ()
    putEvent Event {Maybe Int
    Timestamp
    EventInfo
    evCap :: Event -> Maybe Int
    evSpec :: Event -> EventInfo
    evTime :: Event -> Timestamp
    evTime :: Timestamp
    evSpec :: EventInfo
    evCap :: Maybe Int
    ..} = do
        EventTypeNum -> PutM ()
    putType (EventInfo -> EventTypeNum
    eventTypeNum EventInfo
    evSpec)
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    put Timestamp
    evTime
        EventInfo -> PutM ()
    putEventSpec EventInfo
    evSpec

    putEventSpec :: EventInfo -> PutM ()
    putEventSpec :: EventInfo -> PutM ()
    putEventSpec (Startup Int
    caps) = do
        Int -> PutM ()
    putCap (Int -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    caps)

    putEventSpec (EventBlock Timestamp
    end Int
    cap Word32
    sz) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Word32 -> Word32
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Word32
    szWord32 -> Word32 -> Word32
    forall a. Num a => a -> a -> a
    +Word32
    24) :: BlockSize)
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    end
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    cap :: CapNo)

    putEventSpec (CreateThread Word32
    t) =
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    t

    putEventSpec (RunThread Word32
    t) =
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    t

    -- here we assume that ThreadStopStatus fromEnum matches the definitions in
    -- EventLogFormat.h
    -- The standard encoding is used here, which is wrong for event logs
    -- produced by GHC-7.8.2 ([Stop status in GHC-7.8.2] in EventTypes.hs
    putEventSpec (StopThread Word32
    t ThreadStopStatus
    s) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    t
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (EventTypeNum -> PutM ()) -> EventTypeNum -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ case ThreadStopStatus
    s of
                ThreadStopStatus
    NoStatus -> EventTypeNum
    0 :: Word16
                ThreadStopStatus
    HeapOverflow -> EventTypeNum
    1
                ThreadStopStatus
    StackOverflow -> EventTypeNum
    2
                ThreadStopStatus
    ThreadYielding -> EventTypeNum
    3
                ThreadStopStatus
    ThreadBlocked -> EventTypeNum
    4
                ThreadStopStatus
    ThreadFinished -> EventTypeNum
    5
                ThreadStopStatus
    ForeignCall -> EventTypeNum
    6
                ThreadStopStatus
    BlockedOnMVar -> EventTypeNum
    7
                ThreadStopStatus
    BlockedOnMVarRead -> EventTypeNum
    20 -- since GHC-7.8.3
                ThreadStopStatus
    BlockedOnBlackHole -> EventTypeNum
    8
                BlockedOnBlackHoleOwnedBy Word32
    _ -> EventTypeNum
    8
                ThreadStopStatus
    BlockedOnRead -> EventTypeNum
    9
                ThreadStopStatus
    BlockedOnWrite -> EventTypeNum
    10
                ThreadStopStatus
    BlockedOnDelay -> EventTypeNum
    11
                ThreadStopStatus
    BlockedOnSTM -> EventTypeNum
    12
                ThreadStopStatus
    BlockedOnDoProc -> EventTypeNum
    13
                ThreadStopStatus
    BlockedOnCCall -> EventTypeNum
    14
                ThreadStopStatus
    BlockedOnCCall_NoUnblockExc -> EventTypeNum
    15
                ThreadStopStatus
    BlockedOnMsgThrowTo -> EventTypeNum
    16
                ThreadStopStatus
    ThreadMigrating -> EventTypeNum
    17
                ThreadStopStatus
    BlockedOnMsgGlobalise -> EventTypeNum
    18
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Word32 -> PutM ()) -> Word32 -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ case ThreadStopStatus
    s of
                BlockedOnBlackHoleOwnedBy Word32
    i -> Word32
    i
                ThreadStopStatus
    _                           -> Word32
    0

    putEventSpec (ThreadRunnable Word32
    t) =
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    t

    putEventSpec (MigrateThread Word32
    t Int
    c) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    t
        Int -> PutM ()
    putCap Int
    c

    putEventSpec (CreateSparkThread Word32
    t) =
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    t

    putEventSpec (SparkCounters Timestamp
    crt Timestamp
    dud Timestamp
    ovf Timestamp
    cnv Timestamp
    fiz Timestamp
    gcd Timestamp
    rem) = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    crt
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    dud
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    ovf
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    cnv
        -- Warning: order of fiz and gcd reversed!
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    gcd
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    fiz
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    rem

    putEventSpec EventInfo
    SparkCreate =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    SparkDud =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    SparkOverflow =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    SparkRun =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec (SparkSteal Int
    c) =
        Int -> PutM ()
    putCap Int
    c

    putEventSpec EventInfo
    SparkFizzle =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    SparkGC =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec (WakeupThread Word32
    t Int
    c) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    t
        Int -> PutM ()
    putCap Int
    c

    putEventSpec (ThreadLabel Word32
    t (Text -> ByteString
    TE.encodeUtf8 -> ByteString
    l)) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (ByteString -> Int
    B.length ByteString
    l) EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_tid :: Word16)
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    t
        ByteString -> PutM ()
    putByteString ByteString
    l

    putEventSpec EventInfo
    Shutdown =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    RequestSeqGC =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    RequestParGC =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    StartGC =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    GCWork =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    GCIdle =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    GCDone =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    EndGC =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec EventInfo
    GlobalSyncGC =
        () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec (TaskCreate Timestamp
    taskId Int
    cap KernelThreadId
    tid) = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    taskId
        Int -> PutM ()
    putCap Int
    cap
        KernelThreadId -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE KernelThreadId
    tid

    putEventSpec (TaskMigrate Timestamp
    taskId Int
    cap Int
    new_cap) = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    taskId
        Int -> PutM ()
    putCap Int
    cap
        Int -> PutM ()
    putCap Int
    new_cap

    putEventSpec (TaskDelete Timestamp
    taskId) =
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    taskId

    putEventSpec GCStatsGHC{Int
    Maybe Timestamp
    Word32
    Timestamp
    gen :: EventInfo -> Int
    parNThreads :: EventInfo -> Int
    parBalancedCopied :: EventInfo -> Maybe Timestamp
    parTotCopied :: EventInfo -> Timestamp
    parMaxCopied :: EventInfo -> Timestamp
    frag :: EventInfo -> Timestamp
    slop :: EventInfo -> Timestamp
    copied :: EventInfo -> Timestamp
    heapCapset :: EventInfo -> Word32
    heapCapset :: Word32
    gen :: Int
    copied :: Timestamp
    slop :: Timestamp
    frag :: Timestamp
    parNThreads :: Int
    parMaxCopied :: Timestamp
    parTotCopied :: Timestamp
    parBalancedCopied :: Maybe Timestamp
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    heapCapset
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    gen :: Word16)
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    copied
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    slop
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    frag
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> Word32
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    parNThreads :: Word32)
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    parMaxCopied
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    parTotCopied
        case Maybe Timestamp
    parBalancedCopied of
          Maybe Timestamp
    Nothing -> () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
          Just Timestamp
    v  -> Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    v

    putEventSpec MemReturn{Word32
    heapCapset :: EventInfo -> Word32
    current :: EventInfo -> Word32
    needed :: EventInfo -> Word32
    returned :: EventInfo -> Word32
    heapCapset :: Word32
    current :: Word32
    needed :: Word32
    returned :: Word32
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    heapCapset
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    current
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    needed
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    returned

    putEventSpec HeapAllocated{Word32
    Timestamp
    heapCapset :: EventInfo -> Word32
    allocBytes :: EventInfo -> Timestamp
    heapCapset :: Word32
    allocBytes :: Timestamp
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    heapCapset
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    allocBytes

    putEventSpec HeapSize{Word32
    Timestamp
    heapCapset :: EventInfo -> Word32
    sizeBytes :: EventInfo -> Timestamp
    heapCapset :: Word32
    sizeBytes :: Timestamp
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    heapCapset
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    sizeBytes

    putEventSpec BlocksSize{Word32
    Timestamp
    heapCapset :: EventInfo -> Word32
    blocksSize :: EventInfo -> Timestamp
    heapCapset :: Word32
    blocksSize :: Timestamp
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    heapCapset
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    blocksSize

    putEventSpec HeapLive{Word32
    Timestamp
    heapCapset :: EventInfo -> Word32
    liveBytes :: EventInfo -> Timestamp
    heapCapset :: Word32
    liveBytes :: Timestamp
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    heapCapset
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    liveBytes

    putEventSpec HeapInfoGHC{Int
    Word32
    Timestamp
    heapCapset :: EventInfo -> Word32
    gens :: EventInfo -> Int
    blockSize :: EventInfo -> Timestamp
    mblockSize :: EventInfo -> Timestamp
    allocAreaSize :: EventInfo -> Timestamp
    maxHeapSize :: EventInfo -> Timestamp
    heapCapset :: Word32
    gens :: Int
    maxHeapSize :: Timestamp
    allocAreaSize :: Timestamp
    mblockSize :: Timestamp
    blockSize :: Timestamp
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    heapCapset
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    gens :: Word16)
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    maxHeapSize
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    allocAreaSize
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    mblockSize
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    blockSize

    putEventSpec CapCreate{Int
    cap :: EventInfo -> Int
    cap :: Int
    cap} =
        Int -> PutM ()
    putCap Int
    cap

    putEventSpec CapDelete{Int
    cap :: EventInfo -> Int
    cap :: Int
    cap} =
        Int -> PutM ()
    putCap Int
    cap

    putEventSpec CapDisable{Int
    cap :: EventInfo -> Int
    cap :: Int
    cap} =
        Int -> PutM ()
    putCap Int
    cap

    putEventSpec CapEnable{Int
    cap :: EventInfo -> Int
    cap :: Int
    cap} =
        Int -> PutM ()
    putCap Int
    cap

    putEventSpec (CapsetCreate Word32
    cs CapsetType
    ct) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (EventTypeNum -> PutM ()) -> EventTypeNum -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ case CapsetType
    ct of
                CapsetType
    CapsetCustom -> EventTypeNum
    1 :: Word16
                CapsetType
    CapsetOsProcess -> EventTypeNum
    2
                CapsetType
    CapsetClockDomain -> EventTypeNum
    3
                CapsetType
    CapsetUnknown -> EventTypeNum
    0

    putEventSpec (CapsetDelete Word32
    cs) =
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs

    putEventSpec (CapsetAssignCap Word32
    cs Int
    cp) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        Int -> PutM ()
    putCap Int
    cp

    putEventSpec (CapsetRemoveCap Word32
    cs Int
    cp) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        Int -> PutM ()
    putCap Int
    cp

    putEventSpec (RtsIdentifier Word32
    cs (Text -> ByteString
    TE.encodeUtf8 -> ByteString
    rts)) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (ByteString -> Int
    B.length ByteString
    rts) EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_capset :: Word16)
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        ByteString -> PutM ()
    putByteString ByteString
    rts

    putEventSpec (ProgramArgs Word32
    cs ((Text -> ByteString) -> [Text] -> [ByteString]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> ByteString
    TE.encodeUtf8 -> [ByteString]
    as)) = do
        let sz_args :: Int
    sz_args = [Int] -> Int
    forall a. Num a => [a] -> a
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    sum ((ByteString -> Int) -> [ByteString] -> [Int]
    forall a b. (a -> b) -> [a] -> [b]
    map ((Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    1) {- for \0 -} (Int -> Int) -> (ByteString -> Int) -> ByteString -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ByteString -> Int
    B.length) [ByteString]
    as) Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    sz_args EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_capset :: Word16)
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        (ByteString -> PutM ()) -> [ByteString] -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ ByteString -> PutM ()
    putByteString (ByteString -> [ByteString] -> [ByteString]
    forall a. a -> [a] -> [a]
    intersperse ByteString
    "\0" [ByteString]
    as)

    putEventSpec (ProgramEnv Word32
    cs ((Text -> ByteString) -> [Text] -> [ByteString]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> ByteString
    TE.encodeUtf8 -> [ByteString]
    es)) = do
        let sz_env :: Int
    sz_env = [Int] -> Int
    forall a. Num a => [a] -> a
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    sum ((ByteString -> Int) -> [ByteString] -> [Int]
    forall a b. (a -> b) -> [a] -> [b]
    map ((Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    1) {- for \0 -} (Int -> Int) -> (ByteString -> Int) -> ByteString -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ByteString -> Int
    B.length) [ByteString]
    es) Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    sz_env EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_capset :: Word16)
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        (ByteString -> PutM ()) -> [ByteString] -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ ByteString -> PutM ()
    putByteString ([ByteString] -> PutM ()) -> [ByteString] -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ ByteString -> [ByteString] -> [ByteString]
    forall a. a -> [a] -> [a]
    intersperse ByteString
    "\0" [ByteString]
    es

    putEventSpec (OsProcessPid Word32
    cs Word32
    pid) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    pid

    putEventSpec (OsProcessParentPid Word32
    cs Word32
    ppid) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    ppid

    putEventSpec (WallClockTime Word32
    cs Timestamp
    sec Word32
    nsec) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    cs
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    sec
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    nsec

    putEventSpec (Message (Text -> ByteString
    TE.encodeUtf8 -> ByteString
    s)) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (ByteString -> Int
    B.length ByteString
    s) :: Word16)
        ByteString -> PutM ()
    putByteString ByteString
    s

    putEventSpec (UserMessage (Text -> ByteString
    TE.encodeUtf8 -> ByteString
    s)) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (ByteString -> Int
    B.length ByteString
    s) :: Word16)
        ByteString -> PutM ()
    putByteString ByteString
    s

    putEventSpec (UserMarker (Text -> ByteString
    TE.encodeUtf8 -> ByteString
    s)) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (ByteString -> Int
    B.length ByteString
    s) :: Word16)
        ByteString -> PutM ()
    putByteString ByteString
    s

    putEventSpec (UnknownEvent {}) = String -> PutM ()
    forall a. HasCallStack => String -> a
    error String
    "putEventSpec UnknownEvent"

    putEventSpec (InternString String
    str Word32
    id) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE EventTypeNum
    len
        (Char -> PutM ()) -> String -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ Char -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE String
    str
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    id
      where len :: EventTypeNum
    len = (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (String -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    str) :: Word16) EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_string_id

    putEventSpec (Version String
    s) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (String -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    s) :: Word16)
        (Char -> PutM ()) -> String -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ Char -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE String
    s

    putEventSpec (ProgramInvocation String
    s) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (String -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length String
    s) :: Word16)
        (Char -> PutM ()) -> String -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ Char -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE String
    s

    putEventSpec ( EventInfo
    EdenStartReceive ) = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec ( EventInfo
    EdenEndReceive ) = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec ( CreateProcess  Word32
    process ) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    process

    putEventSpec ( KillProcess Word32
    process ) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    process

    putEventSpec ( AssignThreadToProcess Word32
    thread Word32
    process ) = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    thread
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    process

    putEventSpec ( CreateMachine EventTypeNum
    machine Timestamp
    realtime ) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE EventTypeNum
    machine
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    realtime

    putEventSpec ( KillMachine EventTypeNum
    machine ) = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE EventTypeNum
    machine

    putEventSpec ( SendMessage MessageTag
    mesTag Word32
    senderProcess Word32
    senderThread
                     EventTypeNum
    receiverMachine Word32
    receiverProcess Word32
    receiverInport ) = do
        RawMsgTag -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (MessageTag -> RawMsgTag
    fromMsgTag MessageTag
    mesTag)
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    senderProcess
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    senderThread
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE EventTypeNum
    receiverMachine
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    receiverProcess
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    receiverInport

    putEventSpec ( ReceiveMessage MessageTag
    mesTag Word32
    receiverProcess Word32
    receiverInport
                     EventTypeNum
    senderMachine Word32
    senderProcess Word32
    senderThread Word32
    messageSize ) = do
        RawMsgTag -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (MessageTag -> RawMsgTag
    fromMsgTag MessageTag
    mesTag)
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    receiverProcess
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    receiverInport
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE EventTypeNum
    senderMachine
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    senderProcess
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    senderThread
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    messageSize

    putEventSpec ( SendReceiveLocalMessage MessageTag
    mesTag Word32
    senderProcess Word32
    senderThread
                     Word32
    receiverProcess Word32
    receiverInport ) = do
        RawMsgTag -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (MessageTag -> RawMsgTag
    fromMsgTag MessageTag
    mesTag)
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    senderProcess
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    senderThread
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    receiverProcess
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    receiverInport

    putEventSpec (MerStartParConjunction Timestamp
    dyn_id Word32
    static_id) = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    dyn_id
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    static_id

    putEventSpec (MerEndParConjunction Timestamp
    dyn_id) =
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    dyn_id

    putEventSpec (MerEndParConjunct Timestamp
    dyn_id) =
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    dyn_id

    putEventSpec (MerCreateSpark Timestamp
    dyn_id Word32
    spark_id) = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    dyn_id
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    spark_id

    putEventSpec (MerFutureCreate Timestamp
    future_id Word32
    name_id) = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    future_id
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    name_id

    putEventSpec (MerFutureWaitNosuspend Timestamp
    future_id) =
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    future_id

    putEventSpec (MerFutureWaitSuspended Timestamp
    future_id) =
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    future_id

    putEventSpec (MerFutureSignal Timestamp
    future_id) =
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    future_id

    putEventSpec EventInfo
    MerLookingForGlobalThread = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    putEventSpec EventInfo
    MerWorkStealing = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    putEventSpec EventInfo
    MerLookingForLocalSpark = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec (MerReleaseThread Word32
    thread_id) =
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    thread_id

    putEventSpec EventInfo
    MerCapSleeping = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    putEventSpec EventInfo
    MerCallingMain = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    putEventSpec PerfName{name :: EventInfo -> Text
    name = (Text -> ByteString
    TE.encodeUtf8 -> ByteString
    name), Word32
    perfNum :: EventInfo -> Word32
    perfNum :: Word32
    ..} = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (ByteString -> Int
    B.length ByteString
    name) EventTypeNum -> EventTypeNum -> EventTypeNum
    forall a. Num a => a -> a -> a
    + EventTypeNum
    sz_perf_num :: Word16)
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    perfNum
        ByteString -> PutM ()
    putByteString ByteString
    name

    putEventSpec PerfCounter{Word32
    Timestamp
    KernelThreadId
    tid :: EventInfo -> KernelThreadId
    perfNum :: EventInfo -> Word32
    period :: EventInfo -> Timestamp
    perfNum :: Word32
    tid :: KernelThreadId
    period :: Timestamp
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    perfNum
        KernelThreadId -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE KernelThreadId
    tid
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    period

    putEventSpec PerfTracepoint{Word32
    KernelThreadId
    tid :: EventInfo -> KernelThreadId
    perfNum :: EventInfo -> Word32
    perfNum :: Word32
    tid :: KernelThreadId
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    perfNum
        KernelThreadId -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE KernelThreadId
    tid

    putEventSpec HeapProfBegin {RawMsgTag
    Timestamp
    Text
    HeapProfBreakdown
    heapProfBiographyFilter :: EventInfo -> Text
    heapProfRetainerFilter :: EventInfo -> Text
    heapProfCostCentreStackFilter :: EventInfo -> Text
    heapProfCostCentreFilter :: EventInfo -> Text
    heapProfTypeDescrFilter :: EventInfo -> Text
    heapProfClosureDescrFilter :: EventInfo -> Text
    heapProfModuleFilter :: EventInfo -> Text
    heapProfBreakdown :: EventInfo -> HeapProfBreakdown
    heapProfSamplingPeriod :: EventInfo -> Timestamp
    heapProfId :: EventInfo -> RawMsgTag
    heapProfId :: RawMsgTag
    heapProfSamplingPeriod :: Timestamp
    heapProfBreakdown :: HeapProfBreakdown
    heapProfModuleFilter :: Text
    heapProfClosureDescrFilter :: Text
    heapProfTypeDescrFilter :: Text
    heapProfCostCentreFilter :: Text
    heapProfCostCentreStackFilter :: Text
    heapProfRetainerFilter :: Text
    heapProfBiographyFilter :: Text
    ..} = do
        RawMsgTag -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE RawMsgTag
    heapProfId
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    heapProfSamplingPeriod
        HeapProfBreakdown -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE HeapProfBreakdown
    heapProfBreakdown
        (Text -> PutM ()) -> [Text] -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ (String -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (String -> PutM ()) -> (Text -> String) -> Text -> PutM ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> String
    T.unpack)
          [ Text
    heapProfModuleFilter
          , Text
    heapProfClosureDescrFilter
          , Text
    heapProfTypeDescrFilter
          , Text
    heapProfCostCentreFilter
          , Text
    heapProfCostCentreStackFilter
          , Text
    heapProfRetainerFilter
          , Text
    heapProfBiographyFilter
          ]

    putEventSpec HeapProfCostCentre {Word32
    Text
    HeapProfFlags
    heapProfFlags :: EventInfo -> HeapProfFlags
    heapProfSrcLoc :: EventInfo -> Text
    heapProfModule :: EventInfo -> Text
    heapProfLabel :: EventInfo -> Text
    heapProfCostCentreId :: EventInfo -> Word32
    heapProfCostCentreId :: Word32
    heapProfLabel :: Text
    heapProfModule :: Text
    heapProfSrcLoc :: Text
    heapProfFlags :: HeapProfFlags
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    heapProfCostCentreId
        String -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (String -> PutM ()) -> String -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ Text -> String
    T.unpack Text
    heapProfLabel
        String -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (String -> PutM ()) -> String -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ Text -> String
    T.unpack Text
    heapProfModule
        String -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (String -> PutM ()) -> String -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ Text -> String
    T.unpack Text
    heapProfSrcLoc
        HeapProfFlags -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE HeapProfFlags
    heapProfFlags

    putEventSpec HeapProfSampleBegin {Timestamp
    heapProfSampleEra :: EventInfo -> Timestamp
    heapProfSampleEra :: Timestamp
    ..} =
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    heapProfSampleEra

    putEventSpec HeapProfSampleEnd {Timestamp
    heapProfSampleEra :: EventInfo -> Timestamp
    heapProfSampleEra :: Timestamp
    ..} =
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    heapProfSampleEra

    putEventSpec HeapBioProfSampleBegin {Timestamp
    heapProfSampleEra :: EventInfo -> Timestamp
    heapProfSampleTime :: EventInfo -> Timestamp
    heapProfSampleEra :: Timestamp
    heapProfSampleTime :: Timestamp
    ..} = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    heapProfSampleEra
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    heapProfSampleTime

    putEventSpec HeapProfSampleCostCentre {RawMsgTag
    Timestamp
    Vector Word32
    heapProfId :: EventInfo -> RawMsgTag
    heapProfStack :: EventInfo -> Vector Word32
    heapProfStackDepth :: EventInfo -> RawMsgTag
    heapProfResidency :: EventInfo -> Timestamp
    heapProfId :: RawMsgTag
    heapProfResidency :: Timestamp
    heapProfStackDepth :: RawMsgTag
    heapProfStack :: Vector Word32
    ..} = do
        RawMsgTag -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE RawMsgTag
    heapProfId
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    heapProfResidency
        RawMsgTag -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE RawMsgTag
    heapProfStackDepth
        (Word32 -> PutM ()) -> Vector Word32 -> PutM ()
    forall (m :: * -> *) a b.
    (Monad m, Unbox a) =>
    (a -> m b) -> Vector a -> m ()
    VU.mapM_ Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Vector Word32
    heapProfStack

    putEventSpec HeapProfSampleString {RawMsgTag
    Timestamp
    Text
    heapProfId :: EventInfo -> RawMsgTag
    heapProfLabel :: EventInfo -> Text
    heapProfResidency :: EventInfo -> Timestamp
    heapProfId :: RawMsgTag
    heapProfResidency :: Timestamp
    heapProfLabel :: Text
    ..} = do
        RawMsgTag -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE RawMsgTag
    heapProfId
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    heapProfResidency
        String -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (String -> PutM ()) -> String -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ Text -> String
    T.unpack Text
    heapProfLabel

    putEventSpec ProfSampleCostCentre {RawMsgTag
    EventTypeNum
    Timestamp
    Vector Word32
    profCcsStack :: EventInfo -> Vector Word32
    profStackDepth :: EventInfo -> RawMsgTag
    profTicks :: EventInfo -> Timestamp
    profCap :: EventInfo -> EventTypeNum
    profCap :: EventTypeNum
    profTicks :: Timestamp
    profStackDepth :: RawMsgTag
    profCcsStack :: Vector Word32
    ..} = do
        Int16 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int16 -> PutM ()) -> Int16 -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ forall a b. (Integral a, Num b) => a -> b
    fromIntegral @CapNo @Int16 EventTypeNum
    profCap
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    profTicks
        RawMsgTag -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE RawMsgTag
    profStackDepth
        (Word32 -> PutM ()) -> Vector Word32 -> PutM ()
    forall (m :: * -> *) a b.
    (Monad m, Unbox a) =>
    (a -> m b) -> Vector a -> m ()
    VU.mapM_ Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Vector Word32
    profCcsStack

    putEventSpec ProfBegin {Timestamp
    profTickInterval :: EventInfo -> Timestamp
    profTickInterval :: Timestamp
    ..} = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    profTickInterval

    putEventSpec UserBinaryMessage {ByteString
    payload :: EventInfo -> ByteString
    payload :: ByteString
    ..} = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Int -> EventTypeNum
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (ByteString -> Int
    B.length ByteString
    payload) :: Word16)
        ByteString -> PutM ()
    putByteString ByteString
    payload

    putEventSpec EventInfo
    ConcMarkBegin = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    putEventSpec ConcMarkEnd {Word32
    concMarkedObjectCount :: EventInfo -> Word32
    concMarkedObjectCount :: Word32
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    concMarkedObjectCount
    putEventSpec EventInfo
    ConcSyncBegin = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    putEventSpec EventInfo
    ConcSyncEnd = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    putEventSpec EventInfo
    ConcSweepBegin = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    putEventSpec EventInfo
    ConcSweepEnd = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    putEventSpec ConcUpdRemSetFlush {Int
    cap :: EventInfo -> Int
    cap :: Int
    ..} = do
        Int -> PutM ()
    putCap Int
    cap
    putEventSpec NonmovingHeapCensus {EventTypeNum
    Word32
    nonmovingCensusLiveBlocks :: EventInfo -> Word32
    nonmovingCensusFilledSegs :: EventInfo -> Word32
    nonmovingCensusActiveSegs :: EventInfo -> Word32
    nonmovingCensusBlkSize :: EventInfo -> EventTypeNum
    nonmovingCensusBlkSize :: EventTypeNum
    nonmovingCensusActiveSegs :: Word32
    nonmovingCensusFilledSegs :: Word32
    nonmovingCensusLiveBlocks :: Word32
    ..} = do
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE EventTypeNum
    nonmovingCensusBlkSize
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    nonmovingCensusActiveSegs
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    nonmovingCensusFilledSegs
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    nonmovingCensusLiveBlocks
    putEventSpec NonmovingPrunedSegments {Word32
    nonmovingFreeSegments :: EventInfo -> Word32
    nonmovingPrunedSegments :: EventInfo -> Word32
    nonmovingPrunedSegments :: Word32
    nonmovingFreeSegments :: Word32
    ..} = do
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    nonmovingPrunedSegments
        Word32 -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Word32
    nonmovingFreeSegments
    putEventSpec TickyCounterDef {Maybe Text
    EventTypeNum
    Timestamp
    Text
    tickyCtrJsonDesc :: EventInfo -> Maybe Text
    tickyCtrInfoTbl :: EventInfo -> Timestamp
    tickyCtrDefName :: EventInfo -> Text
    tickyCtrDefKinds :: EventInfo -> Text
    tickyCtrDefArity :: EventInfo -> EventTypeNum
    tickyCtrDefId :: EventInfo -> Timestamp
    tickyCtrDefId :: Timestamp
    tickyCtrDefArity :: EventTypeNum
    tickyCtrDefKinds :: Text
    tickyCtrDefName :: Text
    tickyCtrInfoTbl :: Timestamp
    tickyCtrJsonDesc :: Maybe Text
    ..} = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    tickyCtrDefId
        EventTypeNum -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE EventTypeNum
    tickyCtrDefArity
        String -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Text -> String
    T.unpack Text
    tickyCtrDefKinds)
        String -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Text -> String
    T.unpack Text
    tickyCtrDefName)
        Bool -> PutM () -> PutM ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (Timestamp
    tickyCtrInfoTbl Timestamp -> Timestamp -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Timestamp
    0) (PutM () -> PutM ()) -> PutM () -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ do
          Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    tickyCtrInfoTbl
          -- The json description without the info table field is not supported.
          Bool -> PutM () -> PutM ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (Maybe Text -> Bool
    forall a. Maybe a -> Bool
    isJust Maybe Text
    tickyCtrJsonDesc) (PutM () -> PutM ()) -> PutM () -> PutM ()
    forall a b. (a -> b) -> a -> b
    $ Text -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (Maybe Text -> Text
    forall a. HasCallStack => Maybe a -> a
    fromJust Maybe Text
    tickyCtrJsonDesc)
    putEventSpec TickyCounterSample {Timestamp
    tickyCtrSampleAllocd :: EventInfo -> Timestamp
    tickyCtrSampleAllocs :: EventInfo -> Timestamp
    tickyCtrSampleEntryCount :: EventInfo -> Timestamp
    tickyCtrSampleId :: EventInfo -> Timestamp
    tickyCtrSampleId :: Timestamp
    tickyCtrSampleEntryCount :: Timestamp
    tickyCtrSampleAllocs :: Timestamp
    tickyCtrSampleAllocd :: Timestamp
    ..} = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    tickyCtrSampleId
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    tickyCtrSampleEntryCount
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    tickyCtrSampleAllocs
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    tickyCtrSampleAllocd
    putEventSpec InfoTableProv{Int
    Timestamp
    Text
    itSrcLoc :: EventInfo -> Text
    itModule :: EventInfo -> Text
    itLabel :: EventInfo -> Text
    itTyDesc :: EventInfo -> Text
    itClosureDesc :: EventInfo -> Int
    itTableName :: EventInfo -> Text
    itInfo :: EventInfo -> Timestamp
    itInfo :: Timestamp
    itTableName :: Text
    itClosureDesc :: Int
    itTyDesc :: Text
    itLabel :: Text
    itModule :: Text
    itSrcLoc :: Text
    ..} = do
        Timestamp -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE Timestamp
    itInfo
        (Text -> PutM ()) -> [Text] -> PutM ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ (String -> PutM ()
    forall a. Binary a => a -> PutM ()
    putE (String -> PutM ()) -> (Text -> String) -> Text -> PutM ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> String
    T.unpack)
          [ Text
    itTableName
          , String -> Text
    T.pack (Int -> String
    forall a. Show a => a -> String
    show Int
    itClosureDesc)
          , Text
    itTyDesc
          , Text
    itLabel
          , Text
    itModule
          , Text
    itSrcLoc
          ]
    putEventSpec EventInfo
    TickyBeginSample = () -> PutM ()
    forall a. a -> PutM a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()