Skip to content

Commit

Permalink
Rename InvalidUnicode tag to InvalidUtf8
Browse files Browse the repository at this point in the history
  • Loading branch information
smores56 committed Dec 21, 2024
1 parent d5b2caf commit 49e0c18
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions package/Arg.roc
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ from_str = \str ->
@Arg (Unix (Str.toUtf8 str))

## Attempt to decode an [Arg] to a UTF-8 [Str].
to_str : Arg -> Result Str [InvalidUnicode]
to_str : Arg -> Result Str [InvalidUtf8]
to_str = \@Arg arg ->
# TODO: update when Unicode -> Str conversion is ready:
# https://github.com/roc-lang/roc/issues/7390
when arg is
Unix unix ->
Str.fromUtf8 unix
|> Result.mapErr \_err -> InvalidUnicode
|> Result.mapErr \_err -> InvalidUtf8

Windows _windows -> Err InvalidUnicode
Windows _windows -> Err InvalidUtf8

## Convert an [Arg] to a list of bytes.
to_bytes : Arg -> List U8
Expand Down
2 changes: 1 addition & 1 deletion package/Base.roc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Plurality : [Optional, One, Many]
## The two built-in flags that we parse automatically.
SpecialFlags : { help : Bool, version : Bool }

InvalidValue : [InvalidNumStr, InvalidValue Str, InvalidUnicode]
InvalidValue : [InvalidNumStr, InvalidValue Str, InvalidUtf8]

DefaultValue a : [NoDefault, Value a, Generate ({} -> a)]

Expand Down
4 changes: 2 additions & 2 deletions package/ErrorFormatter.roc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ format_arg_extract_err = \err ->
InvalidValue reason ->
"The value provided to $(option_display_name option) was not a valid $(option_type_name option): $(reason)"

InvalidUnicode ->
InvalidUtf8 ->
"The value provided to $(option_display_name option) was not valid UTF-8."

InvalidParamValue value_err param ->
Expand All @@ -79,7 +79,7 @@ format_arg_extract_err = \err ->
InvalidValue reason ->
"The value provided to the '$(param |> .name)' parameter was not a valid $(param |> .type |> full_type_name): $(reason)."

InvalidUnicode ->
InvalidUtf8 ->
"The value provided to the '$(param |> .name)' parameter was not valid UTF-8."

MissingParam parameter ->
Expand Down
6 changes: 3 additions & 3 deletions package/Opt.roc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ get_maybe_value = \values, option ->
## expect
## Color : [Green, Red, Blue]
##
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUnicode]
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUtf8]
## parse_color = \color ->
## when Arg.to_str color is
## Ok "green" -> Ok Green
Expand Down Expand Up @@ -155,7 +155,7 @@ single = \{ parser, type, short ? "", long ? "", help ? "", default ? NoDefault
## expect
## Color : [Green, Red, Blue]
##
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUnicode]
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUtf8]
## parse_color = \color ->
## when Arg.to_str color is
## Ok "green" -> Ok Green
Expand Down Expand Up @@ -203,7 +203,7 @@ maybe = \{ parser, type, short ? "", long ? "", help ? "" } ->
## expect
## Color : [Green, Red, Blue]
##
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUnicode]
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUtf8]
## parse_color = \color ->
## when Arg.to_str color is
## Ok "green" -> Ok Green
Expand Down
6 changes: 3 additions & 3 deletions package/Param.roc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ builder_with_parameter_parser = \param, value_parser ->
## expect
## Color : [Green, Red, Blue]
##
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUnicode]
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUtf8]
## parse_color = \color ->
## when Arg.to_str color is
## Ok "green" -> Ok Green
Expand Down Expand Up @@ -158,7 +158,7 @@ single = \{ parser, type, name, help ? "", default ? NoDefault } ->
## expect
## Color : [Green, Red, Blue]
##
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUnicode]
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUtf8]
## parse_color = \color ->
## when Arg.to_str color is
## Ok "green" -> Ok Green
Expand Down Expand Up @@ -209,7 +209,7 @@ maybe = \{ parser, type, name, help ? "" } ->
## expect
## Color : [Green, Red, Blue]
##
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUnicode]
## parse_color : Arg -> Result Color [InvalidValue Str, InvalidUtf8]
## parse_color = \color ->
## when Arg.to_str color is
## Ok "green" -> Ok Green
Expand Down
2 changes: 1 addition & 1 deletion package/Parser.roc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ parse_arg = \arg ->
str_arg =
when Arg.to_str arg is
Ok str -> str
Err InvalidUnicode ->
Err InvalidUtf8 ->
return Parameter arg

when Str.splitFirst str_arg "-" is
Expand Down

0 comments on commit 49e0c18

Please sign in to comment.