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
There's currently no way to match built-in strings with anything but identify. In other words, one can write the following:
match s
with "one" :: 1
with "two" :: 2
But one can't check for any pattern that would match only parts of the string (e.g. the character at specific position). Although less impactful, note that built-in integers expose a similar problem.
One solution could be to map the built-in strings to an algebraic type such as #cons(_: Char, _: String) or #empty, which would make them naturally expressible in the language. Hence, the syntax with double quotes would be merely a syntactic sugar for #cons("a", cons("b", ....
Another direction would be to provide a built-in function to extract a specific character (e.g. char(in:at:)) and use identity matching, e.g.:
match char(in: s, at: 0)
with "a" :: "the string starts with 'a'"
// ...
Note that both solutions would require a built-in Char type.
The text was updated successfully, but these errors were encountered:
There's currently no way to match built-in strings with anything but identify. In other words, one can write the following:
But one can't check for any pattern that would match only parts of the string (e.g. the character at specific position). Although less impactful, note that built-in integers expose a similar problem.
One solution could be to map the built-in strings to an algebraic type such as
#cons(_: Char, _: String) or #empty
, which would make them naturally expressible in the language. Hence, the syntax with double quotes would be merely a syntactic sugar for#cons("a", cons("b", ...
.Another direction would be to provide a built-in function to extract a specific character (e.g.
char(in:at:)
) and use identity matching, e.g.:Note that both solutions would require a built-in
Char
type.The text was updated successfully, but these errors were encountered: