    -- | Naming of variables and functions in C.
    module Copilot.Compile.C99.Name
        ( argNames
        , argTempNames
        , exCpyName
        , generatorName
        , generatorOutputArgName
        , guardName
        , indexName
        , streamAccessorName
        , streamName
        )
      where

    -- External imports: Copilot
    import Copilot.Core (Id)

    -- | Turn a stream id into a suitable C variable name.
    streamName :: Id -> String
    streamName :: Int -> String
    streamName Int
    sId = String
    "s" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Int -> String
    forall a. Show a => a -> String
    show Int
    sId

    -- | Turn a stream id into the global varname for indices.
    indexName :: Id -> String
    indexName :: Int -> String
    indexName Int
    sId = Int -> String
    streamName Int
    sId String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "_idx"

    -- | Turn a stream id into the name of its accessor function
    streamAccessorName :: Id -> String
    streamAccessorName :: Int -> String
    streamAccessorName Int
    sId = Int -> String
    streamName Int
    sId String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "_get"

    -- | Add a postfix for copies of external variables the name.
    exCpyName :: String -> String
    exCpyName :: String -> String
    exCpyName String
    name = String
    name String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "_cpy"

    -- | Turn stream id into name of its generator function.
    generatorName :: Id -> String
    generatorName :: Int -> String
    generatorName Int
    sId = Int -> String
    streamName Int
    sId String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "_gen"

    -- | Turn stream id into name of its output argument array.
    generatorOutputArgName :: Id -> String
    generatorOutputArgName :: Int -> String
    generatorOutputArgName Int
    sId = Int -> String
    streamName Int
    sId String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "_output"

    -- | Turn the name of a trigger into a guard generator.
    guardName :: String -> String
    guardName :: String -> String
    guardName String
    name = String
    name String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "_guard"

    -- | Turn a trigger name into a trigger argument name.
    argName :: String -> Int -> String
    argName :: String -> Int -> String
    argName String
    name Int
    n = String
    name String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "_arg" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Int -> String
    forall a. Show a => a -> String
    show Int
    n

    -- | Turn a handler function name into a name for a temporary variable for a
    -- handler argument.
    argTempName :: String -> Int -> String
    argTempName :: String -> Int -> String
    argTempName String
    name Int
    n = String
    name String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    "_arg_temp" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Int -> String
    forall a. Show a => a -> String
    show Int
    n

    -- | Enumerate all argument names based on trigger name.
    argNames :: String -> [String]
    argNames :: String -> [String]
    argNames String
    base = (Int -> String) -> [Int] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> Int -> String
    argName String
    base) [Int
    0..]

    -- | Enumerate all temporary variable names based on handler function name.
    argTempNames :: String -> [String]
    argTempNames :: String -> [String]
    argTempNames String
    base = (Int -> String) -> [Int] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> Int -> String
    argTempName String
    base) [Int
    0..]