No matching definitions.

tur/effects

stdlib/effects.tur

standard algebraic effects for IO, logging, and randomness.

Since: Phase 19

defmacro

with-write

(with-write [body])

handle the Write effect by printing to stdout via println.

bodythe expression whose Write effects are handled

the return value of body

(with-write (perform (Write "hello")))  ; prints "hello"

Since: Phase 19

defmacro

with-fail-panic

(with-fail-panic [body])

handle the Fail effect by panicking with the message.

bodythe expression whose Fail effects are handled

the return value of body, or panics on Fail

(with-fail-panic (perform (Fail "oops")))  ; panics with "oops"

Since: Phase 19

defmacro

with-getenv

(with-getenv [body])

handle the GetEnv effect by delegating to C getenv(3).

bodythe expression whose GetEnv effects are handled

the return value of body

(with-getenv (perform (GetEnv "PATH")))  ; => "/usr/bin:..."

Since: Phase 19

defn

read-int-console

(read-int-console)

read a single integer from stdin via scanf.

int -- the integer read from stdin

(read-int-console)  ; => 7

Since: Phase 19

defmacro

with-read-console

(with-read-console [body])

handle the Read effect by reading an integer from stdin.

bodythe expression whose Read effects are handled

the return value of body

(with-read-console (perform (Read)))  ; reads integer from stdin

Since: Phase 19

defmacro

with-stderr-log

(with-stderr-log [body])

handle the Log effect by printing all messages to stdout.

bodythe expression whose Log effects are handled

the return value of body

(with-stderr-log (perform (Log "warn" "low memory")))  ; prints "low memory"

Since: Phase 19

defmacro

with-silent-log

(with-silent-log [body])

handle the Log effect by suppressing all log output.

bodythe expression whose Log effects are handled

the return value of body

(with-silent-log (perform (Log "debug" "ignored")))  ; no output

Since: Phase 19

defmacro

with-abort-panic

(with-abort-panic [body])

handle the Abort effect by panicking with the message.

bodythe expression whose Abort effects are handled

the return value of body, or panics on Abort

(with-abort-panic (perform (Abort "fatal")))  ; panics with "fatal"

Since: Phase 19

defmacro

with-async

(with-async [body])

handle the Async effect by running the thunk and resuming with its result.

bodythe expression whose Async effects are handled

the return value of body

(with-async (perform (Async my-thunk)))  ; runs thunk inline

Since: Phase T25

defmacro

with-await

(with-await [body])

handle the Await effect by blocking until the future resolves.

bodythe expression whose Await effects are handled

the return value of body

(with-await (perform (Await my-future)))  ; => resolved value

Since: Phase T25