Stream: contributing

Topic: GPT-assisted documentation writing


view this post on Zulip Richard Feldman (Mar 29 2023 at 00:57):

this is very cool!
Screen-Shot-2023-03-28-at-8.56.08-PM.png

Screen-Shot-2023-03-28-at-8.56.40-PM.png

Screen-Shot-2023-03-28-at-8.56.56-PM.png

view this post on Zulip Richard Feldman (Mar 29 2023 at 00:57):

here's what it came up with:

## Split a string into its constituent grapheme clusters.
##
## This function breaks a string into its individual [grapheme clusters](https://stackoverflow.com/a/27331885/4200103),
## returning them as a list of strings. This is useful for working with text that
## contains complex characters, such as emojis or combined characters.
##
## Examples:
## ```
## expect Str.graphemes "Roc" == ["R", "o", "c"]
## expect Str.graphemes "नमस्ते" == ["न", "म", "स", "्", "त", "े"]
## expect Str.graphemes "👩‍👩‍👦‍👦" == ["👩", "‍", "👩", "‍", "👦", "‍", "👦"]
## ```
##
## Note that the "👩‍👩‍👦‍👦" example consists of 7 grapheme clusters, although it visually
## appears as a single glyph. This is because it uses an emoji modifier sequence.
graphemes : Str -> List Str

view this post on Zulip Richard Feldman (Mar 29 2023 at 01:06):

the second and third examples are nice examples, and although they're totally incorrect, I can fix them myself :big_smile:

Screen-Shot-2023-03-28-at-9.08.06-PM.png

view this post on Zulip Richard Feldman (Mar 29 2023 at 01:34):

another cool one:

Screen-Shot-2023-03-28-at-9.33.55-PM.png

(I also gave it a couple of other Str functions for context)

It came up with:

## Encode a range of a [List] of [U8] UTF-8 [code units](https://unicode.org/glossary/#code_unit)
## into a [Str]. The range is specified by a `start` index and a `count` of elements to encode.
##
## Returns `Err OutOfBounds` if the specified range exceeds the list's length.
## Returns `Err BadUtf8` if the given bytes within the specified range are invalid UTF-8.
## Returns `Ok ""` when given `[]` or a `count` of 0.
##
## Example:
## ```
## expect Str.toUtf8 "Hi there!" |> Str.fromUtf8Range { start : 0, count : 2 } == Ok "Hi"
## expect Str.toUtf8 "Hello, Roc!" |> Str.fromUtf8Range { start : 0, count : 0 } == Ok ""
## expect Str.toUtf8 "Hello, Roc!" |> Str.fromUtf8Range { start : 7, count : 3 } == Ok "Roc"
## expect Str.toUtf8 "Hello, Roc!" |> Str.fromUtf8Range { start : 12, count : 2 } |> Result.isErr
## ```
fromUtf8Range : List U8, { start : Nat, count : Nat } -> Result Str [BadUtf8 Utf8ByteProblem Nat, OutOfBounds]

view this post on Zulip Luke Boswell (Mar 29 2023 at 02:39):

It looks like ChatGPT has no issues reading and writing Roc syntax :grinning_face_with_smiling_eyes:

view this post on Zulip Richard Feldman (Mar 29 2023 at 12:40):

oh yeah, I've already started to take that for granted :big_smile:

view this post on Zulip Richard Feldman (Mar 29 2023 at 12:40):

Copilot will sometimes think I'm writing Elm and do things like generate case ... of instead of when ... is - but maybe that's because Copilot uses Codex, which is some version of GPT earlier than 4

view this post on Zulip Richard Feldman (Mar 29 2023 at 12:41):

although at least on chatGPT, choosing GPT-4 makes it way slower to generate answers, so I'm curious to see how that affects the "Copilot on GPT-4" experience


Last updated: Jul 06 2025 at 12:14 UTC