Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion stdlib/effects.affine
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ extern fn read_file(path: String) -> String / io;
extern fn write_file(path: String, content: String) -> Unit / io;

// Built-in State operations
extern fn ref<T>(x: T) -> Ref<T> / state;
// `make_ref` (not `ref`) because `ref` is a reserved ownership keyword;
// see #135 keyword-as-identifier slice.
extern fn make_ref<T>(x: T) -> Ref<T> / state;
extern fn get<T>(r: Ref<T>) -> T / state;
extern fn set<T>(r: Ref<T>, x: T) -> Unit / state;

Expand Down
6 changes: 4 additions & 2 deletions stdlib/result.affine
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ fn result_or<T, E>(a: Result<T, E>, b: Result<T, E>) -> Result<T, E> {
// Error Handling Patterns
// ============================================================================

/// Try block emulation - execute function and catch panics as Err
fn try<T>(f: () -> T) -> Result<T, String> {
/// Try block emulation - execute function and catch panics as Err.
/// Named `attempt` (not `try`) because `try` is a reserved keyword
/// (try/catch/finally); see #135 keyword-as-identifier slice.
fn attempt<T>(f: () -> T) -> Result<T, String> {
// TODO: Requires exception handling support
try {
Ok(f())
Expand Down
Loading