    {-# LANGUAGE DeriveGeneric, GeneralizedNewtypeDeriving #-}
    -- | Game messages displayed on top of the screen for the player to read
    -- and then saved to player history.
    module Game.LambdaHack.Client.UI.Msg
      ( -- * Msg
        Msg, MsgShared, toMsgShared, toMsgDistinct
      , MsgClassShowAndSave(..), MsgClassShow(..), MsgClassSave(..)
      , MsgClassIgnore(..), MsgClassDistinct(..)
      , MsgClass, interruptsRunning, disturbsResting
        -- * Report
      , Report, nullVisibleReport, consReport, renderReport, anyInReport
        -- * History
      , History, newReport, emptyHistory, addToReport, addEolToNewReport
      , archiveReport, lengthHistory, renderHistory
    #ifdef EXPOSE_INTERNAL
        -- * Internal operations
      , UAttrString, uToAttrString, attrStringToU
      , toMsg, MsgPrototype, tripleFromProto
      , scrapsRepeats, isTutorialHint, msgColor
      , RepMsgNK, nullRepMsgNK
      , emptyReport, renderRepetition
      , scrapRepetitionSingle, scrapRepetition, renderTimeReport
    #endif
      ) where

    import Prelude ()

    import Game.LambdaHack.Core.Prelude

    import           Data.Binary
    import qualified Data.Char as Char
    import qualified Data.Set as S
    import           Data.Vector.Binary ()
    import qualified Data.Vector.Unboxed as U
    import           GHC.Generics (Generic)

    import           Game.LambdaHack.Client.UI.Overlay
    import qualified Game.LambdaHack.Common.RingBuffer as RB
    import           Game.LambdaHack.Common.Time
    import qualified Game.LambdaHack.Definition.Color as Color

    -- * UAttrString

    type UAttrString = U.Vector Word32

    uToAttrString :: UAttrString -> AttrString
    uToAttrString :: UAttrString -> [AttrCharW32]
    uToAttrString UAttrString
    v = (Word32 -> AttrCharW32) -> [Word32] -> [AttrCharW32]
    forall a b. (a -> b) -> [a] -> [b]
    map Word32 -> AttrCharW32
    Color.AttrCharW32 ([Word32] -> [AttrCharW32]) -> [Word32] -> [AttrCharW32]
    forall a b. (a -> b) -> a -> b
    $ UAttrString -> [Word32]
    forall a. Unbox a => Vector a -> [a]
    U.toList UAttrString
    v

    attrStringToU :: AttrString -> UAttrString
    attrStringToU :: [AttrCharW32] -> UAttrString
    attrStringToU [AttrCharW32]
    l = [Word32] -> UAttrString
    forall a. Unbox a => [a] -> Vector a
    U.fromList ([Word32] -> UAttrString) -> [Word32] -> UAttrString
    forall a b. (a -> b) -> a -> b
    $ (AttrCharW32 -> Word32) -> [AttrCharW32] -> [Word32]
    forall a b. (a -> b) -> [a] -> [b]
    map AttrCharW32 -> Word32
    Color.attrCharW32 [AttrCharW32]
    l

    -- * Msg

    -- | The type of a single game message.
    data Msg = Msg
      { Msg -> [AttrCharW32]
    msgShow  :: AttrString  -- ^ the colours and characters of the message
                                --   to be shown on the screen; not just text,
                                --   in case there was some colour not coming
                                --   from the message class
      , Msg -> [AttrCharW32]
    msgSave  :: AttrString  -- ^ the same to be saved in the message log only
      , Msg -> MsgClass
    msgClass :: MsgClass
      }
      deriving (Int -> Msg -> ShowS
    [Msg] -> ShowS
    Msg -> [Char]
    (Int -> Msg -> ShowS)
    -> (Msg -> [Char]) -> ([Msg] -> ShowS) -> Show Msg
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Msg -> ShowS
    showsPrec :: Int -> Msg -> ShowS
    $cshow :: Msg -> [Char]
    show :: Msg -> [Char]
    $cshowList :: [Msg] -> ShowS
    showList :: [Msg] -> ShowS
    Show, Msg -> Msg -> Bool
    (Msg -> Msg -> Bool) -> (Msg -> Msg -> Bool) -> Eq Msg
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Msg -> Msg -> Bool
    == :: Msg -> Msg -> Bool
    $c/= :: Msg -> Msg -> Bool
    /= :: Msg -> Msg -> Bool
    Eq, Eq Msg
    Eq Msg =>
    (Msg -> Msg -> Ordering)
    -> (Msg -> Msg -> Bool)
    -> (Msg -> Msg -> Bool)
    -> (Msg -> Msg -> Bool)
    -> (Msg -> Msg -> Bool)
    -> (Msg -> Msg -> Msg)
    -> (Msg -> Msg -> Msg)
    -> Ord Msg
    Msg -> Msg -> Bool
    Msg -> Msg -> Ordering
    Msg -> Msg -> Msg
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Msg -> Msg -> Ordering
    compare :: Msg -> Msg -> Ordering
    $c< :: Msg -> Msg -> Bool
    < :: Msg -> Msg -> Bool
    $c<= :: Msg -> Msg -> Bool
    <= :: Msg -> Msg -> Bool
    $c> :: Msg -> Msg -> Bool
    > :: Msg -> Msg -> Bool
    $c>= :: Msg -> Msg -> Bool
    >= :: Msg -> Msg -> Bool
    $cmax :: Msg -> Msg -> Msg
    max :: Msg -> Msg -> Msg
    $cmin :: Msg -> Msg -> Msg
    min :: Msg -> Msg -> Msg
    Ord, (forall x. Msg -> Rep Msg x)
    -> (forall x. Rep Msg x -> Msg) -> Generic Msg
    forall x. Rep Msg x -> Msg
    forall x. Msg -> Rep Msg x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Msg -> Rep Msg x
    from :: forall x. Msg -> Rep Msg x
    $cto :: forall x. Rep Msg x -> Msg
    to :: forall x. Rep Msg x -> Msg
    Generic)

    instance Binary Msg

    toMsg :: [(String, Color.Color)] -> MsgPrototype -> Msg
    toMsg :: [([Char], Color)] -> MsgPrototype -> Msg
    toMsg [([Char], Color)]
    prefixColors MsgPrototype
    msgProto =
      let (Text
    tShow, Text
    tSave, MsgClass
    msgClass) = MsgPrototype -> (Text, Text, MsgClass)
    tripleFromProto MsgPrototype
    msgProto
          msgClassName :: [Char]
    msgClassName = MsgClass -> [Char]
    showSimpleMsgClass MsgClass
    msgClass
          mprefixColor :: Maybe ([Char], Color)
    mprefixColor = (([Char], Color) -> Bool)
    -> [([Char], Color)] -> Maybe ([Char], Color)
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
    find (([Char] -> [Char] -> Bool
    forall a. Eq a => [a] -> [a] -> Bool
    `isPrefixOf` [Char]
    msgClassName) ([Char] -> Bool)
    -> (([Char], Color) -> [Char]) -> ([Char], Color) -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Char], Color) -> [Char]
    forall a b. (a, b) -> a
    fst) [([Char], Color)]
    prefixColors
          color :: Color
    color = Color
    -> (([Char], Color) -> Color) -> Maybe ([Char], Color) -> Color
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (MsgClass -> Color
    msgColor MsgClass
    msgClass) ([Char], Color) -> Color
    forall a b. (a, b) -> b
    snd Maybe ([Char], Color)
    mprefixColor
          msgShow :: [AttrCharW32]
    msgShow = Color -> Text -> [AttrCharW32]
    textFgToAS Color
    color Text
    tShow
          msgSave :: [AttrCharW32]
    msgSave = Color -> Text -> [AttrCharW32]
    textFgToAS Color
    color Text
    tSave
      in Msg {[AttrCharW32]
    MsgClass
    msgShow :: [AttrCharW32]
    msgSave :: [AttrCharW32]
    msgClass :: MsgClass
    msgClass :: MsgClass
    msgShow :: [AttrCharW32]
    msgSave :: [AttrCharW32]
    ..}

    data MsgPrototype =
        MsgProtoShowAndSave MsgClassShowAndSave Text
      | MsgProtoShow MsgClassShow Text
      | MsgProtoSave MsgClassSave Text
      | MsgProtoIgnore MsgClassIgnore
      | MsgProtoDistinct MsgClassDistinct Text Text

    tripleFromProto :: MsgPrototype -> (Text, Text, MsgClass)
    tripleFromProto :: MsgPrototype -> (Text, Text, MsgClass)
    tripleFromProto = \case
      MsgProtoShowAndSave MsgClassShowAndSave
    x Text
    t -> (Text
    t, Text
    t, MsgClassShowAndSave -> MsgClass
    MsgClassShowAndSave MsgClassShowAndSave
    x)
      MsgProtoShow MsgClassShow
    x Text
    t -> (Text
    t, Text
    "", MsgClassShow -> MsgClass
    MsgClassShow MsgClassShow
    x)
      MsgProtoSave MsgClassSave
    x Text
    t -> (Text
    "", Text
    t, MsgClassSave -> MsgClass
    MsgClassSave MsgClassSave
    x)
      MsgProtoIgnore MsgClassIgnore
    x -> (Text
    "", Text
    "", MsgClassIgnore -> MsgClass
    MsgClassIgnore MsgClassIgnore
    x)
      MsgProtoDistinct MsgClassDistinct
    x Text
    t1 Text
    t2 -> (Text
    t1, Text
    t2, MsgClassDistinct -> MsgClass
    MsgClassDistinct MsgClassDistinct
    x)

    class MsgShared a where
      toMsgShared :: [(String, Color.Color)] -> a -> Text -> Msg

    instance MsgShared MsgClassShowAndSave where
      toMsgShared :: [([Char], Color)] -> MsgClassShowAndSave -> Text -> Msg
    toMsgShared [([Char], Color)]
    prefixColors MsgClassShowAndSave
    msgClass Text
    t =
        [([Char], Color)] -> MsgPrototype -> Msg
    toMsg [([Char], Color)]
    prefixColors (MsgPrototype -> Msg) -> MsgPrototype -> Msg
    forall a b. (a -> b) -> a -> b
    $ MsgClassShowAndSave -> Text -> MsgPrototype
    MsgProtoShowAndSave MsgClassShowAndSave
    msgClass Text
    t

    instance MsgShared MsgClassShow where
      toMsgShared :: [([Char], Color)] -> MsgClassShow -> Text -> Msg
    toMsgShared [([Char], Color)]
    prefixColors MsgClassShow
    msgClass Text
    t =
        [([Char], Color)] -> MsgPrototype -> Msg
    toMsg [([Char], Color)]
    prefixColors (MsgPrototype -> Msg) -> MsgPrototype -> Msg
    forall a b. (a -> b) -> a -> b
    $ MsgClassShow -> Text -> MsgPrototype
    MsgProtoShow MsgClassShow
    msgClass Text
    t

    instance MsgShared MsgClassSave where
      toMsgShared :: [([Char], Color)] -> MsgClassSave -> Text -> Msg
    toMsgShared [([Char], Color)]
    prefixColors MsgClassSave
    msgClass Text
    t =
        [([Char], Color)] -> MsgPrototype -> Msg
    toMsg [([Char], Color)]
    prefixColors (MsgPrototype -> Msg) -> MsgPrototype -> Msg
    forall a b. (a -> b) -> a -> b
    $ MsgClassSave -> Text -> MsgPrototype
    MsgProtoSave MsgClassSave
    msgClass Text
    t

    instance MsgShared MsgClassIgnore where
      toMsgShared :: [([Char], Color)] -> MsgClassIgnore -> Text -> Msg
    toMsgShared [([Char], Color)]
    prefixColors MsgClassIgnore
    msgClass Text
    _ =
        [([Char], Color)] -> MsgPrototype -> Msg
    toMsg [([Char], Color)]
    prefixColors (MsgPrototype -> Msg) -> MsgPrototype -> Msg
    forall a b. (a -> b) -> a -> b
    $ MsgClassIgnore -> MsgPrototype
    MsgProtoIgnore MsgClassIgnore
    msgClass

    toMsgDistinct :: [(String, Color.Color)] -> MsgClassDistinct -> Text -> Text
                  -> Msg
    toMsgDistinct :: [([Char], Color)] -> MsgClassDistinct -> Text -> Text -> Msg
    toMsgDistinct [([Char], Color)]
    prefixColors MsgClassDistinct
    msgClass Text
    t1 Text
    t2 =
      [([Char], Color)] -> MsgPrototype -> Msg
    toMsg [([Char], Color)]
    prefixColors (MsgPrototype -> Msg) -> MsgPrototype -> Msg
    forall a b. (a -> b) -> a -> b
    $ MsgClassDistinct -> Text -> Text -> MsgPrototype
    MsgProtoDistinct MsgClassDistinct
    msgClass Text
    t1 Text
    t2

    -- Each constructor name should have length as asserted in @emptyReport@,
    -- so that the message log with message classes (if set in config) looks tidy.
    data MsgClass =
        MsgClassShowAndSave MsgClassShowAndSave
      | MsgClassShow MsgClassShow
      | MsgClassSave MsgClassSave
      | MsgClassIgnore MsgClassIgnore
      | MsgClassDistinct MsgClassDistinct
      deriving (Int -> MsgClass -> ShowS
    [MsgClass] -> ShowS
    MsgClass -> [Char]
    (Int -> MsgClass -> ShowS)
    -> (MsgClass -> [Char]) -> ([MsgClass] -> ShowS) -> Show MsgClass
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MsgClass -> ShowS
    showsPrec :: Int -> MsgClass -> ShowS
    $cshow :: MsgClass -> [Char]
    show :: MsgClass -> [Char]
    $cshowList :: [MsgClass] -> ShowS
    showList :: [MsgClass] -> ShowS
    Show, MsgClass -> MsgClass -> Bool
    (MsgClass -> MsgClass -> Bool)
    -> (MsgClass -> MsgClass -> Bool) -> Eq MsgClass
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MsgClass -> MsgClass -> Bool
    == :: MsgClass -> MsgClass -> Bool
    $c/= :: MsgClass -> MsgClass -> Bool
    /= :: MsgClass -> MsgClass -> Bool
    Eq, Eq MsgClass
    Eq MsgClass =>
    (MsgClass -> MsgClass -> Ordering)
    -> (MsgClass -> MsgClass -> Bool)
    -> (MsgClass -> MsgClass -> Bool)
    -> (MsgClass -> MsgClass -> Bool)
    -> (MsgClass -> MsgClass -> Bool)
    -> (MsgClass -> MsgClass -> MsgClass)
    -> (MsgClass -> MsgClass -> MsgClass)
    -> Ord MsgClass
    MsgClass -> MsgClass -> Bool
    MsgClass -> MsgClass -> Ordering
    MsgClass -> MsgClass -> MsgClass
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: MsgClass -> MsgClass -> Ordering
    compare :: MsgClass -> MsgClass -> Ordering
    $c< :: MsgClass -> MsgClass -> Bool
    < :: MsgClass -> MsgClass -> Bool
    $c<= :: MsgClass -> MsgClass -> Bool
    <= :: MsgClass -> MsgClass -> Bool
    $c> :: MsgClass -> MsgClass -> Bool
    > :: MsgClass -> MsgClass -> Bool
    $c>= :: MsgClass -> MsgClass -> Bool
    >= :: MsgClass -> MsgClass -> Bool
    $cmax :: MsgClass -> MsgClass -> MsgClass
    max :: MsgClass -> MsgClass -> MsgClass
    $cmin :: MsgClass -> MsgClass -> MsgClass
    min :: MsgClass -> MsgClass -> MsgClass
    Ord, (forall x. MsgClass -> Rep MsgClass x)
    -> (forall x. Rep MsgClass x -> MsgClass) -> Generic MsgClass
    forall x. Rep MsgClass x -> MsgClass
    forall x. MsgClass -> Rep MsgClass x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. MsgClass -> Rep MsgClass x
    from :: forall x. MsgClass -> Rep MsgClass x
    $cto :: forall x. Rep MsgClass x -> MsgClass
    to :: forall x. Rep MsgClass x -> MsgClass
    Generic)

    instance Binary MsgClass

    showSimpleMsgClass :: MsgClass -> String
    showSimpleMsgClass :: MsgClass -> [Char]
    showSimpleMsgClass = \case
      MsgClassShowAndSave MsgClassShowAndSave
    x -> MsgClassShowAndSave -> [Char]
    forall a. Show a => a -> [Char]
    show MsgClassShowAndSave
    x
      MsgClassShow MsgClassShow
    x -> MsgClassShow -> [Char]
    forall a. Show a => a -> [Char]
    show MsgClassShow
    x
      MsgClassSave MsgClassSave
    x -> MsgClassSave -> [Char]
    forall a. Show a => a -> [Char]
    show MsgClassSave
    x
      MsgClassIgnore MsgClassIgnore
    x -> MsgClassIgnore -> [Char]
    forall a. Show a => a -> [Char]
    show MsgClassIgnore
    x
      MsgClassDistinct MsgClassDistinct
    x -> MsgClassDistinct -> [Char]
    forall a. Show a => a -> [Char]
    show MsgClassDistinct
    x

    data MsgClassShowAndSave =
        MsgBookKeeping
      | MsgStatusWakeup
      | MsgStatusStopUs
      | MsgStatusStopThem
      | MsgItemCreation
      | MsgItemRuination
      | MsgDeathVictory
      | MsgDeathDeafeat
      | MsgDeathBoring
      | MsgRiskOfDeath
      | MsgPointmanSwap
      | MsgFactionIntel
      | MsgFinalOutcome
      | MsgBackdropInfo
      | MsgTerrainReveal
      | MsgItemDiscovery
      | MsgSpottedActor
      | MsgItemMovement
      | MsgActionMajor
      | MsgActionMinor
      | MsgEffectMajor
      | MsgEffectMedium
      | MsgEffectMinor
      | MsgMiscellanous
      | MsgHeardOutside
      | MsgHeardNearby
      | MsgHeardFaraway
      | MsgBackdropFocus
      | MsgActionWarning
      | MsgRangedMightyWe
      | MsgRangedMightyUs
      | MsgRangedOthers  -- not ours or projectiles are hit
      | MsgRangedNormalUs
      | MsgGoodMiscEvent
      | MsgBadMiscEvent
      | MsgNeutralEvent
      | MsgSpecialEvent
      | MsgMeleeMightyWe
      | MsgMeleeMightyUs
      | MsgMeleeComplexWe
      | MsgMeleeComplexUs
      | MsgMeleeOthers  -- not ours or projectiles are hit
      | MsgMeleeNormalUs
      | MsgActionComplete
      | MsgAtFeetMajor
      | MsgAtFeetMinor
      | MsgTutorialHint
      deriving (Int -> MsgClassShowAndSave -> ShowS
    [MsgClassShowAndSave] -> ShowS
    MsgClassShowAndSave -> [Char]
    (Int -> MsgClassShowAndSave -> ShowS)
    -> (MsgClassShowAndSave -> [Char])
    -> ([MsgClassShowAndSave] -> ShowS)
    -> Show MsgClassShowAndSave
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MsgClassShowAndSave -> ShowS
    showsPrec :: Int -> MsgClassShowAndSave -> ShowS
    $cshow :: MsgClassShowAndSave -> [Char]
    show :: MsgClassShowAndSave -> [Char]
    $cshowList :: [MsgClassShowAndSave] -> ShowS
    showList :: [MsgClassShowAndSave] -> ShowS
    Show, MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    (MsgClassShowAndSave -> MsgClassShowAndSave -> Bool)
    -> (MsgClassShowAndSave -> MsgClassShowAndSave -> Bool)
    -> Eq MsgClassShowAndSave
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    == :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    $c/= :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    /= :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    Eq, Eq MsgClassShowAndSave
    Eq MsgClassShowAndSave =>
    (MsgClassShowAndSave -> MsgClassShowAndSave -> Ordering)
    -> (MsgClassShowAndSave -> MsgClassShowAndSave -> Bool)
    -> (MsgClassShowAndSave -> MsgClassShowAndSave -> Bool)
    -> (MsgClassShowAndSave -> MsgClassShowAndSave -> Bool)
    -> (MsgClassShowAndSave -> MsgClassShowAndSave -> Bool)
    -> (MsgClassShowAndSave
        -> MsgClassShowAndSave -> MsgClassShowAndSave)
    -> (MsgClassShowAndSave
        -> MsgClassShowAndSave -> MsgClassShowAndSave)
    -> Ord MsgClassShowAndSave
    MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    MsgClassShowAndSave -> MsgClassShowAndSave -> Ordering
    MsgClassShowAndSave -> MsgClassShowAndSave -> MsgClassShowAndSave
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: MsgClassShowAndSave -> MsgClassShowAndSave -> Ordering
    compare :: MsgClassShowAndSave -> MsgClassShowAndSave -> Ordering
    $c< :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    < :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    $c<= :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    <= :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    $c> :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    > :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    $c>= :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    >= :: MsgClassShowAndSave -> MsgClassShowAndSave -> Bool
    $cmax :: MsgClassShowAndSave -> MsgClassShowAndSave -> MsgClassShowAndSave
    max :: MsgClassShowAndSave -> MsgClassShowAndSave -> MsgClassShowAndSave
    $cmin :: MsgClassShowAndSave -> MsgClassShowAndSave -> MsgClassShowAndSave
    min :: MsgClassShowAndSave -> MsgClassShowAndSave -> MsgClassShowAndSave
    Ord, Int -> MsgClassShowAndSave
    MsgClassShowAndSave -> Int
    MsgClassShowAndSave -> [MsgClassShowAndSave]
    MsgClassShowAndSave -> MsgClassShowAndSave
    MsgClassShowAndSave -> MsgClassShowAndSave -> [MsgClassShowAndSave]
    MsgClassShowAndSave
    -> MsgClassShowAndSave
    -> MsgClassShowAndSave
    -> [MsgClassShowAndSave]
    (MsgClassShowAndSave -> MsgClassShowAndSave)
    -> (MsgClassShowAndSave -> MsgClassShowAndSave)
    -> (Int -> MsgClassShowAndSave)
    -> (MsgClassShowAndSave -> Int)
    -> (MsgClassShowAndSave -> [MsgClassShowAndSave])
    -> (MsgClassShowAndSave
        -> MsgClassShowAndSave -> [MsgClassShowAndSave])
    -> (MsgClassShowAndSave
        -> MsgClassShowAndSave -> [MsgClassShowAndSave])
    -> (MsgClassShowAndSave
        -> MsgClassShowAndSave
        -> MsgClassShowAndSave
        -> [MsgClassShowAndSave])
    -> Enum MsgClassShowAndSave
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: MsgClassShowAndSave -> MsgClassShowAndSave
    succ :: MsgClassShowAndSave -> MsgClassShowAndSave
    $cpred :: MsgClassShowAndSave -> MsgClassShowAndSave
    pred :: MsgClassShowAndSave -> MsgClassShowAndSave
    $ctoEnum :: Int -> MsgClassShowAndSave
    toEnum :: Int -> MsgClassShowAndSave
    $cfromEnum :: MsgClassShowAndSave -> Int
    fromEnum :: MsgClassShowAndSave -> Int
    $cenumFrom :: MsgClassShowAndSave -> [MsgClassShowAndSave]
    enumFrom :: MsgClassShowAndSave -> [MsgClassShowAndSave]
    $cenumFromThen :: MsgClassShowAndSave -> MsgClassShowAndSave -> [MsgClassShowAndSave]
    enumFromThen :: MsgClassShowAndSave -> MsgClassShowAndSave -> [MsgClassShowAndSave]
    $cenumFromTo :: MsgClassShowAndSave -> MsgClassShowAndSave -> [MsgClassShowAndSave]
    enumFromTo :: MsgClassShowAndSave -> MsgClassShowAndSave -> [MsgClassShowAndSave]
    $cenumFromThenTo :: MsgClassShowAndSave
    -> MsgClassShowAndSave
    -> MsgClassShowAndSave
    -> [MsgClassShowAndSave]
    enumFromThenTo :: MsgClassShowAndSave
    -> MsgClassShowAndSave
    -> MsgClassShowAndSave
    -> [MsgClassShowAndSave]
    Enum, MsgClassShowAndSave
    MsgClassShowAndSave
    -> MsgClassShowAndSave -> Bounded MsgClassShowAndSave
    forall a. a -> a -> Bounded a
    $cminBound :: MsgClassShowAndSave
    minBound :: MsgClassShowAndSave
    $cmaxBound :: MsgClassShowAndSave
    maxBound :: MsgClassShowAndSave
    Bounded, (forall x. MsgClassShowAndSave -> Rep MsgClassShowAndSave x)
    -> (forall x. Rep MsgClassShowAndSave x -> MsgClassShowAndSave)
    -> Generic MsgClassShowAndSave
    forall x. Rep MsgClassShowAndSave x -> MsgClassShowAndSave
    forall x. MsgClassShowAndSave -> Rep MsgClassShowAndSave x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. MsgClassShowAndSave -> Rep MsgClassShowAndSave x
    from :: forall x. MsgClassShowAndSave -> Rep MsgClassShowAndSave x
    $cto :: forall x. Rep MsgClassShowAndSave x -> MsgClassShowAndSave
    to :: forall x. Rep MsgClassShowAndSave x -> MsgClassShowAndSave
    Generic)

    instance Binary MsgClassShowAndSave

    data MsgClassShow =
        MsgPromptGeneric
      | MsgPromptFocus
      | MsgPromptMention
      | MsgPromptModify
      | MsgPromptActors
      | MsgPromptItems
      | MsgPromptAction
      | MsgActionAlert
      | MsgSpottedThreat
      deriving (Int -> MsgClassShow -> ShowS
    [MsgClassShow] -> ShowS
    MsgClassShow -> [Char]
    (Int -> MsgClassShow -> ShowS)
    -> (MsgClassShow -> [Char])
    -> ([MsgClassShow] -> ShowS)
    -> Show MsgClassShow
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MsgClassShow -> ShowS
    showsPrec :: Int -> MsgClassShow -> ShowS
    $cshow :: MsgClassShow -> [Char]
    show :: MsgClassShow -> [Char]
    $cshowList :: [MsgClassShow] -> ShowS
    showList :: [MsgClassShow] -> ShowS
    Show, MsgClassShow -> MsgClassShow -> Bool
    (MsgClassShow -> MsgClassShow -> Bool)
    -> (MsgClassShow -> MsgClassShow -> Bool) -> Eq MsgClassShow
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MsgClassShow -> MsgClassShow -> Bool
    == :: MsgClassShow -> MsgClassShow -> Bool
    $c/= :: MsgClassShow -> MsgClassShow -> Bool
    /= :: MsgClassShow -> MsgClassShow -> Bool
    Eq, Eq MsgClassShow
    Eq MsgClassShow =>
    (MsgClassShow -> MsgClassShow -> Ordering)
    -> (MsgClassShow -> MsgClassShow -> Bool)
    -> (MsgClassShow -> MsgClassShow -> Bool)
    -> (MsgClassShow -> MsgClassShow -> Bool)
    -> (MsgClassShow -> MsgClassShow -> Bool)
    -> (MsgClassShow -> MsgClassShow -> MsgClassShow)
    -> (MsgClassShow -> MsgClassShow -> MsgClassShow)
    -> Ord MsgClassShow
    MsgClassShow -> MsgClassShow -> Bool
    MsgClassShow -> MsgClassShow -> Ordering
    MsgClassShow -> MsgClassShow -> MsgClassShow
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: MsgClassShow -> MsgClassShow -> Ordering
    compare :: MsgClassShow -> MsgClassShow -> Ordering
    $c< :: MsgClassShow -> MsgClassShow -> Bool
    < :: MsgClassShow -> MsgClassShow -> Bool
    $c<= :: MsgClassShow -> MsgClassShow -> Bool
    <= :: MsgClassShow -> MsgClassShow -> Bool
    $c> :: MsgClassShow -> MsgClassShow -> Bool
    > :: MsgClassShow -> MsgClassShow -> Bool
    $c>= :: MsgClassShow -> MsgClassShow -> Bool
    >= :: MsgClassShow -> MsgClassShow -> Bool
    $cmax :: MsgClassShow -> MsgClassShow -> MsgClassShow
    max :: MsgClassShow -> MsgClassShow -> MsgClassShow
    $cmin :: MsgClassShow -> MsgClassShow -> MsgClassShow
    min :: MsgClassShow -> MsgClassShow -> MsgClassShow
    Ord, Int -> MsgClassShow
    MsgClassShow -> Int
    MsgClassShow -> [MsgClassShow]
    MsgClassShow -> MsgClassShow
    MsgClassShow -> MsgClassShow -> [MsgClassShow]
    MsgClassShow -> MsgClassShow -> MsgClassShow -> [MsgClassShow]
    (MsgClassShow -> MsgClassShow)
    -> (MsgClassShow -> MsgClassShow)
    -> (Int -> MsgClassShow)
    -> (MsgClassShow -> Int)
    -> (MsgClassShow -> [MsgClassShow])
    -> (MsgClassShow -> MsgClassShow -> [MsgClassShow])
    -> (MsgClassShow -> MsgClassShow -> [MsgClassShow])
    -> (MsgClassShow -> MsgClassShow -> MsgClassShow -> [MsgClassShow])
    -> Enum MsgClassShow
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: MsgClassShow -> MsgClassShow
    succ :: MsgClassShow -> MsgClassShow
    $cpred :: MsgClassShow -> MsgClassShow
    pred :: MsgClassShow -> MsgClassShow
    $ctoEnum :: Int -> MsgClassShow
    toEnum :: Int -> MsgClassShow
    $cfromEnum :: MsgClassShow -> Int
    fromEnum :: MsgClassShow -> Int
    $cenumFrom :: MsgClassShow -> [MsgClassShow]
    enumFrom :: MsgClassShow -> [MsgClassShow]
    $cenumFromThen :: MsgClassShow -> MsgClassShow -> [MsgClassShow]
    enumFromThen :: MsgClassShow -> MsgClassShow -> [MsgClassShow]
    $cenumFromTo :: MsgClassShow -> MsgClassShow -> [MsgClassShow]
    enumFromTo :: MsgClassShow -> MsgClassShow -> [MsgClassShow]
    $cenumFromThenTo :: MsgClassShow -> MsgClassShow -> MsgClassShow -> [MsgClassShow]
    enumFromThenTo :: MsgClassShow -> MsgClassShow -> MsgClassShow -> [MsgClassShow]
    Enum, MsgClassShow
    MsgClassShow -> MsgClassShow -> Bounded MsgClassShow
    forall a. a -> a -> Bounded a
    $cminBound :: MsgClassShow
    minBound :: MsgClassShow
    $cmaxBound :: MsgClassShow
    maxBound :: MsgClassShow
    Bounded, (forall x. MsgClassShow -> Rep MsgClassShow x)
    -> (forall x. Rep MsgClassShow x -> MsgClassShow)
    -> Generic MsgClassShow
    forall x. Rep MsgClassShow x -> MsgClassShow
    forall x. MsgClassShow -> Rep MsgClassShow x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. MsgClassShow -> Rep MsgClassShow x
    from :: forall x. MsgClassShow -> Rep MsgClassShow x
    $cto :: forall x. Rep MsgClassShow x -> MsgClassShow
    to :: forall x. Rep MsgClassShow x -> MsgClassShow
    Generic)

    instance Binary MsgClassShow

    data MsgClassSave =
        MsgInnerWorkSpam
      | MsgNumericReport
      deriving (Int -> MsgClassSave -> ShowS
    [MsgClassSave] -> ShowS
    MsgClassSave -> [Char]
    (Int -> MsgClassSave -> ShowS)
    -> (MsgClassSave -> [Char])
    -> ([MsgClassSave] -> ShowS)
    -> Show MsgClassSave
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MsgClassSave -> ShowS
    showsPrec :: Int -> MsgClassSave -> ShowS
    $cshow :: MsgClassSave -> [Char]
    show :: MsgClassSave -> [Char]
    $cshowList :: [MsgClassSave] -> ShowS
    showList :: [MsgClassSave] -> ShowS
    Show, MsgClassSave -> MsgClassSave -> Bool
    (MsgClassSave -> MsgClassSave -> Bool)
    -> (MsgClassSave -> MsgClassSave -> Bool) -> Eq MsgClassSave
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MsgClassSave -> MsgClassSave -> Bool
    == :: MsgClassSave -> MsgClassSave -> Bool
    $c/= :: MsgClassSave -> MsgClassSave -> Bool
    /= :: MsgClassSave -> MsgClassSave -> Bool
    Eq, Eq MsgClassSave
    Eq MsgClassSave =>
    (MsgClassSave -> MsgClassSave -> Ordering)
    -> (MsgClassSave -> MsgClassSave -> Bool)
    -> (MsgClassSave -> MsgClassSave -> Bool)
    -> (MsgClassSave -> MsgClassSave -> Bool)
    -> (MsgClassSave -> MsgClassSave -> Bool)
    -> (MsgClassSave -> MsgClassSave -> MsgClassSave)
    -> (MsgClassSave -> MsgClassSave -> MsgClassSave)
    -> Ord MsgClassSave
    MsgClassSave -> MsgClassSave -> Bool
    MsgClassSave -> MsgClassSave -> Ordering
    MsgClassSave -> MsgClassSave -> MsgClassSave
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: MsgClassSave -> MsgClassSave -> Ordering
    compare :: MsgClassSave -> MsgClassSave -> Ordering
    $c< :: MsgClassSave -> MsgClassSave -> Bool
    < :: MsgClassSave -> MsgClassSave -> Bool
    $c<= :: MsgClassSave -> MsgClassSave -> Bool
    <= :: MsgClassSave -> MsgClassSave -> Bool
    $c> :: MsgClassSave -> MsgClassSave -> Bool
    > :: MsgClassSave -> MsgClassSave -> Bool
    $c>= :: MsgClassSave -> MsgClassSave -> Bool
    >= :: MsgClassSave -> MsgClassSave -> Bool
    $cmax :: MsgClassSave -> MsgClassSave -> MsgClassSave
    max :: MsgClassSave -> MsgClassSave -> MsgClassSave
    $cmin :: MsgClassSave -> MsgClassSave -> MsgClassSave
    min :: MsgClassSave -> MsgClassSave -> MsgClassSave
    Ord, Int -> MsgClassSave
    MsgClassSave -> Int
    MsgClassSave -> [MsgClassSave]
    MsgClassSave -> MsgClassSave
    MsgClassSave -> MsgClassSave -> [MsgClassSave]
    MsgClassSave -> MsgClassSave -> MsgClassSave -> [MsgClassSave]
    (MsgClassSave -> MsgClassSave)
    -> (MsgClassSave -> MsgClassSave)
    -> (Int -> MsgClassSave)
    -> (MsgClassSave -> Int)
    -> (MsgClassSave -> [MsgClassSave])
    -> (MsgClassSave -> MsgClassSave -> [MsgClassSave])
    -> (MsgClassSave -> MsgClassSave -> [MsgClassSave])
    -> (MsgClassSave -> MsgClassSave -> MsgClassSave -> [MsgClassSave])
    -> Enum MsgClassSave
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: MsgClassSave -> MsgClassSave
    succ :: MsgClassSave -> MsgClassSave
    $cpred :: MsgClassSave -> MsgClassSave
    pred :: MsgClassSave -> MsgClassSave
    $ctoEnum :: Int -> MsgClassSave
    toEnum :: Int -> MsgClassSave
    $cfromEnum :: MsgClassSave -> Int
    fromEnum :: MsgClassSave -> Int
    $cenumFrom :: MsgClassSave -> [MsgClassSave]
    enumFrom :: MsgClassSave -> [MsgClassSave]
    $cenumFromThen :: MsgClassSave -> MsgClassSave -> [MsgClassSave]
    enumFromThen :: MsgClassSave -> MsgClassSave -> [MsgClassSave]
    $cenumFromTo :: MsgClassSave -> MsgClassSave -> [MsgClassSave]
    enumFromTo :: MsgClassSave -> MsgClassSave -> [MsgClassSave]
    $cenumFromThenTo :: MsgClassSave -> MsgClassSave -> MsgClassSave -> [MsgClassSave]
    enumFromThenTo :: MsgClassSave -> MsgClassSave -> MsgClassSave -> [MsgClassSave]
    Enum, MsgClassSave
    MsgClassSave -> MsgClassSave -> Bounded MsgClassSave
    forall a. a -> a -> Bounded a
    $cminBound :: MsgClassSave
    minBound :: MsgClassSave
    $cmaxBound :: MsgClassSave
    maxBound :: MsgClassSave
    Bounded, (forall x. MsgClassSave -> Rep MsgClassSave x)
    -> (forall x. Rep MsgClassSave x -> MsgClassSave)
    -> Generic MsgClassSave
    forall x. Rep MsgClassSave x -> MsgClassSave
    forall x. MsgClassSave -> Rep MsgClassSave x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. MsgClassSave -> Rep MsgClassSave x
    from :: forall x. MsgClassSave -> Rep MsgClassSave x
    $cto :: forall x. Rep MsgClassSave x -> MsgClassSave
    to :: forall x. Rep MsgClassSave x -> MsgClassSave
    Generic)

    instance Binary MsgClassSave

    data MsgClassIgnore =
        MsgMacroOperation
      | MsgRunStopReason
      | MsgStopPlayback
      deriving (Int -> MsgClassIgnore -> ShowS
    [MsgClassIgnore] -> ShowS
    MsgClassIgnore -> [Char]
    (Int -> MsgClassIgnore -> ShowS)
    -> (MsgClassIgnore -> [Char])
    -> ([MsgClassIgnore] -> ShowS)
    -> Show MsgClassIgnore
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MsgClassIgnore -> ShowS
    showsPrec :: Int -> MsgClassIgnore -> ShowS
    $cshow :: MsgClassIgnore -> [Char]
    show :: MsgClassIgnore -> [Char]
    $cshowList :: [MsgClassIgnore] -> ShowS
    showList :: [MsgClassIgnore] -> ShowS
    Show, MsgClassIgnore -> MsgClassIgnore -> Bool
    (MsgClassIgnore -> MsgClassIgnore -> Bool)
    -> (MsgClassIgnore -> MsgClassIgnore -> Bool) -> Eq MsgClassIgnore
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MsgClassIgnore -> MsgClassIgnore -> Bool
    == :: MsgClassIgnore -> MsgClassIgnore -> Bool
    $c/= :: MsgClassIgnore -> MsgClassIgnore -> Bool
    /= :: MsgClassIgnore -> MsgClassIgnore -> Bool
    Eq, Eq MsgClassIgnore
    Eq MsgClassIgnore =>
    (MsgClassIgnore -> MsgClassIgnore -> Ordering)
    -> (MsgClassIgnore -> MsgClassIgnore -> Bool)
    -> (MsgClassIgnore -> MsgClassIgnore -> Bool)
    -> (MsgClassIgnore -> MsgClassIgnore -> Bool)
    -> (MsgClassIgnore -> MsgClassIgnore -> Bool)
    -> (MsgClassIgnore -> MsgClassIgnore -> MsgClassIgnore)
    -> (MsgClassIgnore -> MsgClassIgnore -> MsgClassIgnore)
    -> Ord MsgClassIgnore
    MsgClassIgnore -> MsgClassIgnore -> Bool
    MsgClassIgnore -> MsgClassIgnore -> Ordering
    MsgClassIgnore -> MsgClassIgnore -> MsgClassIgnore
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: MsgClassIgnore -> MsgClassIgnore -> Ordering
    compare :: MsgClassIgnore -> MsgClassIgnore -> Ordering
    $c< :: MsgClassIgnore -> MsgClassIgnore -> Bool
    < :: MsgClassIgnore -> MsgClassIgnore -> Bool
    $c<= :: MsgClassIgnore -> MsgClassIgnore -> Bool
    <= :: MsgClassIgnore -> MsgClassIgnore -> Bool
    $c> :: MsgClassIgnore -> MsgClassIgnore -> Bool
    > :: MsgClassIgnore -> MsgClassIgnore -> Bool
    $c>= :: MsgClassIgnore -> MsgClassIgnore -> Bool
    >= :: MsgClassIgnore -> MsgClassIgnore -> Bool
    $cmax :: MsgClassIgnore -> MsgClassIgnore -> MsgClassIgnore
    max :: MsgClassIgnore -> MsgClassIgnore -> MsgClassIgnore
    $cmin :: MsgClassIgnore -> MsgClassIgnore -> MsgClassIgnore
    min :: MsgClassIgnore -> MsgClassIgnore -> MsgClassIgnore
    Ord, Int -> MsgClassIgnore
    MsgClassIgnore -> Int
    MsgClassIgnore -> [MsgClassIgnore]
    MsgClassIgnore -> MsgClassIgnore
    MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore]
    MsgClassIgnore
    -> MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore]
    (MsgClassIgnore -> MsgClassIgnore)
    -> (MsgClassIgnore -> MsgClassIgnore)
    -> (Int -> MsgClassIgnore)
    -> (MsgClassIgnore -> Int)
    -> (MsgClassIgnore -> [MsgClassIgnore])
    -> (MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore])
    -> (MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore])
    -> (MsgClassIgnore
        -> MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore])
    -> Enum MsgClassIgnore
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: MsgClassIgnore -> MsgClassIgnore
    succ :: MsgClassIgnore -> MsgClassIgnore
    $cpred :: MsgClassIgnore -> MsgClassIgnore
    pred :: MsgClassIgnore -> MsgClassIgnore
    $ctoEnum :: Int -> MsgClassIgnore
    toEnum :: Int -> MsgClassIgnore
    $cfromEnum :: MsgClassIgnore -> Int
    fromEnum :: MsgClassIgnore -> Int
    $cenumFrom :: MsgClassIgnore -> [MsgClassIgnore]
    enumFrom :: MsgClassIgnore -> [MsgClassIgnore]
    $cenumFromThen :: MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore]
    enumFromThen :: MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore]
    $cenumFromTo :: MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore]
    enumFromTo :: MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore]
    $cenumFromThenTo :: MsgClassIgnore
    -> MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore]
    enumFromThenTo :: MsgClassIgnore
    -> MsgClassIgnore -> MsgClassIgnore -> [MsgClassIgnore]
    Enum, MsgClassIgnore
    MsgClassIgnore -> MsgClassIgnore -> Bounded MsgClassIgnore
    forall a. a -> a -> Bounded a
    $cminBound :: MsgClassIgnore
    minBound :: MsgClassIgnore
    $cmaxBound :: MsgClassIgnore
    maxBound :: MsgClassIgnore
    Bounded, (forall x. MsgClassIgnore -> Rep MsgClassIgnore x)
    -> (forall x. Rep MsgClassIgnore x -> MsgClassIgnore)
    -> Generic MsgClassIgnore
    forall x. Rep MsgClassIgnore x -> MsgClassIgnore
    forall x. MsgClassIgnore -> Rep MsgClassIgnore x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. MsgClassIgnore -> Rep MsgClassIgnore x
    from :: forall x. MsgClassIgnore -> Rep MsgClassIgnore x
    $cto :: forall x. Rep MsgClassIgnore x -> MsgClassIgnore
    to :: forall x. Rep MsgClassIgnore x -> MsgClassIgnore
    Generic)

    instance Binary MsgClassIgnore

    data MsgClassDistinct =
        MsgSpottedItem
      | MsgStatusSleep
      | MsgStatusGoodUs
      | MsgStatusBadUs
      | MsgStatusOthers
      | MsgStatusBenign
      | MsgStatusWarning
      | MsgStatusLongerUs
      | MsgStatusLongThem
      deriving (Int -> MsgClassDistinct -> ShowS
    [MsgClassDistinct] -> ShowS
    MsgClassDistinct -> [Char]
    (Int -> MsgClassDistinct -> ShowS)
    -> (MsgClassDistinct -> [Char])
    -> ([MsgClassDistinct] -> ShowS)
    -> Show MsgClassDistinct
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MsgClassDistinct -> ShowS
    showsPrec :: Int -> MsgClassDistinct -> ShowS
    $cshow :: MsgClassDistinct -> [Char]
    show :: MsgClassDistinct -> [Char]
    $cshowList :: [MsgClassDistinct] -> ShowS
    showList :: [MsgClassDistinct] -> ShowS
    Show, MsgClassDistinct -> MsgClassDistinct -> Bool
    (MsgClassDistinct -> MsgClassDistinct -> Bool)
    -> (MsgClassDistinct -> MsgClassDistinct -> Bool)
    -> Eq MsgClassDistinct
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MsgClassDistinct -> MsgClassDistinct -> Bool
    == :: MsgClassDistinct -> MsgClassDistinct -> Bool
    $c/= :: MsgClassDistinct -> MsgClassDistinct -> Bool
    /= :: MsgClassDistinct -> MsgClassDistinct -> Bool
    Eq, Eq MsgClassDistinct
    Eq MsgClassDistinct =>
    (MsgClassDistinct -> MsgClassDistinct -> Ordering)
    -> (MsgClassDistinct -> MsgClassDistinct -> Bool)
    -> (MsgClassDistinct -> MsgClassDistinct -> Bool)
    -> (MsgClassDistinct -> MsgClassDistinct -> Bool)
    -> (MsgClassDistinct -> MsgClassDistinct -> Bool)
    -> (MsgClassDistinct -> MsgClassDistinct -> MsgClassDistinct)
    -> (MsgClassDistinct -> MsgClassDistinct -> MsgClassDistinct)
    -> Ord MsgClassDistinct
    MsgClassDistinct -> MsgClassDistinct -> Bool
    MsgClassDistinct -> MsgClassDistinct -> Ordering
    MsgClassDistinct -> MsgClassDistinct -> MsgClassDistinct
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: MsgClassDistinct -> MsgClassDistinct -> Ordering
    compare :: MsgClassDistinct -> MsgClassDistinct -> Ordering
    $c< :: MsgClassDistinct -> MsgClassDistinct -> Bool
    < :: MsgClassDistinct -> MsgClassDistinct -> Bool
    $c<= :: MsgClassDistinct -> MsgClassDistinct -> Bool
    <= :: MsgClassDistinct -> MsgClassDistinct -> Bool
    $c> :: MsgClassDistinct -> MsgClassDistinct -> Bool
    > :: MsgClassDistinct -> MsgClassDistinct -> Bool
    $c>= :: MsgClassDistinct -> MsgClassDistinct -> Bool
    >= :: MsgClassDistinct -> MsgClassDistinct -> Bool
    $cmax :: MsgClassDistinct -> MsgClassDistinct -> MsgClassDistinct
    max :: MsgClassDistinct -> MsgClassDistinct -> MsgClassDistinct
    $cmin :: MsgClassDistinct -> MsgClassDistinct -> MsgClassDistinct
    min :: MsgClassDistinct -> MsgClassDistinct -> MsgClassDistinct
    Ord, Int -> MsgClassDistinct
    MsgClassDistinct -> Int
    MsgClassDistinct -> [MsgClassDistinct]
    MsgClassDistinct -> MsgClassDistinct
    MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct]
    MsgClassDistinct
    -> MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct]
    (MsgClassDistinct -> MsgClassDistinct)
    -> (MsgClassDistinct -> MsgClassDistinct)
    -> (Int -> MsgClassDistinct)
    -> (MsgClassDistinct -> Int)
    -> (MsgClassDistinct -> [MsgClassDistinct])
    -> (MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct])
    -> (MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct])
    -> (MsgClassDistinct
        -> MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct])
    -> Enum MsgClassDistinct
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: MsgClassDistinct -> MsgClassDistinct
    succ :: MsgClassDistinct -> MsgClassDistinct
    $cpred :: MsgClassDistinct -> MsgClassDistinct
    pred :: MsgClassDistinct -> MsgClassDistinct
    $ctoEnum :: Int -> MsgClassDistinct
    toEnum :: Int -> MsgClassDistinct
    $cfromEnum :: MsgClassDistinct -> Int
    fromEnum :: MsgClassDistinct -> Int
    $cenumFrom :: MsgClassDistinct -> [MsgClassDistinct]
    enumFrom :: MsgClassDistinct -> [MsgClassDistinct]
    $cenumFromThen :: MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct]
    enumFromThen :: MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct]
    $cenumFromTo :: MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct]
    enumFromTo :: MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct]
    $cenumFromThenTo :: MsgClassDistinct
    -> MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct]
    enumFromThenTo :: MsgClassDistinct
    -> MsgClassDistinct -> MsgClassDistinct -> [MsgClassDistinct]
    Enum, MsgClassDistinct
    MsgClassDistinct -> MsgClassDistinct -> Bounded MsgClassDistinct
    forall a. a -> a -> Bounded a
    $cminBound :: MsgClassDistinct
    minBound :: MsgClassDistinct
    $cmaxBound :: MsgClassDistinct
    maxBound :: MsgClassDistinct
    Bounded, (forall x. MsgClassDistinct -> Rep MsgClassDistinct x)
    -> (forall x. Rep MsgClassDistinct x -> MsgClassDistinct)
    -> Generic MsgClassDistinct
    forall x. Rep MsgClassDistinct x -> MsgClassDistinct
    forall x. MsgClassDistinct -> Rep MsgClassDistinct x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. MsgClassDistinct -> Rep MsgClassDistinct x
    from :: forall x. MsgClassDistinct -> Rep MsgClassDistinct x
    $cto :: forall x. Rep MsgClassDistinct x -> MsgClassDistinct
    to :: forall x. Rep MsgClassDistinct x -> MsgClassDistinct
    Generic)

    instance Binary MsgClassDistinct

    interruptsRunning :: MsgClass -> Bool
    interruptsRunning :: MsgClass -> Bool
    interruptsRunning = \case
      MsgClassShowAndSave MsgClassShowAndSave
    x -> case MsgClassShowAndSave
    x of
        MsgClassShowAndSave
    MsgBookKeeping -> Bool
    False
        MsgClassShowAndSave
    MsgStatusStopThem -> Bool
    False
        MsgClassShowAndSave
    MsgItemMovement -> Bool
    False
        MsgClassShowAndSave
    MsgActionMinor -> Bool
    False
        MsgClassShowAndSave
    MsgEffectMinor -> Bool
    False
        MsgClassShowAndSave
    MsgMiscellanous -> Bool
    False  -- taunts are colourful, but spammy
        MsgClassShowAndSave
    MsgHeardOutside -> Bool
    False  -- cause must be 'profound', but even taunts are
        MsgClassShowAndSave
    MsgHeardFaraway -> Bool
    False
        -- MsgHeardNearby interrupts, even if running started while hearing close
        MsgClassShowAndSave
    MsgRangedOthers -> Bool
    False
        MsgClassShowAndSave
    MsgNeutralEvent -> Bool
    False
        MsgClassShowAndSave
    MsgAtFeetMinor -> Bool
    False
        MsgClassShowAndSave
    _ -> Bool
    True
      MsgClassShow MsgClassShow
    x -> case MsgClassShow
    x of
        MsgClassShow
    MsgPromptGeneric -> Bool
    False
        MsgClassShow
    MsgPromptFocus -> Bool
    False
        MsgClassShow
    MsgPromptMention -> Bool
    False
        MsgClassShow
    MsgPromptModify -> Bool
    False
        MsgClassShow
    MsgPromptActors -> Bool
    False
        MsgClassShow
    MsgPromptItems -> Bool
    False
        MsgClassShow
    MsgPromptAction -> Bool
    False
        MsgClassShow
    MsgActionAlert -> Bool
    True  -- action alerts or questions cause alarm
        MsgClassShow
    MsgSpottedThreat -> Bool
    True
      MsgClassSave MsgClassSave
    x -> case MsgClassSave
    x of
        MsgClassSave
    MsgInnerWorkSpam -> Bool
    False
        MsgClassSave
    MsgNumericReport -> Bool
    False
      MsgClassIgnore MsgClassIgnore
    x -> case MsgClassIgnore
    x of
        MsgClassIgnore
    MsgMacroOperation -> Bool
    False
        MsgClassIgnore
    MsgRunStopReason -> Bool
    True
        MsgClassIgnore
    MsgStopPlayback -> Bool
    True
      MsgClassDistinct MsgClassDistinct
    x -> case MsgClassDistinct
    x of
        MsgClassDistinct
    MsgSpottedItem -> Bool
    False
        MsgClassDistinct
    MsgStatusLongThem -> Bool
    False
        MsgClassDistinct
    MsgStatusOthers -> Bool
    False
        MsgClassDistinct
    MsgStatusBenign -> Bool
    False
        MsgClassDistinct
    MsgStatusWarning -> Bool
    False
        MsgClassDistinct
    _ -> Bool
    True

    disturbsResting :: MsgClass -> Bool
    disturbsResting :: MsgClass -> Bool
    disturbsResting = \case
      MsgClassShowAndSave MsgClassShowAndSave
    x -> case MsgClassShowAndSave
    x of
        MsgClassShowAndSave
    MsgPointmanSwap -> Bool
    False  -- handled separately
        MsgClassShowAndSave
    MsgItemDiscovery -> Bool
    False  -- medium importance
        MsgClassShowAndSave
    MsgHeardNearby -> Bool
    False  -- handled separately; no disturbance if old
        MsgClassShowAndSave
    _ -> MsgClass -> Bool
    interruptsRunning (MsgClass -> Bool) -> MsgClass -> Bool
    forall a b. (a -> b) -> a -> b
    $ MsgClassShowAndSave -> MsgClass
    MsgClassShowAndSave MsgClassShowAndSave
    x
      MsgClass
    msgClass -> MsgClass -> Bool
    interruptsRunning MsgClass
    msgClass

    scrapsRepeats :: MsgClass -> Bool
    scrapsRepeats :: MsgClass -> Bool
    scrapsRepeats = \case
      MsgClassShowAndSave MsgClassShowAndSave
    x -> case MsgClassShowAndSave
    x of
        MsgClassShowAndSave
    MsgBookKeeping -> Bool
    False  -- too important to scrap
        MsgClassShowAndSave
    MsgDeathDeafeat -> Bool
    False
        MsgClassShowAndSave
    MsgRiskOfDeath -> Bool
    False
        MsgClassShowAndSave
    MsgFinalOutcome -> Bool
    False
        MsgClassShowAndSave
    _ -> Bool
    True
      MsgClassShow MsgClassShow
    x -> case MsgClassShow
    x of
        MsgClassShow
    MsgPromptGeneric -> Bool
    False
        MsgClassShow
    MsgPromptFocus -> Bool
    False
        MsgClassShow
    MsgPromptMention -> Bool
    False
        MsgClassShow
    MsgPromptModify -> Bool
    False
        MsgClassShow
    MsgPromptActors -> Bool
    False
        MsgClassShow
    MsgPromptItems -> Bool
    False
        MsgClassShow
    MsgPromptAction -> Bool
    False
        MsgClassShow
    MsgActionAlert -> Bool
    False
        MsgClassShow
    MsgSpottedThreat -> Bool
    True
      MsgClassSave MsgClassSave
    x -> case MsgClassSave
    x of
        MsgClassSave
    MsgInnerWorkSpam -> Bool
    True
        MsgClassSave
    MsgNumericReport -> Bool
    True
      MsgClassIgnore MsgClassIgnore
    _ -> Bool
    False  -- ignored, so no need to scrap
      MsgClassDistinct MsgClassDistinct
    _x -> Bool
    True

    isTutorialHint :: MsgClass -> Bool
    isTutorialHint :: MsgClass -> Bool
    isTutorialHint = \case
      MsgClassShowAndSave MsgClassShowAndSave
    x -> case MsgClassShowAndSave
    x of  -- show and save: least surprise
        MsgClassShowAndSave
    MsgTutorialHint -> Bool
    True
        MsgClassShowAndSave
    _ -> Bool
    False
      MsgClassShow MsgClassShow
    _ -> Bool
    False
      MsgClassSave MsgClassSave
    _ -> Bool
    False
      MsgClassIgnore MsgClassIgnore
    _ -> Bool
    False
      MsgClassDistinct MsgClassDistinct
    _ -> Bool
    False

    -- Only initially @White@ colour in text (e.g., not highlighted @BrWhite@)
    -- gets replaced by the one indicated.
    msgColor :: MsgClass -> Color.Color
    msgColor :: MsgClass -> Color
    msgColor = \case
      MsgClassShowAndSave MsgClassShowAndSave
    x -> case MsgClassShowAndSave
    x of
        MsgClassShowAndSave
    MsgBookKeeping -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgStatusWakeup -> Color
    Color.cWakeUp
        MsgClassShowAndSave
    MsgStatusStopUs -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgStatusStopThem -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgItemCreation -> Color
    Color.cGreed
        MsgClassShowAndSave
    MsgItemRuination -> Color
    Color.cBoring  -- common, colourful components created
        MsgClassShowAndSave
    MsgDeathVictory -> Color
    Color.cVeryGoodEvent
        MsgClassShowAndSave
    MsgDeathDeafeat -> Color
    Color.cVeryBadEvent
        MsgClassShowAndSave
    MsgDeathBoring -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgRiskOfDeath -> Color
    Color.cGraveRisk
        MsgClassShowAndSave
    MsgPointmanSwap -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgFactionIntel -> Color
    Color.cMeta  -- good or bad
        MsgClassShowAndSave
    MsgFinalOutcome -> Color
    Color.cGameOver
        MsgClassShowAndSave
    MsgBackdropInfo -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgTerrainReveal -> Color
    Color.cIdentification
        MsgClassShowAndSave
    MsgItemDiscovery -> Color
    Color.cIdentification
        MsgClassShowAndSave
    MsgSpottedActor -> Color
    Color.cBoring  -- common; warning in @MsgSpottedThreat@
        MsgClassShowAndSave
    MsgItemMovement -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgActionMajor -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgActionMinor -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgEffectMajor -> Color
    Color.cRareNeutralEvent
        MsgClassShowAndSave
    MsgEffectMedium -> Color
    Color.cNeutralEvent
        MsgClassShowAndSave
    MsgEffectMinor -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgMiscellanous -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgHeardOutside -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgHeardNearby -> Color
    Color.cGraveRisk
        MsgClassShowAndSave
    MsgHeardFaraway -> Color
    Color.cRisk
        MsgClassShowAndSave
    MsgBackdropFocus -> Color
    Color.cVista
        MsgClassShowAndSave
    MsgActionWarning -> Color
    Color.cMeta
        MsgClassShowAndSave
    MsgRangedMightyWe -> Color
    Color.cGoodEvent
        MsgClassShowAndSave
    MsgRangedMightyUs -> Color
    Color.cVeryBadEvent
        MsgClassShowAndSave
    MsgRangedOthers -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgRangedNormalUs -> Color
    Color.cBadEvent
        MsgClassShowAndSave
    MsgGoodMiscEvent -> Color
    Color.cGoodEvent
        MsgClassShowAndSave
    MsgBadMiscEvent -> Color
    Color.cBadEvent
        MsgClassShowAndSave
    MsgNeutralEvent -> Color
    Color.cNeutralEvent
        MsgClassShowAndSave
    MsgSpecialEvent -> Color
    Color.cRareNeutralEvent
        MsgClassShowAndSave
    MsgMeleeMightyWe -> Color
    Color.cGoodEvent
        MsgClassShowAndSave
    MsgMeleeMightyUs -> Color
    Color.cVeryBadEvent
        MsgClassShowAndSave
    MsgMeleeComplexWe -> Color
    Color.cGoodEvent
        MsgClassShowAndSave
    MsgMeleeComplexUs -> Color
    Color.cBadEvent
        MsgClassShowAndSave
    MsgMeleeOthers -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgMeleeNormalUs -> Color
    Color.cBadEvent
        MsgClassShowAndSave
    MsgActionComplete -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgAtFeetMajor -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgAtFeetMinor -> Color
    Color.cBoring
        MsgClassShowAndSave
    MsgTutorialHint -> Color
    Color.cTutorialHint
      MsgClassShow MsgClassShow
    x -> case MsgClassShow
    x of
        MsgClassShow
    MsgPromptGeneric -> Color
    Color.cBoring
        MsgClassShow
    MsgPromptFocus -> Color
    Color.cVista
        MsgClassShow
    MsgPromptMention -> Color
    Color.cNeutralEvent
        MsgClassShow
    MsgPromptModify -> Color
    Color.cRareNeutralEvent
        MsgClassShow
    MsgPromptActors -> Color
    Color.cRisk
        MsgClassShow
    MsgPromptItems -> Color
    Color.cGreed
        MsgClassShow
    MsgPromptAction -> Color
    Color.cMeta
        MsgClassShow
    MsgActionAlert -> Color
    Color.cMeta
        MsgClassShow
    MsgSpottedThreat -> Color
    Color.cGraveRisk
      MsgClassSave MsgClassSave
    x -> case MsgClassSave
    x of
        MsgClassSave
    MsgInnerWorkSpam -> Color
    Color.cBoring
        MsgClassSave
    MsgNumericReport -> Color
    Color.cBoring
      MsgClassIgnore MsgClassIgnore
    x -> case MsgClassIgnore
    x of
        MsgClassIgnore
    MsgMacroOperation -> Color
    Color.cBoring
        MsgClassIgnore
    MsgRunStopReason -> Color
    Color.cBoring
        MsgClassIgnore
    MsgStopPlayback -> Color
    Color.cMeta
      MsgClassDistinct MsgClassDistinct
    x -> case MsgClassDistinct
    x of
        MsgClassDistinct
    MsgSpottedItem -> Color
    Color.cBoring
        MsgClassDistinct
    MsgStatusSleep -> Color
    Color.cSleep
        MsgClassDistinct
    MsgStatusGoodUs -> Color
    Color.cGoodEvent
        MsgClassDistinct
    MsgStatusBadUs -> Color
    Color.cBadEvent
        MsgClassDistinct
    MsgStatusOthers -> Color
    Color.cBoring
        MsgClassDistinct
    MsgStatusBenign -> Color
    Color.cBoring
        MsgClassDistinct
    MsgStatusWarning -> Color
    Color.cMeta
        MsgClassDistinct
    MsgStatusLongerUs -> Color
    Color.cBoring  -- not important enough
        MsgClassDistinct
    MsgStatusLongThem -> Color
    Color.cBoring  -- not important enough, no disturb even

    -- * Report

    data RepMsgNK = RepMsgNK {RepMsgNK -> Msg
    repMsg :: Msg, RepMsgNK -> Int
    _repShow :: Int, RepMsgNK -> Int
    _repSave :: Int}
      deriving (Int -> RepMsgNK -> ShowS
    [RepMsgNK] -> ShowS
    RepMsgNK -> [Char]
    (Int -> RepMsgNK -> ShowS)
    -> (RepMsgNK -> [Char]) -> ([RepMsgNK] -> ShowS) -> Show RepMsgNK
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> RepMsgNK -> ShowS
    showsPrec :: Int -> RepMsgNK -> ShowS
    $cshow :: RepMsgNK -> [Char]
    show :: RepMsgNK -> [Char]
    $cshowList :: [RepMsgNK] -> ShowS
    showList :: [RepMsgNK] -> ShowS
    Show, (forall x. RepMsgNK -> Rep RepMsgNK x)
    -> (forall x. Rep RepMsgNK x -> RepMsgNK) -> Generic RepMsgNK
    forall x. Rep RepMsgNK x -> RepMsgNK
    forall x. RepMsgNK -> Rep RepMsgNK x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. RepMsgNK -> Rep RepMsgNK x
    from :: forall x. RepMsgNK -> Rep RepMsgNK x
    $cto :: forall x. Rep RepMsgNK x -> RepMsgNK
    to :: forall x. Rep RepMsgNK x -> RepMsgNK
    Generic)

    instance Binary RepMsgNK

    -- | If only one of the message components is non-empty and non-whitespace,
    -- but its count is zero, the message is considered empty.
    nullRepMsgNK :: RepMsgNK -> Bool
    nullRepMsgNK :: RepMsgNK -> Bool
    nullRepMsgNK (RepMsgNK Msg{[AttrCharW32]
    MsgClass
    msgShow :: Msg -> [AttrCharW32]
    msgSave :: Msg -> [AttrCharW32]
    msgClass :: Msg -> MsgClass
    msgShow :: [AttrCharW32]
    msgSave :: [AttrCharW32]
    msgClass :: MsgClass
    ..} Int
    _ Int
    _) =
      (AttrCharW32 -> Bool) -> [AttrCharW32] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all (Char -> Bool
    Char.isSpace (Char -> Bool) -> (AttrCharW32 -> Char) -> AttrCharW32 -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . AttrCharW32 -> Char
    Color.charFromW32) [AttrCharW32]
    msgShow
      Bool -> Bool -> Bool
    && (AttrCharW32 -> Bool) -> [AttrCharW32] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all (Char -> Bool
    Char.isSpace (Char -> Bool) -> (AttrCharW32 -> Char) -> AttrCharW32 -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . AttrCharW32 -> Char
    Color.charFromW32) [AttrCharW32]
    msgSave

    -- | The set of messages, with repetitions, to show at the screen at once.
    newtype Report = Report [RepMsgNK]
      deriving (Int -> Report -> ShowS
    [Report] -> ShowS
    Report -> [Char]
    (Int -> Report -> ShowS)
    -> (Report -> [Char]) -> ([Report] -> ShowS) -> Show Report
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Report -> ShowS
    showsPrec :: Int -> Report -> ShowS
    $cshow :: Report -> [Char]
    show :: Report -> [Char]
    $cshowList :: [Report] -> ShowS
    showList :: [Report] -> ShowS
    Show, Get Report
    [Report] -> Put
    Report -> Put
    (Report -> Put) -> Get Report -> ([Report] -> Put) -> Binary Report
    forall t. (t -> Put) -> Get t -> ([t] -> Put) -> Binary t
    $cput :: Report -> Put
    put :: Report -> Put
    $cget :: Get Report
    get :: Get Report
    $cputList :: [Report] -> Put
    putList :: [Report] -> Put
    Binary)

    -- | Empty set of messages.
    emptyReport :: Report
    emptyReport :: Report
    emptyReport = Bool -> Report -> Report
    forall a. HasCallStack => Bool -> a -> a
    assert (let checkLen :: MsgClass -> Bool
    checkLen MsgClass
    msgClass =
                                let len :: Int
    len = [Char] -> Int
    forall a. [a] -> Int
    length (MsgClass -> [Char]
    showSimpleMsgClass MsgClass
    msgClass)
                                in Int
    len Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Int
    14 Bool -> Bool -> Bool
    && Int
    len Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Int
    17
                              l :: [MsgClass]
    l = (MsgClassShowAndSave -> MsgClass)
    -> [MsgClassShowAndSave] -> [MsgClass]
    forall a b. (a -> b) -> [a] -> [b]
    map MsgClassShowAndSave -> MsgClass
    MsgClassShowAndSave [MsgClassShowAndSave
    forall a. Bounded a => a
    minBound .. MsgClassShowAndSave
    forall a. Bounded a => a
    maxBound]
                                  [MsgClass] -> [MsgClass] -> [MsgClass]
    forall a. [a] -> [a] -> [a]
    ++ (MsgClassShow -> MsgClass) -> [MsgClassShow] -> [MsgClass]
    forall a b. (a -> b) -> [a] -> [b]
    map MsgClassShow -> MsgClass
    MsgClassShow [MsgClassShow
    forall a. Bounded a => a
    minBound .. MsgClassShow
    forall a. Bounded a => a
    maxBound]
                                  [MsgClass] -> [MsgClass] -> [MsgClass]
    forall a. [a] -> [a] -> [a]
    ++ (MsgClassSave -> MsgClass) -> [MsgClassSave] -> [MsgClass]
    forall a b. (a -> b) -> [a] -> [b]
    map MsgClassSave -> MsgClass
    MsgClassSave [MsgClassSave
    forall a. Bounded a => a
    minBound .. MsgClassSave
    forall a. Bounded a => a
    maxBound]
                                  [MsgClass] -> [MsgClass] -> [MsgClass]
    forall a. [a] -> [a] -> [a]
    ++ (MsgClassIgnore -> MsgClass) -> [MsgClassIgnore] -> [MsgClass]
    forall a b. (a -> b) -> [a] -> [b]
    map MsgClassIgnore -> MsgClass
    MsgClassIgnore [MsgClassIgnore
    forall a. Bounded a => a
    minBound .. MsgClassIgnore
    forall a. Bounded a => a
    maxBound]
                                  [MsgClass] -> [MsgClass] -> [MsgClass]
    forall a. [a] -> [a] -> [a]
    ++ (MsgClassDistinct -> MsgClass) -> [MsgClassDistinct] -> [MsgClass]
    forall a b. (a -> b) -> [a] -> [b]
    map MsgClassDistinct -> MsgClass
    MsgClassDistinct [MsgClassDistinct
    forall a. Bounded a => a
    minBound .. MsgClassDistinct
    forall a. Bounded a => a
    maxBound]
                          in (MsgClass -> Bool) -> [MsgClass] -> Bool
    forall v. Show v => (v -> Bool) -> [v] -> Bool
    allB MsgClass -> Bool
    checkLen [MsgClass]
    l)
                  (Report -> Report) -> Report -> Report
    forall a b. (a -> b) -> a -> b
    $ [RepMsgNK] -> Report
    Report []  -- as good place as any to verify display lengths

    -- | Test if the list of non-whitespace messages is empty.
    nullVisibleReport :: Report -> Bool
    nullVisibleReport :: Report -> Bool
    nullVisibleReport (Report [RepMsgNK]
    l) =
      (RepMsgNK -> Bool) -> [RepMsgNK] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all ((AttrCharW32 -> Bool) -> [AttrCharW32] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all (Char -> Bool
    Char.isSpace (Char -> Bool) -> (AttrCharW32 -> Char) -> AttrCharW32 -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . AttrCharW32 -> Char
    Color.charFromW32) ([AttrCharW32] -> Bool)
    -> (RepMsgNK -> [AttrCharW32]) -> RepMsgNK -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Msg -> [AttrCharW32]
    msgShow (Msg -> [AttrCharW32])
    -> (RepMsgNK -> Msg) -> RepMsgNK -> [AttrCharW32]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . RepMsgNK -> Msg
    repMsg) [RepMsgNK]
    l

    -- | Add a message to the start of report.
    consReport :: Msg -> Report -> Report
    consReport :: Msg -> Report -> Report
    consReport Msg
    msg (Report [RepMsgNK]
    r) = [RepMsgNK] -> Report
    Report ([RepMsgNK] -> Report) -> [RepMsgNK] -> Report
    forall a b. (a -> b) -> a -> b
    $ [RepMsgNK]
    r [RepMsgNK] -> [RepMsgNK] -> [RepMsgNK]
    forall a. [a] -> [a] -> [a]
    ++ [Msg -> Int -> Int -> RepMsgNK
    RepMsgNK Msg
    msg Int
    1 Int
    1]

    -- | Render a report as a (possibly very long) list of 'AttrString'.
    renderReport :: Bool -> Report -> [AttrString]
    renderReport :: Bool -> Report -> [[AttrCharW32]]
    renderReport Bool
    displaying (Report [RepMsgNK]
    r) =
      let rep :: [([AttrCharW32], Int)]
    rep = (RepMsgNK -> ([AttrCharW32], Int))
    -> [RepMsgNK] -> [([AttrCharW32], Int)]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(RepMsgNK Msg
    msg Int
    n Int
    k) -> if Bool
    displaying
                                            then (Msg -> [AttrCharW32]
    msgShow Msg
    msg, Int
    n)
                                            else (Msg -> [AttrCharW32]
    msgSave Msg
    msg, Int
    k)) [RepMsgNK]
    r
      in [[AttrCharW32]] -> [[AttrCharW32]]
    forall a. [a] -> [a]
    reverse ([[AttrCharW32]] -> [[AttrCharW32]])
    -> [[AttrCharW32]] -> [[AttrCharW32]]
    forall a b. (a -> b) -> a -> b
    $ (([AttrCharW32], Int) -> [AttrCharW32])
    -> [([AttrCharW32], Int)] -> [[AttrCharW32]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([AttrCharW32], Int) -> [AttrCharW32]
    renderRepetition [([AttrCharW32], Int)]
    rep

    renderRepetition :: (AttrString, Int) -> AttrString
    renderRepetition :: ([AttrCharW32], Int) -> [AttrCharW32]
    renderRepetition ([AttrCharW32]
    asRaw, Int
    n) =
      let as :: [AttrCharW32]
    as = (AttrCharW32 -> Bool) -> [AttrCharW32] -> [AttrCharW32]
    forall a. (a -> Bool) -> [a] -> [a]
    dropWhileEnd (Char -> Bool
    Char.isSpace (Char -> Bool) -> (AttrCharW32 -> Char) -> AttrCharW32 -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . AttrCharW32 -> Char
    Color.charFromW32) [AttrCharW32]
    asRaw
      in if Int
    n Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Int
    1 Bool -> Bool -> Bool
    || [AttrCharW32] -> Bool
    forall a. [a] -> Bool
    null [AttrCharW32]
    as
         then [AttrCharW32]
    as
         else [AttrCharW32]
    as [AttrCharW32] -> [AttrCharW32] -> [AttrCharW32]
    forall a. [a] -> [a] -> [a]
    ++ [Char] -> [AttrCharW32]
    stringToAS ([Char]
    "<x" [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Int -> [Char]
    forall a. Show a => a -> [Char]
    show Int
    n [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    ">")

    anyInReport :: (MsgClass -> Bool) -> Report -> Bool
    anyInReport :: (MsgClass -> Bool) -> Report -> Bool
    anyInReport MsgClass -> Bool
    f (Report [RepMsgNK]
    xns) = (RepMsgNK -> Bool) -> [RepMsgNK] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    any (MsgClass -> Bool
    f (MsgClass -> Bool) -> (RepMsgNK -> MsgClass) -> RepMsgNK -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Msg -> MsgClass
    msgClass (Msg -> MsgClass) -> (RepMsgNK -> Msg) -> RepMsgNK -> MsgClass
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . RepMsgNK -> Msg
    repMsg) [RepMsgNK]
    xns

    -- * History

    -- | The history of reports. This is a ring buffer of the given length
    -- containing old archived history and two most recent reports stored
    -- separately.
    data History = History
      { History -> Report
    newReport       :: Report
      , History -> Time
    newTime         :: Time
      , History -> Report
    oldReport       :: Report
      , History -> Time
    oldTime         :: Time
      , History -> RingBuffer UAttrString
    archivedHistory :: RB.RingBuffer UAttrString }
      deriving (Int -> History -> ShowS
    [History] -> ShowS
    History -> [Char]
    (Int -> History -> ShowS)
    -> (History -> [Char]) -> ([History] -> ShowS) -> Show History
    forall a.
    (Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> History -> ShowS
    showsPrec :: Int -> History -> ShowS
    $cshow :: History -> [Char]
    show :: History -> [Char]
    $cshowList :: [History] -> ShowS
    showList :: [History] -> ShowS
    Show, (forall x. History -> Rep History x)
    -> (forall x. Rep History x -> History) -> Generic History
    forall x. Rep History x -> History
    forall x. History -> Rep History x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. History -> Rep History x
    from :: forall x. History -> Rep History x
    $cto :: forall x. Rep History x -> History
    to :: forall x. Rep History x -> History
    Generic)

    instance Binary History

    -- | Empty history of the given maximal length.
    emptyHistory :: Int -> History
    emptyHistory :: Int -> History
    emptyHistory Int
    size =
      let ringBufferSize :: Int
    ringBufferSize = Int
    size Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - Int
    1  -- a report resides outside the buffer
      in Report
    -> Time -> Report -> Time -> RingBuffer UAttrString -> History
    History Report
    emptyReport Time
    timeZero Report
    emptyReport Time
    timeZero
                 (Int -> UAttrString -> RingBuffer UAttrString
    forall a. Int -> a -> RingBuffer a
    RB.empty Int
    ringBufferSize UAttrString
    forall a. Unbox a => Vector a
    U.empty)

    scrapRepetitionSingle :: (AttrString, Int)
                          -> [(AttrString, Int)]
                          -> [(AttrString, Int)]
                          -> (Bool, [(AttrString, Int)], [(AttrString, Int)])
    scrapRepetitionSingle :: ([AttrCharW32], Int)
    -> [([AttrCharW32], Int)]
    -> [([AttrCharW32], Int)]
    -> (Bool, [([AttrCharW32], Int)], [([AttrCharW32], Int)])
    scrapRepetitionSingle ([AttrCharW32]
    s1, Int
    n1) [([AttrCharW32], Int)]
    rest1 [([AttrCharW32], Int)]
    oldMsgs =
      let butLastEOLs :: [AttrCharW32] -> [AttrCharW32]
    butLastEOLs = (AttrCharW32 -> Bool) -> [AttrCharW32] -> [AttrCharW32]
    forall a. (a -> Bool) -> [a] -> [a]
    dropWhileEnd ((Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    '\n') (Char -> Bool) -> (AttrCharW32 -> Char) -> AttrCharW32 -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . AttrCharW32 -> Char
    Color.charFromW32)
          eqs1 :: ([AttrCharW32], Int) -> Bool
    eqs1 ([AttrCharW32]
    s2, Int
    _) = [AttrCharW32] -> [AttrCharW32]
    butLastEOLs [AttrCharW32]
    s1 [AttrCharW32] -> [AttrCharW32] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [AttrCharW32] -> [AttrCharW32]
    butLastEOLs [AttrCharW32]
    s2
      in case (([AttrCharW32], Int) -> Bool)
    -> [([AttrCharW32], Int)]
    -> ([([AttrCharW32], Int)], [([AttrCharW32], Int)])
    forall a. (a -> Bool) -> [a] -> ([a], [a])
    break ([AttrCharW32], Int) -> Bool
    eqs1 [([AttrCharW32], Int)]
    rest1 of
        ([([AttrCharW32], Int)]
    _, []) -> case (([AttrCharW32], Int) -> Bool)
    -> [([AttrCharW32], Int)]
    -> ([([AttrCharW32], Int)], [([AttrCharW32], Int)])
    forall a. (a -> Bool) -> [a] -> ([a], [a])
    break ([AttrCharW32], Int) -> Bool
    eqs1 [([AttrCharW32], Int)]
    oldMsgs of
          ([([AttrCharW32], Int)]
    noDup, ([AttrCharW32]
    _, Int
    n2) : [([AttrCharW32], Int)]
    rest2) ->
            -- We keep the occurence of the message in the new report only.
            let newReport :: [([AttrCharW32], Int)]
    newReport = ([AttrCharW32]
    s1, Int
    n1 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    n2) ([AttrCharW32], Int)
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)]
    forall a. a -> [a] -> [a]
    : [([AttrCharW32], Int)]
    rest1
                oldReport :: [([AttrCharW32], Int)]
    oldReport = [([AttrCharW32], Int)]
    noDup [([AttrCharW32], Int)]
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)]
    forall a. [a] -> [a] -> [a]
    ++ ([], Int
    0) ([AttrCharW32], Int)
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)]
    forall a. a -> [a] -> [a]
    : [([AttrCharW32], Int)]
    rest2
            in (Bool
    True, [([AttrCharW32], Int)]
    newReport, [([AttrCharW32], Int)]
    oldReport)
          ([([AttrCharW32], Int)], [([AttrCharW32], Int)])
    _ -> (Bool
    False, ([AttrCharW32]
    s1, Int
    n1) ([AttrCharW32], Int)
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)]
    forall a. a -> [a] -> [a]
    : [([AttrCharW32], Int)]
    rest1, [([AttrCharW32], Int)]
    oldMsgs)
        ([([AttrCharW32], Int)]
    noDup, ([AttrCharW32]
    s2, Int
    n2) : [([AttrCharW32], Int)]
    rest3) ->
          -- We keep the older (and so, oldest) occurence of the message,
          -- to avoid visual disruption by moving the message around.
          let newReport :: [([AttrCharW32], Int)]
    newReport = ([], Int
    0) ([AttrCharW32], Int)
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)]
    forall a. a -> [a] -> [a]
    : [([AttrCharW32], Int)]
    noDup [([AttrCharW32], Int)]
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)]
    forall a. [a] -> [a] -> [a]
    ++ ([AttrCharW32]
    s2, Int
    n1 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    n2) ([AttrCharW32], Int)
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)]
    forall a. a -> [a] -> [a]
    : [([AttrCharW32], Int)]
    rest3
              oldReport :: [([AttrCharW32], Int)]
    oldReport = [([AttrCharW32], Int)]
    oldMsgs
          in (Bool
    True, [([AttrCharW32], Int)]
    newReport, [([AttrCharW32], Int)]
    oldReport)

    scrapRepetition :: History -> Maybe History
    scrapRepetition :: History -> Maybe History
    scrapRepetition History{ newReport :: History -> Report
    newReport = Report [RepMsgNK]
    newMsgs
                           , oldReport :: History -> Report
    oldReport = Report [RepMsgNK]
    oldMsgs
                           , RingBuffer UAttrString
    Time
    newTime :: History -> Time
    oldTime :: History -> Time
    archivedHistory :: History -> RingBuffer UAttrString
    newTime :: Time
    oldTime :: Time
    archivedHistory :: RingBuffer UAttrString
    .. } =
      case [RepMsgNK]
    newMsgs of
        -- We take into account only first message of the new report,
        -- because others were deduplicated as they were added.
        -- We keep the message in the new report, because it should not
        -- vanish from the screen. In this way the message may be passed
        -- along many reports.
        RepMsgNK Msg
    msg1 Int
    n1 Int
    k1 : [RepMsgNK]
    rest1 ->
          let -- We ignore message classes and scrap even if same strings
              -- come from different classes. Otherwise user would be confused.
              makeShow :: [RepMsgNK] -> [([AttrCharW32], Int)]
    makeShow = (RepMsgNK -> ([AttrCharW32], Int))
    -> [RepMsgNK] -> [([AttrCharW32], Int)]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(RepMsgNK Msg
    msg Int
    n Int
    _) -> (Msg -> [AttrCharW32]
    msgShow Msg
    msg, Int
    n))
              makeSave :: [RepMsgNK] -> [([AttrCharW32], Int)]
    makeSave = (RepMsgNK -> ([AttrCharW32], Int))
    -> [RepMsgNK] -> [([AttrCharW32], Int)]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(RepMsgNK Msg
    msg Int
    _ Int
    k) -> (Msg -> [AttrCharW32]
    msgSave Msg
    msg, Int
    k))
              (Bool
    scrapShowNeeded, [([AttrCharW32], Int)]
    scrapShowNew, [([AttrCharW32], Int)]
    scrapShowOld) =
                ([AttrCharW32], Int)
    -> [([AttrCharW32], Int)]
    -> [([AttrCharW32], Int)]
    -> (Bool, [([AttrCharW32], Int)], [([AttrCharW32], Int)])
    scrapRepetitionSingle (Msg -> [AttrCharW32]
    msgShow Msg
    msg1, Int
    n1)
                                      ([RepMsgNK] -> [([AttrCharW32], Int)]
    makeShow [RepMsgNK]
    rest1)
                                      ([RepMsgNK] -> [([AttrCharW32], Int)]
    makeShow [RepMsgNK]
    oldMsgs)
              (Bool
    scrapSaveNeeded, [([AttrCharW32], Int)]
    scrapSaveNew, [([AttrCharW32], Int)]
    scrapSaveOld) =
                ([AttrCharW32], Int)
    -> [([AttrCharW32], Int)]
    -> [([AttrCharW32], Int)]
    -> (Bool, [([AttrCharW32], Int)], [([AttrCharW32], Int)])
    scrapRepetitionSingle (Msg -> [AttrCharW32]
    msgSave Msg
    msg1, Int
    k1)
                                      ([RepMsgNK] -> [([AttrCharW32], Int)]
    makeSave [RepMsgNK]
    rest1)
                                      ([RepMsgNK] -> [([AttrCharW32], Int)]
    makeSave [RepMsgNK]
    oldMsgs)
          in if Bool
    scrapShowNeeded Bool -> Bool -> Bool
    || Bool
    scrapSaveNeeded
             then let combineMsg :: Msg
    -> ([AttrCharW32], Int) -> ([AttrCharW32], Int) -> Maybe RepMsgNK
    combineMsg Msg
    _ ([], Int
    _) ([], Int
    _) = Maybe RepMsgNK
    forall a. Maybe a
    Nothing
                      combineMsg Msg
    msg ([AttrCharW32]
    s, Int
    n) ([AttrCharW32]
    t, Int
    k) = RepMsgNK -> Maybe RepMsgNK
    forall a. a -> Maybe a
    Just (RepMsgNK -> Maybe RepMsgNK) -> RepMsgNK -> Maybe RepMsgNK
    forall a b. (a -> b) -> a -> b
    $
                        Msg -> Int -> Int -> RepMsgNK
    RepMsgNK Msg
    msg{msgShow = s, msgSave = t} Int
    n Int
    k
                      zipMsg :: [RepMsgNK]
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)] -> Report
    zipMsg [RepMsgNK]
    l1 [([AttrCharW32], Int)]
    l2 [([AttrCharW32], Int)]
    l3 = [RepMsgNK] -> Report
    Report ([RepMsgNK] -> Report) -> [RepMsgNK] -> Report
    forall a b. (a -> b) -> a -> b
    $ [Maybe RepMsgNK] -> [RepMsgNK]
    forall a. [Maybe a] -> [a]
    catMaybes ([Maybe RepMsgNK] -> [RepMsgNK]) -> [Maybe RepMsgNK] -> [RepMsgNK]
    forall a b. (a -> b) -> a -> b
    $
                        (Msg
     -> ([AttrCharW32], Int) -> ([AttrCharW32], Int) -> Maybe RepMsgNK)
    -> [Msg]
    -> [([AttrCharW32], Int)]
    -> [([AttrCharW32], Int)]
    -> [Maybe RepMsgNK]
    forall a b c d. (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
    zipWith3 Msg
    -> ([AttrCharW32], Int) -> ([AttrCharW32], Int) -> Maybe RepMsgNK
    combineMsg ((RepMsgNK -> Msg) -> [RepMsgNK] -> [Msg]
    forall a b. (a -> b) -> [a] -> [b]
    map RepMsgNK -> Msg
    repMsg [RepMsgNK]
    l1) [([AttrCharW32], Int)]
    l2 [([AttrCharW32], Int)]
    l3
                      newReport :: Report
    newReport = [RepMsgNK]
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)] -> Report
    zipMsg [RepMsgNK]
    newMsgs [([AttrCharW32], Int)]
    scrapShowNew [([AttrCharW32], Int)]
    scrapSaveNew
                      oldReport :: Report
    oldReport = [RepMsgNK]
    -> [([AttrCharW32], Int)] -> [([AttrCharW32], Int)] -> Report
    zipMsg [RepMsgNK]
    oldMsgs [([AttrCharW32], Int)]
    scrapShowOld [([AttrCharW32], Int)]
    scrapSaveOld
                  in History -> Maybe History
    forall a. a -> Maybe a
    Just History{RingBuffer UAttrString
    Time
    Report
    newReport :: Report
    newTime :: Time
    oldReport :: Report
    oldTime :: Time
    archivedHistory :: RingBuffer UAttrString
    newTime :: Time
    oldTime :: Time
    archivedHistory :: RingBuffer UAttrString
    newReport :: Report
    oldReport :: Report
    ..}
             else Maybe History
    forall a. Maybe a
    Nothing
        [RepMsgNK]
    _ -> [Char] -> Maybe History
    forall a. HasCallStack => [Char] -> a
    error [Char]
    "scrapRepetition: empty new report for scrapping"

    -- | Add a message to the new report of history, eliminating a possible
    -- duplicate and noting its existence in the result.
    addToReport :: S.Set Msg -> Bool -> Bool -> History -> Msg -> Time
                -> (S.Set Msg, History, Bool)
    addToReport :: Set Msg
    -> Bool
    -> Bool
    -> History
    -> Msg
    -> Time
    -> (Set Msg, History, Bool)
    addToReport Set Msg
    usedHints Bool
    displayHints Bool
    inMelee
                oldHistory :: History
    oldHistory@History{newReport :: History -> Report
    newReport = Report [RepMsgNK]
    r, RingBuffer UAttrString
    Time
    Report
    newTime :: History -> Time
    oldReport :: History -> Report
    oldTime :: History -> Time
    archivedHistory :: History -> RingBuffer UAttrString
    newTime :: Time
    oldReport :: Report
    oldTime :: Time
    archivedHistory :: RingBuffer UAttrString
    ..} Msg
    msgRaw Time
    time =
      -- When each turn we lose HP, stuff that wouldn't interrupt
      -- running should go at most to message log, not onto the screen,
      -- unless it goes only onto screen, so the message would be lost.
      let isMsgClassShow :: MsgClass -> Bool
    isMsgClassShow = \case
            MsgClassShow{} -> Bool
    True
            MsgClass
    _ -> Bool
    False
          msg :: Msg
    msg = if Bool
    inMelee
                   Bool -> Bool -> Bool
    && Bool -> Bool
    not (MsgClass -> Bool
    interruptsRunning (Msg -> MsgClass
    msgClass Msg
    msgRaw))
                   Bool -> Bool -> Bool
    && Bool -> Bool
    not (MsgClass -> Bool
    isMsgClassShow (MsgClass -> Bool) -> MsgClass -> Bool
    forall a b. (a -> b) -> a -> b
    $ Msg -> MsgClass
    msgClass Msg
    msgRaw)
                then Msg
    msgRaw {msgShow = []}
                else Msg
    msgRaw
          repMsgNK :: RepMsgNK
    repMsgNK = Msg -> Int -> Int -> RepMsgNK
    RepMsgNK Msg
    msg Int
    1 Int
    1
          newH :: History
    newH = History { newReport :: Report
    newReport = [RepMsgNK] -> Report
    Report ([RepMsgNK] -> Report) -> [RepMsgNK] -> Report
    forall a b. (a -> b) -> a -> b
    $ RepMsgNK
    repMsgNK RepMsgNK -> [RepMsgNK] -> [RepMsgNK]
    forall a. a -> [a] -> [a]
    : [RepMsgNK]
    r
                         , newTime :: Time
    newTime = Time
    time
                         , RingBuffer UAttrString
    Time
    Report
    oldReport :: Report
    oldTime :: Time
    archivedHistory :: RingBuffer UAttrString
    oldReport :: Report
    oldTime :: Time
    archivedHistory :: RingBuffer UAttrString
    .. }
          msgIsHint :: Bool
    msgIsHint = MsgClass -> Bool
    isTutorialHint (Msg -> MsgClass
    msgClass Msg
    msg)
          msgUsedAsHint :: Bool
    msgUsedAsHint = Msg -> Set Msg -> Bool
    forall a. Ord a => a -> Set a -> Bool
    S.member Msg
    msg Set Msg
    usedHints
          newUsedHints :: Set Msg
    newUsedHints = if Bool
    msgIsHint Bool -> Bool -> Bool
    && Bool
    displayHints Bool -> Bool -> Bool
    && Bool -> Bool
    not Bool
    msgUsedAsHint
                         then Msg -> Set Msg -> Set Msg
    forall a. Ord a => a -> Set a -> Set a
    S.insert Msg
    msg Set Msg
    usedHints
                         else Set Msg
    usedHints
      in -- Tutorial hint shown only when tutorial enabled and hint not yet shown.
         if | Bool
    msgIsHint Bool -> Bool -> Bool
    && (Bool -> Bool
    not Bool
    displayHints Bool -> Bool -> Bool
    || Bool
    msgUsedAsHint) ->
              (Set Msg
    usedHints, History
    oldHistory, Bool
    False)
            | Bool -> Bool
    not (MsgClass -> Bool
    scrapsRepeats (MsgClass -> Bool) -> MsgClass -> Bool
    forall a b. (a -> b) -> a -> b
    $ Msg -> MsgClass
    msgClass Msg
    msg)
              Bool -> Bool -> Bool
    || RepMsgNK -> Bool
    nullRepMsgNK RepMsgNK
    repMsgNK ->
              -- Don't waste time on never shown messages.
              (Set Msg
    newUsedHints, History
    newH, Bool
    False)
            | Bool
    otherwise -> case History -> Maybe History
    scrapRepetition History
    newH of
                Just History
    scrappedH -> (Set Msg
    newUsedHints, History
    scrappedH, Bool
    True)
                Maybe History
    Nothing -> (Set Msg
    newUsedHints, History
    newH, Bool
    False)

    -- | Add a newline to end of the new report of history, unless empty.
    addEolToNewReport :: History -> History
    addEolToNewReport :: History -> History
    addEolToNewReport History
    hist =
      let addEolToReport :: Report -> Report
    addEolToReport (Report []) = [RepMsgNK] -> Report
    Report []
          addEolToReport (Report (RepMsgNK
    hd : [RepMsgNK]
    tl)) = [RepMsgNK] -> Report
    Report ([RepMsgNK] -> Report) -> [RepMsgNK] -> Report
    forall a b. (a -> b) -> a -> b
    $ RepMsgNK -> RepMsgNK
    addEolToRepMsgNK RepMsgNK
    hd RepMsgNK -> [RepMsgNK] -> [RepMsgNK]
    forall a. a -> [a] -> [a]
    : [RepMsgNK]
    tl
          addEolToRepMsgNK :: RepMsgNK -> RepMsgNK
    addEolToRepMsgNK RepMsgNK
    rm = RepMsgNK
    rm {repMsg = addEolToMsg $ repMsg rm}
          addEolToMsg :: Msg -> Msg
    addEolToMsg Msg
    msg = Msg
    msg { msgShow = addEolToAS $ msgShow msg
                                , msgSave = addEolToAS $ msgSave msg }
          addEolToAS :: [AttrCharW32] -> [AttrCharW32]
    addEolToAS [AttrCharW32]
    as = [AttrCharW32]
    as [AttrCharW32] -> [AttrCharW32] -> [AttrCharW32]
    forall a. [a] -> [a] -> [a]
    ++ [Char] -> [AttrCharW32]
    stringToAS [Char]
    "\n"
      in History
    hist {newReport = addEolToReport $ newReport hist}

    -- | Archive old report to history, filtering out messages with 0 duplicates
    -- and prompts. Set up new report with a new timestamp.
    archiveReport :: History -> History
    archiveReport :: History -> History
    archiveReport History{newReport :: History -> Report
    newReport=Report [RepMsgNK]
    newMsgs, RingBuffer UAttrString
    Time
    Report
    newTime :: History -> Time
    oldReport :: History -> Report
    oldTime :: History -> Time
    archivedHistory :: History -> RingBuffer UAttrString
    newTime :: Time
    oldReport :: Report
    oldTime :: Time
    archivedHistory :: RingBuffer UAttrString
    ..} =
      let newFiltered :: Report
    newFiltered@(Report [RepMsgNK]
    r) = [RepMsgNK] -> Report
    Report ([RepMsgNK] -> Report) -> [RepMsgNK] -> Report
    forall a b. (a -> b) -> a -> b
    $ (RepMsgNK -> Bool) -> [RepMsgNK] -> [RepMsgNK]
    forall a. (a -> Bool) -> [a] -> [a]
    filter (Bool -> Bool
    not (Bool -> Bool) -> (RepMsgNK -> Bool) -> RepMsgNK -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . RepMsgNK -> Bool
    nullRepMsgNK) [RepMsgNK]
    newMsgs
      in if [RepMsgNK] -> Bool
    forall a. [a] -> Bool
    null [RepMsgNK]
    r
         then -- Drop empty new report.
              Report
    -> Time -> Report -> Time -> RingBuffer UAttrString -> History
    History Report
    emptyReport Time
    timeZero Report
    oldReport Time
    oldTime RingBuffer UAttrString
    archivedHistory
         else let lU :: [UAttrString]
    lU = ([AttrCharW32] -> UAttrString) -> [[AttrCharW32]] -> [UAttrString]
    forall a b. (a -> b) -> [a] -> [b]
    map [AttrCharW32] -> UAttrString
    attrStringToU
                       ([[AttrCharW32]] -> [UAttrString])
    -> [[AttrCharW32]] -> [UAttrString]
    forall a b. (a -> b) -> a -> b
    $ Time -> Report -> [[AttrCharW32]]
    renderTimeReport Time
    oldTime Report
    oldReport
              in Report
    -> Time -> Report -> Time -> RingBuffer UAttrString -> History
    History Report
    emptyReport Time
    timeZero Report
    newFiltered Time
    newTime
                 (RingBuffer UAttrString -> History)
    -> RingBuffer UAttrString -> History
    forall a b. (a -> b) -> a -> b
    $ (RingBuffer UAttrString -> UAttrString -> RingBuffer UAttrString)
    -> RingBuffer UAttrString
    -> [UAttrString]
    -> RingBuffer UAttrString
    forall b a. (b -> a -> b) -> b -> [a] -> b
    forall (t :: * -> *) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl' (\ !RingBuffer UAttrString
    h !UAttrString
    v -> UAttrString -> RingBuffer UAttrString -> RingBuffer UAttrString
    forall a. a -> RingBuffer a -> RingBuffer a
    RB.cons UAttrString
    v RingBuffer UAttrString
    h) RingBuffer UAttrString
    archivedHistory [UAttrString]
    lU

    renderTimeReport :: Time -> Report -> [AttrString]
    renderTimeReport :: Time -> Report -> [[AttrCharW32]]
    renderTimeReport Time
    t rep :: Report
    rep@(Report [RepMsgNK]
    r) =
      let turns :: Int
    turns = Time
    t Time -> Time -> Int
    `timeFitUp` Time
    timeTurn
          repMsgs :: [[AttrCharW32]]
    repMsgs = Bool -> Report -> [[AttrCharW32]]
    renderReport Bool
    False Report
    rep
          mgsClasses :: [[Char]]
    mgsClasses = [[Char]] -> [[Char]]
    forall a. [a] -> [a]
    reverse ([[Char]] -> [[Char]]) -> [[Char]] -> [[Char]]
    forall a b. (a -> b) -> a -> b
    $ (RepMsgNK -> [Char]) -> [RepMsgNK] -> [[Char]]
    forall a b. (a -> b) -> [a] -> [b]
    map (MsgClass -> [Char]
    showSimpleMsgClass (MsgClass -> [Char])
    -> (RepMsgNK -> MsgClass) -> RepMsgNK -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Msg -> MsgClass
    msgClass (Msg -> MsgClass) -> (RepMsgNK -> Msg) -> RepMsgNK -> MsgClass
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . RepMsgNK -> Msg
    repMsg) [RepMsgNK]
    r
          turnsString :: [Char]
    turnsString = Int -> [Char]
    forall a. Show a => a -> [Char]
    show Int
    turns
          isSpace32 :: AttrCharW32 -> Bool
    isSpace32 = Char -> Bool
    Char.isSpace (Char -> Bool) -> (AttrCharW32 -> Char) -> AttrCharW32 -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . AttrCharW32 -> Char
    Color.charFromW32
          worthSaving :: [AttrCharW32] -> Bool
    worthSaving = Bool -> Bool
    not (Bool -> Bool) -> ([AttrCharW32] -> Bool) -> [AttrCharW32] -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (AttrCharW32 -> Bool) -> [AttrCharW32] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all AttrCharW32 -> Bool
    isSpace32
          renderClass :: ([AttrCharW32], [Char]) -> [AttrCharW32]
    renderClass ([AttrCharW32]
    as, [Char]
    msgClassString) =
            let lenUnderscore :: Int
    lenUnderscore = Int
    17 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - [Char] -> Int
    forall a. [a] -> Int
    length [Char]
    msgClassString
                                Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int -> Int -> Int
    forall a. Ord a => a -> a -> a
    max Int
    0 (Int
    3 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - [Char] -> Int
    forall a. [a] -> Int
    length [Char]
    turnsString)
            in [Char] -> [AttrCharW32]
    stringToAS ([Char]
    turnsString [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    ":")
               [AttrCharW32] -> [AttrCharW32] -> [AttrCharW32]
    forall a. [a] -> [a] -> [a]
    ++ (Char -> AttrCharW32) -> [Char] -> [AttrCharW32]
    forall a b. (a -> b) -> [a] -> [b]
    map (Color -> Char -> AttrCharW32
    Color.attrChar2ToW32 Color
    Color.BrBlack)
                      ([Char]
    "[" [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Int -> Char -> [Char]
    forall a. Int -> a -> [a]
    replicate Int
    lenUnderscore Char
    '_' [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    msgClassString [Char] -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "]")
               [AttrCharW32] -> [AttrCharW32] -> [AttrCharW32]
    forall a. [a] -> [a] -> [a]
    ++ [AttrCharW32
    Color.spaceAttrW32]
               [AttrCharW32] -> [AttrCharW32] -> [AttrCharW32]
    forall a. [a] -> [a] -> [a]
    ++ (AttrCharW32 -> Bool) -> [AttrCharW32] -> [AttrCharW32]
    forall a. (a -> Bool) -> [a] -> [a]
    dropWhile AttrCharW32 -> Bool
    isSpace32 [AttrCharW32]
    as
      in (([AttrCharW32], [Char]) -> [AttrCharW32])
    -> [([AttrCharW32], [Char])] -> [[AttrCharW32]]
    forall a b. (a -> b) -> [a] -> [b]
    map ([AttrCharW32], [Char]) -> [AttrCharW32]
    renderClass ([([AttrCharW32], [Char])] -> [[AttrCharW32]])
    -> [([AttrCharW32], [Char])] -> [[AttrCharW32]]
    forall a b. (a -> b) -> a -> b
    $ (([AttrCharW32], [Char]) -> Bool)
    -> [([AttrCharW32], [Char])] -> [([AttrCharW32], [Char])]
    forall a. (a -> Bool) -> [a] -> [a]
    filter ([AttrCharW32] -> Bool
    worthSaving ([AttrCharW32] -> Bool)
    -> (([AttrCharW32], [Char]) -> [AttrCharW32])
    -> ([AttrCharW32], [Char])
    -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([AttrCharW32], [Char]) -> [AttrCharW32]
    forall a b. (a, b) -> a
    fst) ([([AttrCharW32], [Char])] -> [([AttrCharW32], [Char])])
    -> [([AttrCharW32], [Char])] -> [([AttrCharW32], [Char])]
    forall a b. (a -> b) -> a -> b
    $ [[AttrCharW32]] -> [[Char]] -> [([AttrCharW32], [Char])]
    forall a b. [a] -> [b] -> [(a, b)]
    zip [[AttrCharW32]]
    repMsgs [[Char]]
    mgsClasses

    lengthHistory :: History -> Int
    lengthHistory :: History -> Int
    lengthHistory History{Report
    oldReport :: History -> Report
    oldReport :: Report
    oldReport, RingBuffer UAttrString
    archivedHistory :: History -> RingBuffer UAttrString
    archivedHistory :: RingBuffer UAttrString
    archivedHistory} =
      RingBuffer UAttrString -> Int
    forall a. RingBuffer a -> Int
    RB.length RingBuffer UAttrString
    archivedHistory
      Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + [[AttrCharW32]] -> Int
    forall a. [a] -> Int
    length (Time -> Report -> [[AttrCharW32]]
    renderTimeReport Time
    timeZero Report
    oldReport)
          -- matches @renderHistory@

    -- | Render history as many lines of text. New report is not rendered.
    -- It's expected to be empty when history is shown.
    renderHistory :: History -> [AttrString]
    renderHistory :: History -> [[AttrCharW32]]
    renderHistory History{RingBuffer UAttrString
    Time
    Report
    newReport :: History -> Report
    newTime :: History -> Time
    oldReport :: History -> Report
    oldTime :: History -> Time
    archivedHistory :: History -> RingBuffer UAttrString
    newReport :: Report
    newTime :: Time
    oldReport :: Report
    oldTime :: Time
    archivedHistory :: RingBuffer UAttrString
    ..} =
      (UAttrString -> [AttrCharW32]) -> [UAttrString] -> [[AttrCharW32]]
    forall a b. (a -> b) -> [a] -> [b]
    map UAttrString -> [AttrCharW32]
    uToAttrString (RingBuffer UAttrString -> [UAttrString]
    forall a. RingBuffer a -> [a]
    RB.toList RingBuffer UAttrString
    archivedHistory)
      [[AttrCharW32]] -> [[AttrCharW32]] -> [[AttrCharW32]]
    forall a. [a] -> [a] -> [a]
    ++ Time -> Report -> [[AttrCharW32]]
    renderTimeReport Time
    oldTime Report
    oldReport