    -- | C99 backend specific versions of selected `Copilot.Core` datatypes.
    module Copilot.Compile.C99.Representation
        ( UniqueTrigger (..)
        , UniqueTriggerId
        , mkUniqueTriggers
        )
      where

    import Copilot.Core ( Trigger (..) )

    -- | Internal unique name for a trigger.
    type UniqueTriggerId = String

    -- | A `Copilot.Core.Trigger` with an unique name.
    data UniqueTrigger = UniqueTrigger UniqueTriggerId Trigger

    -- | Given a list of triggers, make their names unique.
    mkUniqueTriggers :: [Trigger] -> [UniqueTrigger]
    mkUniqueTriggers :: [Trigger] -> [UniqueTrigger]
    mkUniqueTriggers [Trigger]
    ts = (Trigger -> Integer -> UniqueTrigger)
    -> [Trigger] -> [Integer] -> [UniqueTrigger]
    forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
    zipWith Trigger -> Integer -> UniqueTrigger
    forall {a}. Show a => Trigger -> a -> UniqueTrigger
    mkUnique [Trigger]
    ts [Integer
    0..]
      where
        mkUnique :: Trigger -> a -> UniqueTrigger
    mkUnique t :: Trigger
    t@(Trigger Name
    name Expr Bool
    _ [UExpr]
    _) a
    n = Name -> Trigger -> UniqueTrigger
    UniqueTrigger (Name
    name Name -> Name -> Name
    forall a. [a] -> [a] -> [a]
    ++ Name
    "_" Name -> Name -> Name
    forall a. [a] -> [a] -> [a]
    ++ a -> Name
    forall a. Show a => a -> Name
    show a
    n) Trigger
    t