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
Attempting to generalize the maybe type in the tests, I found two issues:
type maybe<type> {
Just(type)
None()
}
implementation printable<maybe<string>> {
fn to_string(a) {
match a {
Just(x) => "x"
None() => "None<string>"
}
}
}
fn print_maybe<type>(x: maybe<type>) -> void {
print(x) // not all maybes are printable
}
print(Just("abc"))
// maybe<int> is not printable...
print_maybe(Just(42))
$ ./verve input.vrv 1.53825e-1541.53825e-154
I think the two issues are:
the output of print(Just("abc")) is some undefined value (the number changes slightly between runs) interpreted as a float.
print_maybe can be used with non-printable maybes, (when one kind of maybe is printable.).
The text was updated successfully, but these errors were encountered:
Other than the fact that the type checker is not that smart yet (😞), there are a couple hacks that I have to fix to make it more sane:
The signature of print says it takes a printable, but it never calls to_string in the value. It's an old version of the function that expects the pointer to be NaN-boxed and checks the type tag.
In the case that the print function doesn't recognise the type tag, it'll print anything as doubles: that was a quick hack to add double support without rewriting the whole print logic (I know, it's bad)
I'll try to fix these issues soon, and it should, at least, improve the error, instead of just printing garbage.
Attempting to generalize the maybe type in the tests, I found two issues:
I think the two issues are:
print(Just("abc"))
is some undefined value (the number changes slightly between runs) interpreted as a float.The text was updated successfully, but these errors were encountered: