Skip to main content

Module io

Module io 

Source
Expand description

IO primitives: results (EST.Out), handles (the standard streams and files), streams, ST.Ref and the monotonic clocks.

In Lean 4.35 an IO action returns an EST.Out (ok = constructor 0, error = constructor 1, one object field), while a BaseIO/ST action returns its value itself. The world parameter has the IR type void and is not passed to externs.

Structs§

FileState
An open file and the bytes read from it ahead of the reader.

Enums§

HandleFile
The file behind a IO.FS.Handle.

Functions§

lean_get_set_stderr⚠
IO.setStderr : IO.FS.Stream → BaseIO IO.FS.Stream.
lean_get_set_stdin⚠
IO.setStdin : IO.FS.Stream → BaseIO IO.FS.Stream (returns the previous stream).
lean_get_set_stdout⚠
IO.setStdout : IO.FS.Stream → BaseIO IO.FS.Stream.
lean_get_stderr⚠
IO.getStderr : BaseIO IO.FS.Stream.
lean_get_stdin⚠
IO.getStdin : BaseIO IO.FS.Stream.
lean_get_stdout⚠
IO.getStdout : BaseIO IO.FS.Stream.
lean_io_exit⚠
IO.Process.exit : UInt8 → IO α.
lean_io_mk_world⚠
lean_io_mono_ms_now⚠
IO.monoMsNow : BaseIO Nat.
lean_io_mono_nanos_now⚠
IO.monoNanosNow : BaseIO Nat.
lean_io_prim_handle_flush⚠
Handle.flush : (@& Handle) → IO Unit.
lean_io_prim_handle_get_line⚠
Handle.getLine : (@& Handle) → IO String: up to and including the next newline.
lean_io_prim_handle_is_tty⚠
Handle.isTty : (@& Handle) → BaseIO Bool.
lean_io_prim_handle_lock⚠
Handle.lock : (@& Handle) → (exclusive : Bool) → IO Unit.
lean_io_prim_handle_mk⚠
Handle.mk : (@& FilePath) → FS.Mode → IO Handle: read, write, writeNew, readWrite or append (0–4).
lean_io_prim_handle_put_str⚠
Handle.putStr : (@& Handle) → (@& String) → IO Unit.
lean_io_prim_handle_read⚠
Handle.read : (@& Handle) → USize → IO ByteArray.
lean_io_prim_handle_rewind⚠
Handle.rewind : (@& Handle) → IO Unit.
lean_io_prim_handle_truncate⚠
Handle.truncate : (@& Handle) → IO Unit: truncates the file at the reader’s position.
lean_io_prim_handle_try_lock⚠
Handle.tryLock : (@& Handle) → (exclusive : Bool) → IO Bool.
lean_io_prim_handle_unlock⚠
Handle.unlock : (@& Handle) → IO Unit.
lean_io_prim_handle_write⚠
Handle.write : (@& Handle) → (@& ByteArray) → IO Unit.
lean_io_result_get_error⚠
lean_io_result_get_value⚠
lean_io_result_is_error⚠
lean_io_result_is_ok⚠
lean_io_result_mk_error⚠
lean_io_result_mk_ok⚠
lean_io_result_show_error⚠
Prints uncaught exception: <IO.Error.toString e> for an error result (borrowed).
lean_io_result_take_value⚠
The value of an ok result (consumes r).
lean_io_wrap_handle⚠
An IO.FS.Handle for f.
lean_runtime_mark_multi_threaded⚠
Runtime.markMultiThreaded : α → BaseIO α (objects stay single-threaded).
lean_runtime_mark_persistent⚠
Runtime.markPersistent : α → BaseIO α.
lean_st_mk_ref⚠
ST.Prim.mkRef (consumes a).
lean_st_ref_get⚠
ST.Prim.Ref.get (borrows the ref).
lean_st_ref_ptr_eq⚠
ST.Prim.Ref.ptrEq.
lean_st_ref_put⚠
ST.Prim.Ref.set (consumes a).
lean_st_ref_swap⚠
ST.Prim.Ref.swap (consumes a, returns the old value).
lean_st_ref_take⚠
ST.Prim.Ref.take: the value, leaving the ref empty.
lean_stream_of_handle⚠
IO.FS.Stream.ofHandle (consumes h).