fsprojects / fsprojects/FSharpPlus
Add more string functions - StringBuilder extension
Nobody has claimed this yet.
- Dominant language
- F#
- Stars
- 941
- Forks
- 106
- PR merge metrics
- No merged PRs in 30d
Description
Description
https://github.com/fsprojects/FSharpPlus/issues/158#issuecomment-512607693
For the StringBuilder extension, it will be used like below with the
String.buildfunction from my String.fs:let s = String.build (fun builder -> builder.printfn "%s" "hello" builder.printfn "%i%i" 4 2 ... )The motivation to use this extension is to avoid the repetitive use of
ignorecaused by the fact StringBuilder'sWriteandWriteLinereturns the StringBuilder for method chaining. Also,sb.WriteLine(sprintf "%i" 42).WriteLine(sprintf "%s" "foo").ToString()looks odd and ugly imo, but this might be just a personal impression.
https://github.com/fsprojects/FSharpPlus/issues/158#issuecomment-512721780
the
buildand the StringBuilder functions looks nice to me, but let's open another issue for StringBuilder extensions as at the moment we don't have any of them, and it might require more discussion.
Referece implementation:
From cannorin/prelude.fs:
let build (builder: StringBuilder -> unit) =
let sb = new StringBuilder()
builder sb
sb.ToString()
type StringBuilder with
member inline this.printf format =
Printf.kprintf (fun s -> this.Append s |> ignore) format
member inline this.printfn format =
Printf.kprintf (fun s -> this.AppendLine s |> ignore) format
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked discussion in fsprojects/FSharpPlus issue 158 and compare its proposed StringBuilder extension with the reference implementation in cannorin/prelude.fs. Check the existing String.fs and extension organization, then determine whether String.build plus printf and printfn are the agreed scope; done means the selected functions are available with matching behavior and coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100