Skip to content

[Repo Assist] Extract isFirstCharUppercase helper in CodePrinter#3282

Closed
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/improve-extract-isfirstcharuppercase-20260314-4686fd52a1b9db6d
Closed

[Repo Assist] Extract isFirstCharUppercase helper in CodePrinter#3282
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/improve-extract-isfirstcharuppercase-20260314-4686fd52a1b9db6d

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant. All changes were reviewed and tested before submission.

Summary

Both (|UppercaseType|LowercaseType|) and (|UppercaseExpr|LowercaseExpr|) in CodePrinter.fs contained identical inline logic to check whether a string's first character is uppercase:

let upperOrLower (v: string) =
    let isUpper = Seq.tryHead v |> Option.map Char.IsUpper |> Option.defaultValue false
    if isUpper then UppercaseX else LowercaseX

The two definitions were independent copies of the same logic. This PR extracts the shared predicate into a single module-level helper:

let isFirstCharUppercase (v: string) =
    Seq.tryHead v |> Option.map Char.IsUpper |> Option.defaultValue false

Both active patterns now delegate to this helper, reducing duplication.

Trade-offs

  • Positive: single definition for the "first char uppercase?" check, easier to update if the logic changes.
  • Neutral: because CodePrinter.fs is a module rec, order of definitions doesn't matter — no structural rearrangement was needed.
  • No behaviour change: the logic is identical; only the location of the definition has changed.

Test Status

Build: ✅ succeeded (Build succeeded.)
Tests: ✅ all 2737 passed, 7 skipped (Passed! - Failed: 0, Passed: 2737, Skipped: 7)

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

Both UppercaseType and UppercaseExpr active patterns contained
identical logic to check if a string's first character is uppercase.
Extract into a shared helper to eliminate the duplication.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nojaf
Copy link
Contributor

nojaf commented Mar 13, 2026

/repo-assist , nitpick but I'm more in a phase of life where I would write Seq.tryHead v |> Option.map Char.IsUpper |> Option.defaultValue false as match expression. Please update

@nojaf
Copy link
Contributor

nojaf commented Mar 16, 2026

/repo-assist try again

@github-actions
Copy link
Contributor Author

Pull request created: #3292

Generated by Repo Assist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant