tokenRender :: Token -> Text
tokenRender = \case
    TokenSquareBracket bs -> withBracketSide "[" "]" bs
    TokenParenthesis bs -> withBracketSide "(" ")" bs
    -- Double up every double quote, and surround the whole thing with double
    -- quotes.
    TokenString t -> quote (escapeQuotes t)
      where
        quote :: Text -> Text
        quote t' = Text.concat [Text.singleton '\"', t', Text.singleton '\"']
        escapeQuotes :: Text -> Text
        escapeQuotes = Text.intercalate "\"\"" . Text.splitOn "\""
    TokenNumber n -> show n
    TokenAddress a -> pretty a
    TokenPublicKey pk -> sformat fullPublicKeyF pk
    TokenStakeholderId sId -> sformat hashHexF sId
    TokenHash h -> sformat hashHexF (getAHash h)
    TokenBlockVersion v -> pretty v
    TokenSoftwareVersion v -> "~software~" <> pretty v
    TokenFilePath s -> pretty s
    TokenName ss -> pretty ss
    TokenKey ss -> pretty ss <> ":"
    TokenEquals -> "="
    TokenSemicolon -> ";"
    TokenUnknown (UnknownChar c) -> Text.singleton c
tokenRender :: Token -> Text
tokenRender = \case
    TokenSquareBracket bs -> withBracketSide "[" "]" bs
    TokenParenthesis bs -> withBracketSide "(" ")" bs
    -- Double up every double quote, and surround the whole thing with double
    -- quotes.
    TokenString t -> quote (escapeQuotes t)
      where
        quote :: Text -> Text
        quote t' = Text.concat [Text.singleton '\"', t', Text.singleton '\"']
        escapeQuotes :: Text -> Text
        escapeQuotes = Text.intercalate "\"\"" . Text.splitOn "\""
    TokenNumber n -> show n
    TokenAddress a -> pretty a
    TokenPublicKey pk -> sformat fullPublicKeyF pk
    TokenStakeholderId sId -> sformat hashHexF sId
    TokenHash h -> sformat hashHexF (getAHash h)
    TokenBlockVersion v -> pretty v
    TokenSoftwareVersion v -> "~software~" <> pretty v
    TokenFilePath s -> pretty s
    TokenName ss -> pretty ss
    TokenKey ss -> pretty ss <> ":"
    TokenEquals -> "="
    TokenSemicolon -> ";"
    TokenUnknown (UnknownChar c) -> Text.singleton c
tokenRender = \case
    TokenSquareBracket bs -> withBracketSide "[" "]" bs
    TokenParenthesis bs -> withBracketSide "(" ")" bs
    -- Double up every double quote, and surround the whole thing with double
    -- quotes.
    TokenString t -> quote (escapeQuotes t)
      where
        quote :: Text -> Text
        quote t' = Text.concat [Text.singleton '\"', t', Text.singleton '\"']
        escapeQuotes :: Text -> Text
        escapeQuotes = Text.intercalate "\"\"" . Text.splitOn "\""
    TokenNumber n -> show n
    TokenAddress a -> pretty a
    TokenPublicKey pk -> sformat fullPublicKeyF pk
    TokenStakeholderId sId -> sformat hashHexF sId
    TokenHash h -> sformat hashHexF (getAHash h)
    TokenBlockVersion v -> pretty v
    TokenSoftwareVersion v -> "~software~" <> pretty v
    TokenFilePath s -> pretty s
    TokenName ss -> pretty ss
    TokenKey ss -> pretty ss <> ":"
    TokenEquals -> "="
    TokenSemicolon -> ";"
    TokenUnknown (UnknownChar c) -> Text.singleton c