Stream: beginners

Topic: Missing Str.graphemes


view this post on Zulip Gabriela (Oct 23 2022 at 21:25):

The Str module does not expose graphemes:

21│ |> Str.graphemes
^^^^^^^^^^^^^

https://www.roc-lang.org/builtins/Str/#graphemes

view this post on Zulip Folkert de Vries (Oct 23 2022 at 21:26):

the PR for that was merged today, so you may have a version of the compiler that does not support it yet

view this post on Zulip Gabriela (Oct 23 2022 at 21:34):

So I will wait for the next nightly build to be available, probably tomorrow, thanks.

view this post on Zulip Chris Duncan (Oct 23 2022 at 21:51):

Here's the previous conversation on this topic:
https://roc.zulipchat.com/#narrow/stream/316715-contributing/topic/.E2.9C.94.20Missing.20Str.2Egraphemes

view this post on Zulip Gabriela (Oct 23 2022 at 22:02):

I was a little anxious to finish this advent of code exercise (2015, 3rd), so I converted the String input myself.
https://pastebin.com/YGB2rkFP

view this post on Zulip Chris Duncan (Oct 23 2022 at 22:41):

In lieu of not having that function, I did the following for Roctoberfest:

parseContents : Str -> Result Report [ContentsParseErr Str]*
parseContents = \contents ->
    line <- Str.split contents "\n" |> List.mapTry
    err <- Result.mapErr (parseLine line)
    when err is
        InvalidBit -> ContentsParseErr "The line \"\(line)\" have an invalid bit"

parseLine : Str -> Result ReportLine [InvalidBit]*
parseLine = \line -> List.mapTry (Str.toUtf8 line) parseBit

expect parseLine "101010011010" == Ok [One, Zero, One, Zero, One, Zero, Zero, One, One, Zero, One, Zero]

parseBit : U8 -> Result Bit [InvalidBit]*
parseBit = \bit ->
    when bit is
        48 -> Ok Zero
        49 -> Ok One
        _ -> Err InvalidBit

view this post on Zulip Anton (Oct 24 2022 at 11:37):

@Gabriela the new nightlies are available now, except for MacOS x86_64, I'll look into what went wrong there.

view this post on Zulip Anton (Oct 24 2022 at 16:18):

New MacOS x86_64 nightlies are available now as well.


Last updated: Jul 06 2025 at 12:14 UTC