flix

0.67.0

Abort

eff AbortSource

An effect used to abort computation with an error message.

Operations

def abort(m: String): Void \ Abort Source

Immediately aborts the current computation with the given error message m.

The computation cannot be resumed.

Definitions

def handle(f: a -> b \ ef): a -> b \ (ef - Abort) + IO Source

Handles the Abort effect of the given function f by printing the error message and exiting.

In other words, re-interprets the Abort effect using the IO effect.

Note: The returned function can still return normally if abort is never called by f.

def handleWithResult(f: a -> b \ ef): a -> Result[String, b] \ ef - Abort Source

Handles the Abort effect of the given function f by converting aborts to Result values.

Returns a function that

Returns Ok(f()) if the computation completes successfully without aborting. Returns Err(m) if the computation aborts with error message m.

@DefaultHandler
def runWithIO(f: Unit -> a \ ef): a \ (ef - Abort) + IO Source

Runs the Abort effect of the given function f.

In other words, re-interprets the Abort effect using the IO effect.

Note: This function can still return normally if abort is never called by f.

def runWithResult(f: Unit -> a \ ef): Result[String, a] \ ef - Abort Source

Runs the Abort effect of the given function f.

Returns Ok(f()) if the computation completes successfully without aborting. Returns Err(m) if the computation aborts with error message m.