You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
❯ roc check examples/getVisualWidth.roc
── UNRECOGNIZED NAME in examples/../../basic-cli/platform/main.roc ─────────────
The #UserApp module does not expose anything by the name 1.
── UNRECOGNIZED NAME in examples/../../basic-cli/platform/main.roc ─────────────
The #UserApp module does not expose anything by the name 1.
With the code:
app [main] {
pf: platform "../../basic-cli/platform/main.roc",
unicode: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/roc/unicode/releases
}
import pf.Stdoutimport unicode.CodePointword = "世界"## Get the display width (in amount of characters) of a Strget_visual_width : Str -> ResultU32CodePoint.Utf8ParseErrget_visual_width = \str ->
str
|>Str.to_utf8|>CodePoint.parse_utf8|>Result.map(\lst -> List.map(lst, CodePoint.visual_width))
|>Result.map(List.sum)
main =
when get_visual_width(word) isOk(width) -> Stdout.line("\n\nThe word ${word} will be displayed with the width of ${Num.to_str(width)} characters on most UIs.\n\n")
Err(_) -> crash("ERROR: Unable to parse ${word}!")
expect (get_visual_width(word)) ==Ok(4)
This happens if you forget the ! after main.
The text was updated successfully, but these errors were encountered:
With the code:
This happens if you forget the
!
aftermain
.The text was updated successfully, but these errors were encountered: