Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IO functions return Result #657

Closed
developedby opened this issue Aug 5, 2024 · 0 comments · Fixed by #661
Closed

Make IO functions return Result #657

developedby opened this issue Aug 5, 2024 · 0 comments · Fixed by #661
Labels
enhancement New feature or request prelude Bend's builtin types and functions

Comments

@developedby
Copy link
Member

HigherOrderCO/HVM#407 Implements the necessary changes for us to capture both errors in the runtime (like incorrect arguments, non-existant IO called) as well as errors in the execution of the IO themselves.

The IOs now return Result<A, IOError<B>>

We need to add the IOError type to the prelude

# Not necessarily these names
type IOError(T):
  TypeError
  UnknownFn
  Inner { val: T }

First one is generated by the IO function, for when user passes incorrect / invalid arguments.
Second one is generated by the runtime itself, when the user calls a function with a name that isn't registered.
Third one is all the errors internal to the IO functions themselves. For example, opening a file when it doesn't exist returns an Inner with a string containing the OS message.

Looking at the pull request shows the other inner errors returned by each IO function.

We need to change the existing IO functions to reflect this change in HVM.

@developedby developedby added enhancement New feature or request prelude Bend's builtin types and functions labels Aug 5, 2024
@imaqtkatt imaqtkatt linked a pull request Aug 7, 2024 that will close this issue
github-merge-queue bot pushed a commit that referenced this issue Aug 7, 2024
@developedby developedby added this to the Bend IO lib v0 milestone Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request prelude Bend's builtin types and functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant