File: .lake/packages/lean4/src/lean/Init/System/IO.lean

full_name: IO.RealWorld
code: /-- Like <https://hackage.haskell.org/package/ghc-Prim-0.5.2.0/docs/GHC-Prim.html#t:RealWorld>.
    Makes sure we never reorder `IO` operations.

    TODO: mark opaque -/
def IO.RealWorld : Type 
goal: Type

full_name: EIO
code: def EIO (ε : Type) : Type → Type 
goal: Type → Type

full_name: instMonadEIO
code: instance : Monad (EIO ε) 
goal: Monad (EIO ε)

full_name: instMonadFinallyEIO
code: instance : MonadFinally (EIO ε) 
goal: MonadFinally (EIO ε)

full_name: instMonadExceptOfEIO
code: instance : MonadExceptOf ε (EIO ε) 
goal: MonadExceptOf ε (EIO ε)

full_name: instOrElseEIO
code: instance : OrElse (EIO ε α) 
goal: OrElse (EIO ε α)

full_name: instInhabitedEIO
code: instance [Inhabited ε] : Inhabited (EIO ε α) 
goal: Inhabited (EIO ε α)

full_name: BaseIO
code: /-- An `EIO` monad that cannot throw exceptions. -/
def BaseIO 
goal: Type → Type

full_name: instMonadBaseIO
code: instance : Monad BaseIO 
goal: Monad BaseIO

full_name: instMonadFinallyBaseIO
code: instance : MonadFinally BaseIO 
goal: MonadFinally BaseIO

full_name: BaseIO.toEIO
code: @[always_inline, inline]
def BaseIO.toEIO (act : BaseIO α) : EIO ε α 
goal: EIO ε α

full_name: instMonadLiftBaseIOEIO
code: instance : MonadLift BaseIO (EIO ε) 
goal: MonadLift BaseIO (EIO ε)

full_name: EIO.toBaseIO
code: @[always_inline, inline]
def EIO.toBaseIO (act : EIO ε α) : BaseIO (Except ε α) 
goal: BaseIO (Except ε α)

full_name: EIO.catchExceptions
code: @[always_inline, inline]
def EIO.catchExceptions (act : EIO ε α) (h : ε → BaseIO α) : BaseIO α 
goal: BaseIO α

full_name: IO
code: abbrev IO : Type → Type 
goal: Type → Type

full_name: BaseIO.toIO
code: @[inline] def BaseIO.toIO (act : BaseIO α) : IO α 
goal: IO α

full_name: EIO.toIO
code: @[inline] def EIO.toIO (f : ε → IO.Error) (act : EIO ε α) : IO α 
goal: IO α

full_name: EIO.toIO'
code: @[inline] def EIO.toIO' (act : EIO ε α) : IO (Except ε α) 
goal: IO (Except ε α)

full_name: IO.toEIO
code: @[inline] def IO.toEIO (f : IO.Error → ε) (act : IO α) : EIO ε α 
goal: EIO ε α

full_name: unsafeBaseIO
code: @[inline] unsafe def unsafeBaseIO (fn : BaseIO α) : α 
goal: α

full_name: unsafeEIO
code: @[inline] unsafe def unsafeEIO (fn : EIO ε α) : Except ε α 
goal: Except ε α

full_name: unsafeIO
code: @[inline] unsafe def unsafeIO (fn : IO α) : Except IO.Error α 
goal: Except IO.Error α

full_name: timeit
code: @[extern "lean_io_timeit"] opaque timeit (msg : @& String) (fn : IO α) : IO α
goal: IO α

full_name: allocprof
code: @[extern "lean_io_allocprof"] opaque allocprof (msg : @& String) (fn : IO α) : IO α
goal: IO α

full_name: IO.initializing
code: /-- Programs can execute IO actions during initialization that occurs before
   the `main` function is executed. The attribute `[init <action>]` specifies
   which IO action is executed to set the value of an opaque constant.

   The action `initializing` returns `true` iff it is invoked during initialization. -/
@[extern "lean_io_initializing"] opaque IO.initializing : BaseIO Bool
goal: BaseIO Bool

full_name: BaseIO.asTask
code: /--
  Run `act` in a separate `Task`.
  This is similar to Haskell's [`unsafeInterleaveIO`](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-IO-Unsafe.html#v:unsafeInterleaveIO),
  except that the `Task` is started eagerly as usual. Thus pure accesses to the `Task` do not influence the impure `act`
  computation.
  Unlike with pure tasks created by `Task.spawn`, tasks created by this function will be run even if the last reference
  to the task is dropped. The `act` should manually check for cancellation via `IO.checkCanceled` if it wants to react
  to that. -/
@[extern "lean_io_as_task"]
opaque asTask (act : BaseIO α) (prio := Task.Priority.default) : BaseIO (Task α) 
goal: BaseIO (Task α)

full_name: BaseIO.mapTask
code: /-- See `BaseIO.asTask`. -/
@[extern "lean_io_map_task"]
opaque mapTask (f : α → BaseIO β) (t : Task α) (prio := Task.Priority.default) (sync := false) :
    BaseIO (Task β) 
goal: BaseIO (Task β)

full_name: BaseIO.bindTask
code: /-- See `BaseIO.asTask`. -/
@[extern "lean_io_bind_task"]
opaque bindTask (t : Task α) (f : α → BaseIO (Task β)) (prio := Task.Priority.default)
    (sync := false) : BaseIO (Task β) 
goal: BaseIO (Task β)

full_name: BaseIO.mapTasks.go
code: def mapTasks (f : List α → BaseIO β) (tasks : List (Task α)) (prio := Task.Priority.default)
    (sync := false) : BaseIO (Task β) 
goal: List (Task α) → List α → BaseIO (Task β)

full_name: BaseIO.mapTasks
code: def mapTasks (f : List α → BaseIO β) (tasks : List (Task α)) (prio := Task.Priority.default)
    (sync := false) : BaseIO (Task β) 
goal: BaseIO (Task β)

full_name: EIO.asTask
code: /-- `EIO` specialization of `BaseIO.asTask`. -/
@[inline] def asTask (act : EIO ε α) (prio := Task.Priority.default) : BaseIO (Task (Except ε α)) 
goal: BaseIO (Task (Except ε α))

full_name: EIO.mapTask
code: /-- `EIO` specialization of `BaseIO.mapTask`. -/
@[inline] def mapTask (f : α → EIO ε β) (t : Task α) (prio := Task.Priority.default)
    (sync := false) : BaseIO (Task (Except ε β)) 
goal: BaseIO (Task (Except ε β))

full_name: EIO.bindTask
code: /-- `EIO` specialization of `BaseIO.bindTask`. -/
@[inline] def bindTask (t : Task α) (f : α → EIO ε (Task (Except ε β)))
    (prio := Task.Priority.default) (sync := false) : BaseIO (Task (Except ε β)) 
goal: BaseIO (Task (Except ε β))

full_name: EIO.mapTasks
code: /-- `EIO` specialization of `BaseIO.mapTasks`. -/
@[inline] def mapTasks (f : List α → EIO ε β) (tasks : List (Task α))
    (prio := Task.Priority.default) (sync := false) : BaseIO (Task (Except ε β)) 
goal: BaseIO (Task (Except ε β))

full_name: IO.ofExcept
code: def ofExcept [ToString ε] (e : Except ε α) : IO α 
goal: IO α

full_name: IO.lazyPure
code: def lazyPure (fn : Unit → α) : IO α 
goal: IO α

full_name: IO.monoMsNow
code: /-- Monotonically increasing time since an unspecified past point in milliseconds. No relation to wall clock time. -/
@[extern "lean_io_mono_ms_now"] opaque monoMsNow : BaseIO Nat
goal: BaseIO Nat

full_name: IO.monoNanosNow
code: /-- Monotonically increasing time since an unspecified past point in nanoseconds. No relation to wall clock time. -/
@[extern "lean_io_mono_nanos_now"] opaque monoNanosNow : BaseIO Nat
goal: BaseIO Nat

full_name: IO.getRandomBytes
code: /-- Read bytes from a system entropy source. Not guaranteed to be cryptographically secure.
If `nBytes = 0`, return immediately with an empty buffer. -/
@[extern "lean_io_get_random_bytes"] opaque getRandomBytes (nBytes : USize) : IO ByteArray
goal: IO ByteArray

full_name: IO.sleep
code: def sleep (ms : UInt32) : BaseIO Unit 
goal: BaseIO Unit

full_name: IO.asTask
code: /-- `IO` specialization of `EIO.asTask`. -/
@[inline] def asTask (act : IO α) (prio := Task.Priority.default) : BaseIO (Task (Except IO.Error α)) 
goal: BaseIO (Task (Except IO.Error α))

full_name: IO.mapTask
code: /-- `IO` specialization of `EIO.mapTask`. -/
@[inline] def mapTask (f : α → IO β) (t : Task α) (prio := Task.Priority.default) (sync := false) :
    BaseIO (Task (Except IO.Error β)) 
goal: BaseIO (Task (Except IO.Error β))

full_name: IO.bindTask
code: /-- `IO` specialization of `EIO.bindTask`. -/
@[inline] def bindTask (t : Task α) (f : α → IO (Task (Except IO.Error β)))
    (prio := Task.Priority.default) (sync := false) : BaseIO (Task (Except IO.Error β)) 
goal: BaseIO (Task (Except IO.Error β))

full_name: IO.mapTasks
code: /-- `IO` specialization of `EIO.mapTasks`. -/
@[inline] def mapTasks (f : List α → IO β) (tasks : List (Task α)) (prio := Task.Priority.default)
    (sync := false) : BaseIO (Task (Except IO.Error β)) 
goal: BaseIO (Task (Except IO.Error β))

full_name: IO.checkCanceled
code: /-- Check if the task's cancellation flag has been set by calling `IO.cancel` or dropping the last reference to the task. -/
@[extern "lean_io_check_canceled"] opaque checkCanceled : BaseIO Bool
goal: BaseIO Bool

full_name: IO.cancel
code: /-- Request cooperative cancellation of the task. The task must explicitly call `IO.checkCanceled` to react to the cancellation. -/
@[extern "lean_io_cancel"] opaque cancel : @& Task α → BaseIO Unit
goal: Task α → BaseIO Unit

full_name: IO.TaskState.running
code: /-- The current state of a `Task` in the Lean runtime's task manager. -/
inductive TaskState
  /--
  The `Task` is waiting to be run.
  It can be waiting for dependencies to complete or
  sitting in the task manager queue waiting for a thread to run on.
  -/
  | waiting
  /--
  The `Task` is actively running on a thread or,
  in the case of a `Promise`, waiting for a call to `IO.Promise.resolve`.
  -/
  | running
  /--
  The `Task` has finished running and its result is available.
  Calling `Task.get` or `IO.wait` on the task will not block.
  -/
  | finished
  deriving Inhabited, Repr, DecidableEq, Ord
goal: IO.TaskState

full_name: IO.TaskState.waiting
code: /-- The current state of a `Task` in the Lean runtime's task manager. -/
inductive TaskState
  /--
  The `Task` is waiting to be run.
  It can be waiting for dependencies to complete or
  sitting in the task manager queue waiting for a thread to run on.
  -/
  | waiting
  /--
  The `Task` is actively running on a thread or,
  in the case of a `Promise`, waiting for a call to `IO.Promise.resolve`.
  -/
  | running
  /--
  The `Task` has finished running and its result is available.
  Calling `Task.get` or `IO.wait` on the task will not block.
  -/
  | finished
  deriving Inhabited, Repr, DecidableEq, Ord
goal: IO.TaskState

full_name: IO.TaskState.finished
code: /-- The current state of a `Task` in the Lean runtime's task manager. -/
inductive TaskState
  /--
  The `Task` is waiting to be run.
  It can be waiting for dependencies to complete or
  sitting in the task manager queue waiting for a thread to run on.
  -/
  | waiting
  /--
  The `Task` is actively running on a thread or,
  in the case of a `Promise`, waiting for a call to `IO.Promise.resolve`.
  -/
  | running
  /--
  The `Task` has finished running and its result is available.
  Calling `Task.get` or `IO.wait` on the task will not block.
  -/
  | finished
  deriving Inhabited, Repr, DecidableEq, Ord
goal: IO.TaskState

full_name: IO.instReprTaskState
code: /-- The current state of a `Task` in the Lean runtime's task manager. -/
inductive TaskState
  /--
  The `Task` is waiting to be run.
  It can be waiting for dependencies to complete or
  sitting in the task manager queue waiting for a thread to run on.
  -/
  | waiting
  /--
  The `Task` is actively running on a thread or,
  in the case of a `Promise`, waiting for a call to `IO.Promise.resolve`.
  -/
  | running
  /--
  The `Task` has finished running and its result is available.
  Calling `Task.get` or `IO.wait` on the task will not block.
  -/
  | finished
  deriving Inhabited, Repr, DecidableEq, Ord
goal: Repr IO.TaskState

full_name: IO.TaskState
code: /-- The current state of a `Task` in the Lean runtime's task manager. -/
inductive TaskState
  /--
  The `Task` is waiting to be run.
  It can be waiting for dependencies to complete or
  sitting in the task manager queue waiting for a thread to run on.
  -/
  | waiting
  /--
  The `Task` is actively running on a thread or,
  in the case of a `Promise`, waiting for a call to `IO.Promise.resolve`.
  -/
  | running
  /--
  The `Task` has finished running and its result is available.
  Calling `Task.get` or `IO.wait` on the task will not block.
  -/
  | finished
  deriving Inhabited, Repr, DecidableEq, Ord
goal: Type

full_name: IO.instOrdTaskState
code: /-- The current state of a `Task` in the Lean runtime's task manager. -/
inductive TaskState
  /--
  The `Task` is waiting to be run.
  It can be waiting for dependencies to complete or
  sitting in the task manager queue waiting for a thread to run on.
  -/
  | waiting
  /--
  The `Task` is actively running on a thread or,
  in the case of a `Promise`, waiting for a call to `IO.Promise.resolve`.
  -/
  | running
  /--
  The `Task` has finished running and its result is available.
  Calling `Task.get` or `IO.wait` on the task will not block.
  -/
  | finished
  deriving Inhabited, Repr, DecidableEq, Ord
goal: Ord IO.TaskState

full_name: IO.instDecidableEqTaskState
code: /-- The current state of a `Task` in the Lean runtime's task manager. -/
inductive TaskState
  /--
  The `Task` is waiting to be run.
  It can be waiting for dependencies to complete or
  sitting in the task manager queue waiting for a thread to run on.
  -/
  | waiting
  /--
  The `Task` is actively running on a thread or,
  in the case of a `Promise`, waiting for a call to `IO.Promise.resolve`.
  -/
  | running
  /--
  The `Task` has finished running and its result is available.
  Calling `Task.get` or `IO.wait` on the task will not block.
  -/
  | finished
  deriving Inhabited, Repr, DecidableEq, Ord
goal: DecidableEq IO.TaskState

full_name: IO.instInhabitedTaskState
code: /-- The current state of a `Task` in the Lean runtime's task manager. -/
inductive TaskState
  /--
  The `Task` is waiting to be run.
  It can be waiting for dependencies to complete or
  sitting in the task manager queue waiting for a thread to run on.
  -/
  | waiting
  /--
  The `Task` is actively running on a thread or,
  in the case of a `Promise`, waiting for a call to `IO.Promise.resolve`.
  -/
  | running
  /--
  The `Task` has finished running and its result is available.
  Calling `Task.get` or `IO.wait` on the task will not block.
  -/
  | finished
  deriving Inhabited, Repr, DecidableEq, Ord
goal: Inhabited IO.TaskState

full_name: IO.instLTTaskState
code: instance : LT TaskState 
goal: LT IO.TaskState

full_name: IO.instLETaskState
code: instance : LE TaskState 
goal: LE IO.TaskState

full_name: IO.instMinTaskState
code: instance : Min TaskState 
goal: Min IO.TaskState

full_name: IO.instMaxTaskState
code: instance : Max TaskState 
goal: Max IO.TaskState

full_name: IO.TaskState.toString
code: protected def TaskState.toString : TaskState → String
  
goal: IO.TaskState → String

full_name: IO.instToStringTaskState
code: instance : ToString TaskState 
goal: ToString IO.TaskState

full_name: IO.getTaskState
code: /-- Returns current state of the `Task` in the Lean runtime's task manager. -/
@[extern "lean_io_get_task_state"] opaque getTaskState : @& Task α → BaseIO TaskState
goal: Task α → BaseIO IO.TaskState

full_name: IO.hasFinished
code: /-- Check if the task has finished execution, at which point calling `Task.get` will return immediately. -/
@[inline] def hasFinished (task : Task α) : BaseIO Bool 
goal: BaseIO Bool

full_name: IO.wait
code: /-- Wait for the task to finish, then return its result. -/
@[extern "lean_io_wait"] opaque wait (t : Task α) : BaseIO α 
goal: BaseIO α

full_name: IO.waitAny
code: /-- Wait until any of the tasks in the given list has finished, then return its result. -/
@[extern "lean_io_wait_any"] opaque waitAny (tasks : @& List (Task α))
    (h : tasks.length > 0 := by exact Nat.zero_lt_succ _) : BaseIO α 
goal: BaseIO α

full_name: IO.getNumHeartbeats
code: /-- Helper method for implementing "deterministic" timeouts. It is the number of "small" memory allocations performed by the current execution thread. -/
@[extern "lean_io_get_num_heartbeats"] opaque getNumHeartbeats : BaseIO Nat
goal: BaseIO Nat

full_name: IO.addHeartbeats
code: /--
Adjusts the heartbeat counter of the current thread by the given amount. This can be useful to give
allocation-avoiding code additional "weight" and is also used to adjust the counter after resuming
from a snapshot.
-/
@[extern "lean_io_add_heartbeats"] opaque addHeartbeats (count : UInt64) : BaseIO Unit
goal: BaseIO Unit

full_name: IO.FS.Mode.writeNew
code: /--
The mode of a file handle (i.e., a set of `open` flags and an `fdopen` mode).

All modes do not translate line endings (i.e., `O_BINARY` on Windows) and
are not inherited across process creation (i.e., `O_NOINHERIT` on Windows,
`O_CLOEXEC` elsewhere).

**References:**
* Windows:
  [`_open`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-170),
  [`_fdopen`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fdopen-wfdopen?view=msvc-170)
* Linux:
  [`open`](https://linux.die.net/man/2/open),
  [`fdopen`](https://linux.die.net/man/3/fdopen)
-/
inductive FS.Mode where
  /--
  File opened for reading.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDONLY`
  * `fdopen` mode: `r`
  -/
  | read
  /--
  File opened for writing.
  On open, truncate an existing file to zero length or create a new file.
  The stream is positioned at the beginning of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC`
  * `fdopen` mode: `w`
  -/
  | write
  /--
  New file opened for writing.
  On open, create a new file with the stream positioned at the start.
  Errors if the file already exists.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC | O_EXCL`
  * `fdopen` mode: `w`
  -/
  | writeNew
  /--
  File opened for reading and writing.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDWR`
  * `fdopen` mode: `r+`
  -/
  | readWrite
  /--
  File opened for writing.
  On open, create a new file if it does not exist.
  The stream is positioned at the end of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_APPEND`
  * `fdopen` mode: `a`
  -/
  | append
goal: IO.FS.Mode

full_name: IO.FS.Mode.append
code: /--
The mode of a file handle (i.e., a set of `open` flags and an `fdopen` mode).

All modes do not translate line endings (i.e., `O_BINARY` on Windows) and
are not inherited across process creation (i.e., `O_NOINHERIT` on Windows,
`O_CLOEXEC` elsewhere).

**References:**
* Windows:
  [`_open`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-170),
  [`_fdopen`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fdopen-wfdopen?view=msvc-170)
* Linux:
  [`open`](https://linux.die.net/man/2/open),
  [`fdopen`](https://linux.die.net/man/3/fdopen)
-/
inductive FS.Mode where
  /--
  File opened for reading.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDONLY`
  * `fdopen` mode: `r`
  -/
  | read
  /--
  File opened for writing.
  On open, truncate an existing file to zero length or create a new file.
  The stream is positioned at the beginning of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC`
  * `fdopen` mode: `w`
  -/
  | write
  /--
  New file opened for writing.
  On open, create a new file with the stream positioned at the start.
  Errors if the file already exists.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC | O_EXCL`
  * `fdopen` mode: `w`
  -/
  | writeNew
  /--
  File opened for reading and writing.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDWR`
  * `fdopen` mode: `r+`
  -/
  | readWrite
  /--
  File opened for writing.
  On open, create a new file if it does not exist.
  The stream is positioned at the end of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_APPEND`
  * `fdopen` mode: `a`
  -/
  | append
goal: IO.FS.Mode

full_name: IO.FS.Mode.read
code: /--
The mode of a file handle (i.e., a set of `open` flags and an `fdopen` mode).

All modes do not translate line endings (i.e., `O_BINARY` on Windows) and
are not inherited across process creation (i.e., `O_NOINHERIT` on Windows,
`O_CLOEXEC` elsewhere).

**References:**
* Windows:
  [`_open`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-170),
  [`_fdopen`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fdopen-wfdopen?view=msvc-170)
* Linux:
  [`open`](https://linux.die.net/man/2/open),
  [`fdopen`](https://linux.die.net/man/3/fdopen)
-/
inductive FS.Mode where
  /--
  File opened for reading.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDONLY`
  * `fdopen` mode: `r`
  -/
  | read
  /--
  File opened for writing.
  On open, truncate an existing file to zero length or create a new file.
  The stream is positioned at the beginning of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC`
  * `fdopen` mode: `w`
  -/
  | write
  /--
  New file opened for writing.
  On open, create a new file with the stream positioned at the start.
  Errors if the file already exists.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC | O_EXCL`
  * `fdopen` mode: `w`
  -/
  | writeNew
  /--
  File opened for reading and writing.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDWR`
  * `fdopen` mode: `r+`
  -/
  | readWrite
  /--
  File opened for writing.
  On open, create a new file if it does not exist.
  The stream is positioned at the end of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_APPEND`
  * `fdopen` mode: `a`
  -/
  | append
goal: IO.FS.Mode

full_name: IO.FS.Mode.write
code: /--
The mode of a file handle (i.e., a set of `open` flags and an `fdopen` mode).

All modes do not translate line endings (i.e., `O_BINARY` on Windows) and
are not inherited across process creation (i.e., `O_NOINHERIT` on Windows,
`O_CLOEXEC` elsewhere).

**References:**
* Windows:
  [`_open`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-170),
  [`_fdopen`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fdopen-wfdopen?view=msvc-170)
* Linux:
  [`open`](https://linux.die.net/man/2/open),
  [`fdopen`](https://linux.die.net/man/3/fdopen)
-/
inductive FS.Mode where
  /--
  File opened for reading.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDONLY`
  * `fdopen` mode: `r`
  -/
  | read
  /--
  File opened for writing.
  On open, truncate an existing file to zero length or create a new file.
  The stream is positioned at the beginning of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC`
  * `fdopen` mode: `w`
  -/
  | write
  /--
  New file opened for writing.
  On open, create a new file with the stream positioned at the start.
  Errors if the file already exists.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC | O_EXCL`
  * `fdopen` mode: `w`
  -/
  | writeNew
  /--
  File opened for reading and writing.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDWR`
  * `fdopen` mode: `r+`
  -/
  | readWrite
  /--
  File opened for writing.
  On open, create a new file if it does not exist.
  The stream is positioned at the end of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_APPEND`
  * `fdopen` mode: `a`
  -/
  | append
goal: IO.FS.Mode

full_name: IO.FS.Mode.readWrite
code: /--
The mode of a file handle (i.e., a set of `open` flags and an `fdopen` mode).

All modes do not translate line endings (i.e., `O_BINARY` on Windows) and
are not inherited across process creation (i.e., `O_NOINHERIT` on Windows,
`O_CLOEXEC` elsewhere).

**References:**
* Windows:
  [`_open`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-170),
  [`_fdopen`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fdopen-wfdopen?view=msvc-170)
* Linux:
  [`open`](https://linux.die.net/man/2/open),
  [`fdopen`](https://linux.die.net/man/3/fdopen)
-/
inductive FS.Mode where
  /--
  File opened for reading.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDONLY`
  * `fdopen` mode: `r`
  -/
  | read
  /--
  File opened for writing.
  On open, truncate an existing file to zero length or create a new file.
  The stream is positioned at the beginning of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC`
  * `fdopen` mode: `w`
  -/
  | write
  /--
  New file opened for writing.
  On open, create a new file with the stream positioned at the start.
  Errors if the file already exists.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC | O_EXCL`
  * `fdopen` mode: `w`
  -/
  | writeNew
  /--
  File opened for reading and writing.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDWR`
  * `fdopen` mode: `r+`
  -/
  | readWrite
  /--
  File opened for writing.
  On open, create a new file if it does not exist.
  The stream is positioned at the end of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_APPEND`
  * `fdopen` mode: `a`
  -/
  | append
goal: IO.FS.Mode

full_name: IO.FS.Mode
code: /--
The mode of a file handle (i.e., a set of `open` flags and an `fdopen` mode).

All modes do not translate line endings (i.e., `O_BINARY` on Windows) and
are not inherited across process creation (i.e., `O_NOINHERIT` on Windows,
`O_CLOEXEC` elsewhere).

**References:**
* Windows:
  [`_open`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-170),
  [`_fdopen`](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fdopen-wfdopen?view=msvc-170)
* Linux:
  [`open`](https://linux.die.net/man/2/open),
  [`fdopen`](https://linux.die.net/man/3/fdopen)
-/
inductive FS.Mode where
  /--
  File opened for reading.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDONLY`
  * `fdopen` mode: `r`
  -/
  | read
  /--
  File opened for writing.
  On open, truncate an existing file to zero length or create a new file.
  The stream is positioned at the beginning of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC`
  * `fdopen` mode: `w`
  -/
  | write
  /--
  New file opened for writing.
  On open, create a new file with the stream positioned at the start.
  Errors if the file already exists.

  * `open` flags: `O_WRONLY | O_CREAT | O_TRUNC | O_EXCL`
  * `fdopen` mode: `w`
  -/
  | writeNew
  /--
  File opened for reading and writing.
  On open, the stream is positioned at the beginning of the file.
  Errors if the file does not exist.

  * `open` flags: `O_RDWR`
  * `fdopen` mode: `r+`
  -/
  | readWrite
  /--
  File opened for writing.
  On open, create a new file if it does not exist.
  The stream is positioned at the end of the file.

  * `open` flags: `O_WRONLY | O_CREAT | O_APPEND`
  * `fdopen` mode: `a`
  -/
  | append
goal: Type

full_name: IO.FS.Handle
code: opaque FS.Handle : Type 
goal: Type

full_name: IO.FS.Stream.write
code: /--
  A pure-Lean abstraction of POSIX streams. We use `Stream`s for the standard streams stdin/stdout/stderr so we can
  capture output of `#eval` commands into memory. -/
structure FS.Stream where
  flush   : IO Unit
  /--
Read up to the given number of bytes from the stream.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  read    : USize → IO ByteArray
  write   : ByteArray → IO Unit
  /--
Read text up to (including) the next line break from the stream.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  getLine : IO String
  putStr  : String → IO Unit
  /-- Returns true if a stream refers to a Windows console or Unix terminal. -/
  isTty   : BaseIO Bool
  deriving Inhabited
goal: ByteArray → IO Unit

full_name: IO.FS.Stream.getLine
code: /--
  A pure-Lean abstraction of POSIX streams. We use `Stream`s for the standard streams stdin/stdout/stderr so we can
  capture output of `#eval` commands into memory. -/
structure FS.Stream where
  flush   : IO Unit
  /--
Read up to the given number of bytes from the stream.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  read    : USize → IO ByteArray
  write   : ByteArray → IO Unit
  /--
Read text up to (including) the next line break from the stream.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  getLine : IO String
  putStr  : String → IO Unit
  /-- Returns true if a stream refers to a Windows console or Unix terminal. -/
  isTty   : BaseIO Bool
  deriving Inhabited
goal: IO String

full_name: IO.FS.Stream.putStr
code: /--
  A pure-Lean abstraction of POSIX streams. We use `Stream`s for the standard streams stdin/stdout/stderr so we can
  capture output of `#eval` commands into memory. -/
structure FS.Stream where
  flush   : IO Unit
  /--
Read up to the given number of bytes from the stream.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  read    : USize → IO ByteArray
  write   : ByteArray → IO Unit
  /--
Read text up to (including) the next line break from the stream.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  getLine : IO String
  putStr  : String → IO Unit
  /-- Returns true if a stream refers to a Windows console or Unix terminal. -/
  isTty   : BaseIO Bool
  deriving Inhabited
goal: String → IO Unit

full_name: IO.FS.Stream.flush
code: /--
  A pure-Lean abstraction of POSIX streams. We use `Stream`s for the standard streams stdin/stdout/stderr so we can
  capture output of `#eval` commands into memory. -/
structure FS.Stream where
  flush   : IO Unit
  /--
Read up to the given number of bytes from the stream.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  read    : USize → IO ByteArray
  write   : ByteArray → IO Unit
  /--
Read text up to (including) the next line break from the stream.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  getLine : IO String
  putStr  : String → IO Unit
  /-- Returns true if a stream refers to a Windows console or Unix terminal. -/
  isTty   : BaseIO Bool
  deriving Inhabited
goal: IO Unit

full_name: IO.FS.Stream.read
code: /--
  A pure-Lean abstraction of POSIX streams. We use `Stream`s for the standard streams stdin/stdout/stderr so we can
  capture output of `#eval` commands into memory. -/
structure FS.Stream where
  flush   : IO Unit
  /--
Read up to the given number of bytes from the stream.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  read    : USize → IO ByteArray
  write   : ByteArray → IO Unit
  /--
Read text up to (including) the next line break from the stream.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  getLine : IO String
  putStr  : String → IO Unit
  /-- Returns true if a stream refers to a Windows console or Unix terminal. -/
  isTty   : BaseIO Bool
  deriving Inhabited
goal: USize → IO ByteArray

full_name: IO.FS.Stream
code: /--
  A pure-Lean abstraction of POSIX streams. We use `Stream`s for the standard streams stdin/stdout/stderr so we can
  capture output of `#eval` commands into memory. -/
structure FS.Stream where
  flush   : IO Unit
  /--
Read up to the given number of bytes from the stream.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  read    : USize → IO ByteArray
  write   : ByteArray → IO Unit
  /--
Read text up to (including) the next line break from the stream.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  getLine : IO String
  putStr  : String → IO Unit
  /-- Returns true if a stream refers to a Windows console or Unix terminal. -/
  isTty   : BaseIO Bool
  deriving Inhabited
goal: Type

full_name: IO.FS.instInhabitedStream
code: /--
  A pure-Lean abstraction of POSIX streams. We use `Stream`s for the standard streams stdin/stdout/stderr so we can
  capture output of `#eval` commands into memory. -/
structure FS.Stream where
  flush   : IO Unit
  /--
Read up to the given number of bytes from the stream.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  read    : USize → IO ByteArray
  write   : ByteArray → IO Unit
  /--
Read text up to (including) the next line break from the stream.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  getLine : IO String
  putStr  : String → IO Unit
  /-- Returns true if a stream refers to a Windows console or Unix terminal. -/
  isTty   : BaseIO Bool
  deriving Inhabited
goal: Inhabited IO.FS.Stream

full_name: IO.FS.Stream.isTty
code: /--
  A pure-Lean abstraction of POSIX streams. We use `Stream`s for the standard streams stdin/stdout/stderr so we can
  capture output of `#eval` commands into memory. -/
structure FS.Stream where
  flush   : IO Unit
  /--
Read up to the given number of bytes from the stream.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  read    : USize → IO ByteArray
  write   : ByteArray → IO Unit
  /--
Read text up to (including) the next line break from the stream.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a stream, so further reads may block and return more data.
  -/
  getLine : IO String
  putStr  : String → IO Unit
  /-- Returns true if a stream refers to a Windows console or Unix terminal. -/
  isTty   : BaseIO Bool
  deriving Inhabited
goal: BaseIO Bool

full_name: IO.getStdin
code: @[extern "lean_get_stdin"] opaque getStdin  : BaseIO FS.Stream
goal: BaseIO IO.FS.Stream

full_name: IO.getStdout
code: @[extern "lean_get_stdout"] opaque getStdout : BaseIO FS.Stream
goal: BaseIO IO.FS.Stream

full_name: IO.getStderr
code: @[extern "lean_get_stderr"] opaque getStderr : BaseIO FS.Stream
goal: BaseIO IO.FS.Stream

full_name: IO.setStdin
code: /-- Replaces the stdin stream of the current thread and returns its previous value. -/
@[extern "lean_get_set_stdin"] opaque setStdin  : FS.Stream → BaseIO FS.Stream
goal: IO.FS.Stream → BaseIO IO.FS.Stream

full_name: IO.setStdout
code: /-- Replaces the stdout stream of the current thread and returns its previous value. -/
@[extern "lean_get_set_stdout"] opaque setStdout : FS.Stream → BaseIO FS.Stream
goal: IO.FS.Stream → BaseIO IO.FS.Stream

full_name: IO.setStderr
code: /-- Replaces the stderr stream of the current thread and returns its previous value. -/
@[extern "lean_get_set_stderr"] opaque setStderr : FS.Stream → BaseIO FS.Stream
goal: IO.FS.Stream → BaseIO IO.FS.Stream

full_name: IO.iterate
code: @[specialize] partial def iterate (a : α) (f : α → IO (Sum α β)) : IO β 
goal: IO β

full_name: IO.FS.Handle.mk
code: @[extern "lean_io_prim_handle_mk"] opaque mk (fn : @& FilePath) (mode : FS.Mode) : IO Handle
goal: IO IO.FS.Handle

full_name: IO.FS.Handle.lock
code: /--
Acquires an exclusive or shared lock on the handle.
Will block to wait for the lock if necessary.

**NOTE:** Acquiring a exclusive lock while already possessing a shared lock
will NOT reliably succeed (i.e., it works on Unix but not on Windows).
-/
@[extern "lean_io_prim_handle_lock"] opaque lock (h : @& Handle) (exclusive := true) : IO Unit
goal: IO Unit

full_name: IO.FS.Handle.tryLock
code: /--
Tries to acquire an exclusive or shared lock on the handle.
Will NOT block for the lock, but instead return `false`.

**NOTE:** Acquiring a exclusive lock while already possessing a shared lock
will NOT reliably succeed (i.e., it works on Unix but not on Windows).
-/
@[extern "lean_io_prim_handle_try_lock"] opaque tryLock (h : @& Handle) (exclusive := true) : IO Bool
goal: IO Bool

full_name: IO.FS.Handle.unlock
code: /--
Releases any previously acquired lock on the handle.
Will succeed even if no lock has been acquired.
-/
@[extern "lean_io_prim_handle_unlock"] opaque unlock (h : @& Handle) : IO Unit
goal: IO Unit

full_name: IO.FS.Handle.isTty
code: /-- Returns true if a handle refers to a Windows console or Unix terminal. -/
@[extern "lean_io_prim_handle_is_tty"] opaque isTty (h : @& Handle) : BaseIO Bool
goal: BaseIO Bool

full_name: IO.FS.Handle.flush
code: @[extern "lean_io_prim_handle_flush"] opaque flush (h : @& Handle) : IO Unit
goal: IO Unit

full_name: IO.FS.Handle.rewind
code: /-- Rewinds the read/write cursor to the beginning of the handle. -/
@[extern "lean_io_prim_handle_rewind"] opaque rewind (h : @& Handle) : IO Unit
goal: IO Unit

full_name: IO.FS.Handle.truncate
code: /--
Truncates the handle to the read/write cursor.

Does not automatically flush. Usually this is fine because the read/write
cursor includes buffered writes. However, the combination of buffered writes,
then `rewind`, then `truncate`, then close may lead to a file with content.
If unsure, flush before truncating.
-/
@[extern "lean_io_prim_handle_truncate"] opaque truncate (h : @& Handle) : IO Unit
goal: IO Unit

full_name: IO.FS.Handle.read
code: /--
Read up to the given number of bytes from the handle.
If the returned array is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a handle, so further reads may block and return more data.
-/
@[extern "lean_io_prim_handle_read"] opaque read (h : @& Handle) (bytes : USize) : IO ByteArray
goal: IO ByteArray

full_name: IO.FS.Handle.write
code: @[extern "lean_io_prim_handle_write"] opaque write (h : @& Handle) (buffer : @& ByteArray) : IO Unit
goal: IO Unit

full_name: IO.FS.Handle.getLine
code: /--
Read text up to (including) the next line break from the handle.
If the returned string is empty, an end-of-file marker has been reached.
Note that EOF does not actually close a handle, so further reads may block and return more data.
-/
@[extern "lean_io_prim_handle_get_line"] opaque getLine (h : @& Handle) : IO String
goal: IO String

full_name: IO.FS.Handle.putStr
code: @[extern "lean_io_prim_handle_put_str"] opaque putStr (h : @& Handle) (s : @& String) : IO Unit
goal: IO Unit

full_name: IO.FS.realPath
code: @[extern "lean_io_realpath"] opaque realPath (fname : FilePath) : IO FilePath
goal: IO System.FilePath

full_name: IO.FS.removeFile
code: @[extern "lean_io_remove_file"] opaque removeFile (fname : @& FilePath) : IO Unit
goal: IO Unit

full_name: IO.FS.removeDir
code: /-- Remove given directory. Fails if not empty; see also `IO.FS.removeDirAll`. -/
@[extern "lean_io_remove_dir"] opaque removeDir : @& FilePath → IO Unit
goal: System.FilePath → IO Unit

full_name: IO.FS.createDir
code: @[extern "lean_io_create_dir"] opaque createDir : @& FilePath → IO Unit
goal: System.FilePath → IO Unit

full_name: IO.FS.rename
code: /--
Moves a file or directory `old` to the new location `new`.

This function coincides with the [POSIX `rename` function](https://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html),
see there for more information.
-/
@[extern "lean_io_rename"] opaque rename (old new : @& FilePath) : IO Unit
goal: IO Unit

full_name: IO.getEnv
code: @[extern "lean_io_getenv"] opaque getEnv (var : @& String) : BaseIO (Option String)
goal: BaseIO (Option String)

full_name: IO.appPath
code: @[extern "lean_io_app_path"] opaque appPath : IO FilePath
goal: IO System.FilePath

full_name: IO.currentDir
code: @[extern "lean_io_current_dir"] opaque currentDir : IO FilePath
goal: IO System.FilePath

full_name: IO.FS.withFile
code: @[inline]
def withFile (fn : FilePath) (mode : Mode) (f : Handle → IO α) : IO α 
goal: IO α

full_name: IO.FS.Handle.putStrLn
code: def Handle.putStrLn (h : Handle) (s : String) : IO Unit 
goal: IO Unit

full_name: IO.FS.Handle.readBinToEnd.loop
code: partial def Handle.readBinToEnd (h : Handle) : IO ByteArray 
goal: IO ByteArray

full_name: IO.FS.Handle.readBinToEnd
code: partial def Handle.readBinToEnd (h : Handle) : IO ByteArray 
goal: IO ByteArray

full_name: IO.FS.Handle.readToEnd
code: partial def Handle.readToEnd (h : Handle) : IO String 
goal: IO String

full_name: IO.FS.Handle.readToEnd.loop
code: partial def Handle.readToEnd (h : Handle) : IO String 
goal: IO String

full_name: IO.FS.readBinFile
code: def readBinFile (fname : FilePath) : IO ByteArray 
goal: IO ByteArray

full_name: IO.FS.readFile
code: def readFile (fname : FilePath) : IO String 
goal: IO String

full_name: IO.FS.lines
code: partial def lines (fname : FilePath) : IO (Array String) 
goal: IO (Array String)

full_name: IO.FS.lines.read
code: partial def lines (fname : FilePath) : IO (Array String) 
goal: IO (Array String)

full_name: IO.FS.writeBinFile
code: def writeBinFile (fname : FilePath) (content : ByteArray) : IO Unit 
goal: IO Unit

full_name: IO.FS.writeFile
code: def writeFile (fname : FilePath) (content : String) : IO Unit 
goal: IO Unit

full_name: IO.FS.Stream.putStrLn
code: def Stream.putStrLn (strm : FS.Stream) (s : String) : IO Unit 
goal: IO Unit

full_name: IO.FS.instReprDirEntry
code: structure DirEntry where
  root     : FilePath
  fileName : String
  deriving Repr
goal: Repr IO.FS.DirEntry

full_name: IO.FS.DirEntry.fileName
code: structure DirEntry where
  root     : FilePath
  fileName : String
  deriving Repr
goal: String

full_name: IO.FS.DirEntry
code: structure DirEntry where
  root     : FilePath
  fileName : String
  deriving Repr
goal: Type

full_name: IO.FS.DirEntry.root
code: structure DirEntry where
  root     : FilePath
  fileName : String
  deriving Repr
goal: System.FilePath

full_name: IO.FS.DirEntry.path
code: def DirEntry.path (entry : DirEntry) : FilePath 
goal: System.FilePath

full_name: IO.FS.FileType
code: inductive FileType where
  | dir
  | file
  | symlink
  | other
  deriving Repr, BEq
goal: Type

full_name: IO.FS.instReprFileType
code: inductive FileType where
  | dir
  | file
  | symlink
  | other
  deriving Repr, BEq
goal: Repr IO.FS.FileType

full_name: IO.FS.FileType.symlink
code: inductive FileType where
  | dir
  | file
  | symlink
  | other
  deriving Repr, BEq
goal: IO.FS.FileType

full_name: IO.FS.FileType.file
code: inductive FileType where
  | dir
  | file
  | symlink
  | other
  deriving Repr, BEq
goal: IO.FS.FileType

full_name: IO.FS.FileType.dir
code: inductive FileType where
  | dir
  | file
  | symlink
  | other
  deriving Repr, BEq
goal: IO.FS.FileType

full_name: IO.FS.FileType.other
code: inductive FileType where
  | dir
  | file
  | symlink
  | other
  deriving Repr, BEq
goal: IO.FS.FileType

full_name: IO.FS.instBEqFileType
code: BEq
goal: BEq IO.FS.FileType

full_name: IO.FS.instBEqSystemTime
code: structure SystemTime where
  sec  : Int
  nsec : UInt32
  deriving Repr, BEq, Ord, Inhabited
goal: BEq IO.FS.SystemTime

full_name: IO.FS.instReprSystemTime
code: structure SystemTime where
  sec  : Int
  nsec : UInt32
  deriving Repr, BEq, Ord, Inhabited
goal: Repr IO.FS.SystemTime

full_name: IO.FS.SystemTime.nsec
code: structure SystemTime where
  sec  : Int
  nsec : UInt32
  deriving Repr, BEq, Ord, Inhabited
goal: UInt32

full_name: IO.FS.SystemTime.sec
code: structure SystemTime where
  sec  : Int
  nsec : UInt32
  deriving Repr, BEq, Ord, Inhabited
goal: Int

full_name: IO.FS.SystemTime
code: structure SystemTime where
  sec  : Int
  nsec : UInt32
  deriving Repr, BEq, Ord, Inhabited
goal: Type

full_name: IO.FS.instInhabitedSystemTime
code: structure SystemTime where
  sec  : Int
  nsec : UInt32
  deriving Repr, BEq, Ord, Inhabited
goal: Inhabited IO.FS.SystemTime

full_name: IO.FS.instOrdSystemTime
code: structure SystemTime where
  sec  : Int
  nsec : UInt32
  deriving Repr, BEq, Ord, Inhabited
goal: Ord IO.FS.SystemTime

full_name: IO.FS.instLTSystemTime
code: instance : LT SystemTime 
goal: LT IO.FS.SystemTime

full_name: IO.FS.instLESystemTime
code: instance : LE SystemTime 
goal: LE IO.FS.SystemTime

full_name: IO.FS.Metadata.byteSize
code: structure Metadata where
  --permissions : ...
  accessed : SystemTime
  modified : SystemTime
  byteSize : UInt64
  type     : FileType
  deriving Repr
goal: UInt64

full_name: IO.FS.instReprMetadata
code: structure Metadata where
  --permissions : ...
  accessed : SystemTime
  modified : SystemTime
  byteSize : UInt64
  type     : FileType
  deriving Repr
goal: Repr IO.FS.Metadata

full_name: IO.FS.Metadata.type
code: structure Metadata where
  --permissions : ...
  accessed : SystemTime
  modified : SystemTime
  byteSize : UInt64
  type     : FileType
  deriving Repr
goal: IO.FS.FileType

full_name: IO.FS.Metadata.modified
code: structure Metadata where
  --permissions : ...
  accessed : SystemTime
  modified : SystemTime
  byteSize : UInt64
  type     : FileType
  deriving Repr
goal: IO.FS.SystemTime

full_name: IO.FS.Metadata
code: structure Metadata where
  --permissions : ...
  accessed : SystemTime
  modified : SystemTime
  byteSize : UInt64
  type     : FileType
  deriving Repr
goal: Type

full_name: IO.FS.Metadata.accessed
code: structure Metadata where
  --permissions : ...
  accessed : SystemTime
  modified : SystemTime
  byteSize : UInt64
  type     : FileType
  deriving Repr
goal: IO.FS.SystemTime

full_name: System.FilePath.readDir
code: @[extern "lean_io_read_dir"]
opaque readDir : @& FilePath → IO (Array IO.FS.DirEntry)
goal: System.FilePath → IO (Array IO.FS.DirEntry)

full_name: System.FilePath.metadata
code: @[extern "lean_io_metadata"]
opaque metadata : @& FilePath → IO IO.FS.Metadata
goal: System.FilePath → IO IO.FS.Metadata

full_name: System.FilePath.isDir
code: def isDir (p : FilePath) : BaseIO Bool 
goal: BaseIO Bool

full_name: System.FilePath.pathExists
code: def pathExists (p : FilePath) : BaseIO Bool 
goal: BaseIO Bool

full_name: System.FilePath.walkDir
code: /--
  Return all filesystem entries of a preorder traversal of all directories satisfying `enter`, starting at `p`.
  Symbolic links are visited as well by default. -/
partial def walkDir (p : FilePath) (enter : FilePath → IO Bool := fun _ => pure true) : IO (Array FilePath) 
goal: IO (Array System.FilePath)

full_name: System.FilePath.walkDir.go
code: /--
  Return all filesystem entries of a preorder traversal of all directories satisfying `enter`, starting at `p`.
  Symbolic links are visited as well by default. -/
partial def walkDir (p : FilePath) (enter : FilePath → IO Bool := fun _ => pure true) : IO (Array FilePath) 
goal: StateT (Array System.FilePath) IO Unit

full_name: IO.withStdin
code: def withStdin [Monad m] [MonadFinally m] [MonadLiftT BaseIO m] (h : FS.Stream) (x : m α) : m α 
goal: m α

full_name: IO.withStdout
code: def withStdout [Monad m] [MonadFinally m] [MonadLiftT BaseIO m] (h : FS.Stream) (x : m α) : m α 
goal: m α

full_name: IO.withStderr
code: def withStderr [Monad m] [MonadFinally m] [MonadLiftT BaseIO m] (h : FS.Stream) (x : m α) : m α 
goal: m α

full_name: IO.print
code: def print [ToString α] (s : α) : IO Unit 
goal: IO Unit

full_name: IO.println
code: def println [ToString α] (s : α) : IO Unit 
goal: IO Unit

full_name: IO.eprint
code: def eprint [ToString α] (s : α) : IO Unit 
goal: IO Unit

full_name: IO.eprintln
code: def eprintln [ToString α] (s : α) : IO Unit 
goal: IO Unit

full_name: _private.«.lake».packages.lean4.src.lean.Init.System.IO.0.IO.eprintAux
code: @[export lean_io_eprint]
private def eprintAux (s : String) : IO Unit 
goal: IO Unit

full_name: _private.«.lake».packages.lean4.src.lean.Init.System.IO.0.IO.eprintlnAux
code: @[export lean_io_eprintln]
private def eprintlnAux (s : String) : IO Unit 
goal: IO Unit

full_name: IO.appDir
code: def appDir : IO FilePath 
goal: IO System.FilePath

full_name: IO.FS.createDirAll
code: /-- Create given path and all missing parents as directories. -/
partial def FS.createDirAll (p : FilePath) : IO Unit 
goal: IO Unit

full_name: IO.FS.removeDirAll
code: /--
  Fully remove given directory by deleting all contained files and directories in an unspecified order.
  Fails if any contained entry cannot be deleted or was newly created during execution. -/
partial def FS.removeDirAll (p : FilePath) : IO Unit 
goal: IO Unit

full_name: IO.Process.getCurrentDir
code: /-- Returns the current working directory of the calling process. -/
@[extern "lean_io_process_get_current_dir"] opaque getCurrentDir : IO FilePath
goal: IO System.FilePath

full_name: IO.Process.setCurrentDir
code: /-- Sets the current working directory of the calling process. -/
@[extern "lean_io_process_set_current_dir"] opaque setCurrentDir (path : @& FilePath) : IO Unit
goal: IO Unit

full_name: IO.Process.getPID
code: /-- Returns the process ID of the calling process. -/
@[extern "lean_io_process_get_pid"] opaque getPID : BaseIO UInt32
goal: BaseIO UInt32

full_name: IO.Process.Stdio.piped
code: inductive Stdio where
  | piped
  | inherit
  | null
goal: IO.Process.Stdio

full_name: IO.Process.Stdio.null
code: inductive Stdio where
  | piped
  | inherit
  | null
goal: IO.Process.Stdio

full_name: IO.Process.Stdio.inherit
code: inductive Stdio where
  | piped
  | inherit
  | null
goal: IO.Process.Stdio

full_name: IO.Process.Stdio
code: inductive Stdio where
  | piped
  | inherit
  | null
goal: Type

full_name: IO.Process.Stdio.toHandleType
code: def Stdio.toHandleType : Stdio → Type
  
goal: IO.Process.Stdio → Type

full_name: IO.Process.StdioConfig.stdin
code: structure StdioConfig where
  /-- Configuration for the process' stdin handle. -/
  stdin := Stdio.inherit
  /-- Configuration for the process' stdout handle. -/
  stdout := Stdio.inherit
  /-- Configuration for the process' stderr handle. -/
  stderr := Stdio.inherit
goal: IO.Process.Stdio

full_name: IO.Process.StdioConfig.stderr
code: structure StdioConfig where
  /-- Configuration for the process' stdin handle. -/
  stdin := Stdio.inherit
  /-- Configuration for the process' stdout handle. -/
  stdout := Stdio.inherit
  /-- Configuration for the process' stderr handle. -/
  stderr := Stdio.inherit
goal: IO.Process.Stdio

full_name: IO.Process.StdioConfig
code: structure StdioConfig where
  /-- Configuration for the process' stdin handle. -/
  stdin := Stdio.inherit
  /-- Configuration for the process' stdout handle. -/
  stdout := Stdio.inherit
  /-- Configuration for the process' stderr handle. -/
  stderr := Stdio.inherit
goal: Type

full_name: IO.Process.StdioConfig.stdout
code: structure StdioConfig where
  /-- Configuration for the process' stdin handle. -/
  stdin := Stdio.inherit
  /-- Configuration for the process' stdout handle. -/
  stdout := Stdio.inherit
  /-- Configuration for the process' stderr handle. -/
  stderr := Stdio.inherit
goal: IO.Process.Stdio

full_name: IO.Process.SpawnArgs.setsid
code: structure SpawnArgs extends StdioConfig where
  /-- Command name. -/
  cmd : String
  /-- Arguments for the process -/
  args : Array String := #[]
  /-- Working directory for the process. Inherit from current process if `none`. -/
  cwd : Option FilePath := none
  /-- Add or remove environment variables for the process. -/
  env : Array (String × Option String) := #[]
  /-- Start process in new session and process group using `setsid`. Currently a no-op on non-POSIX platforms. -/
  setsid : Bool := false
goal: Bool

full_name: IO.Process.SpawnArgs.cwd
code: structure SpawnArgs extends StdioConfig where
  /-- Command name. -/
  cmd : String
  /-- Arguments for the process -/
  args : Array String := #[]
  /-- Working directory for the process. Inherit from current process if `none`. -/
  cwd : Option FilePath := none
  /-- Add or remove environment variables for the process. -/
  env : Array (String × Option String) := #[]
  /-- Start process in new session and process group using `setsid`. Currently a no-op on non-POSIX platforms. -/
  setsid : Bool := false
goal: Option System.FilePath

full_name: IO.Process.SpawnArgs.env
code: structure SpawnArgs extends StdioConfig where
  /-- Command name. -/
  cmd : String
  /-- Arguments for the process -/
  args : Array String := #[]
  /-- Working directory for the process. Inherit from current process if `none`. -/
  cwd : Option FilePath := none
  /-- Add or remove environment variables for the process. -/
  env : Array (String × Option String) := #[]
  /-- Start process in new session and process group using `setsid`. Currently a no-op on non-POSIX platforms. -/
  setsid : Bool := false
goal: Array (String × Option String)

full_name: IO.Process.SpawnArgs
code: structure SpawnArgs extends StdioConfig where
  /-- Command name. -/
  cmd : String
  /-- Arguments for the process -/
  args : Array String := #[]
  /-- Working directory for the process. Inherit from current process if `none`. -/
  cwd : Option FilePath := none
  /-- Add or remove environment variables for the process. -/
  env : Array (String × Option String) := #[]
  /-- Start process in new session and process group using `setsid`. Currently a no-op on non-POSIX platforms. -/
  setsid : Bool := false
goal: Type

full_name: IO.Process.SpawnArgs.args
code: structure SpawnArgs extends StdioConfig where
  /-- Command name. -/
  cmd : String
  /-- Arguments for the process -/
  args : Array String := #[]
  /-- Working directory for the process. Inherit from current process if `none`. -/
  cwd : Option FilePath := none
  /-- Add or remove environment variables for the process. -/
  env : Array (String × Option String) := #[]
  /-- Start process in new session and process group using `setsid`. Currently a no-op on non-POSIX platforms. -/
  setsid : Bool := false
goal: Array String

full_name: IO.Process.SpawnArgs.cmd
code: structure SpawnArgs extends StdioConfig where
  /-- Command name. -/
  cmd : String
  /-- Arguments for the process -/
  args : Array String := #[]
  /-- Working directory for the process. Inherit from current process if `none`. -/
  cwd : Option FilePath := none
  /-- Add or remove environment variables for the process. -/
  env : Array (String × Option String) := #[]
  /-- Start process in new session and process group using `setsid`. Currently a no-op on non-POSIX platforms. -/
  setsid : Bool := false
goal: String

full_name: IO.Process.Child.stdin
code: structure Child (cfg : StdioConfig) where
  stdin  : cfg.stdin.toHandleType
  stdout : cfg.stdout.toHandleType
  stderr : cfg.stderr.toHandleType
goal: cfg.stdin.toHandleType

full_name: IO.Process.Child.stderr
code: structure Child (cfg : StdioConfig) where
  stdin  : cfg.stdin.toHandleType
  stdout : cfg.stdout.toHandleType
  stderr : cfg.stderr.toHandleType
goal: cfg.stderr.toHandleType

full_name: IO.Process.Child
code: structure Child (cfg : StdioConfig) where
  stdin  : cfg.stdin.toHandleType
  stdout : cfg.stdout.toHandleType
  stderr : cfg.stderr.toHandleType
goal: Type

full_name: IO.Process.Child.stdout
code: structure Child (cfg : StdioConfig) where
  stdin  : cfg.stdin.toHandleType
  stdout : cfg.stdout.toHandleType
  stderr : cfg.stderr.toHandleType
goal: cfg.stdout.toHandleType

full_name: IO.Process.spawn
code: @[extern "lean_io_process_spawn"] opaque spawn (args : SpawnArgs) : IO (Child args.toStdioConfig)
goal: IO (IO.Process.Child args.toStdioConfig)

full_name: IO.Process.Child.wait
code: @[extern "lean_io_process_child_wait"] opaque Child.wait {cfg : @& StdioConfig} : @& Child cfg → IO UInt32
goal: IO.Process.Child cfg → IO UInt32

full_name: IO.Process.Child.kill
code: /-- Terminates the child process using the SIGTERM signal or a platform analogue.
    If the process was started using `SpawnArgs.setsid`, terminates the entire process group instead. -/
@[extern "lean_io_process_child_kill"] opaque Child.kill {cfg : @& StdioConfig} : @& Child cfg → IO Unit
goal: IO.Process.Child cfg → IO Unit

full_name: IO.Process.Child.takeStdin
code: /--
Extract the `stdin` field from a `Child` object, allowing them to be freed independently.
This operation is necessary for closing the child process' stdin while still holding on to a process handle,
e.g. for `Child.wait`. A file handle is closed when all references to it are dropped, which without this
operation includes the `Child` object.
-/
@[extern "lean_io_process_child_take_stdin"] opaque Child.takeStdin {cfg : @& StdioConfig} : Child cfg →
    IO (cfg.stdin.toHandleType × Child { cfg with stdin := Stdio.null })
goal: IO.Process.Child cfg →
  IO
    (cfg.stdin.toHandleType ×
      IO.Process.Child { stdin := IO.Process.Stdio.null, stdout := cfg.stdout, stderr := cfg.stderr })

full_name: IO.Process.Output.stdout
code: structure Output where
  exitCode : UInt32
  stdout   : String
  stderr   : String
goal: String

full_name: IO.Process.Output
code: structure Output where
  exitCode : UInt32
  stdout   : String
  stderr   : String
goal: Type

full_name: IO.Process.Output.stderr
code: structure Output where
  exitCode : UInt32
  stdout   : String
  stderr   : String
goal: String

full_name: IO.Process.Output.exitCode
code: structure Output where
  exitCode : UInt32
  stdout   : String
  stderr   : String
goal: UInt32

full_name: IO.Process.output
code: /--
Run process to completion and capture output.
The process does not inherit the standard input of the caller.
-/
def output (args : SpawnArgs) : IO Output 
goal: IO IO.Process.Output

full_name: IO.Process.run
code: /-- Run process to completion and return stdout on success. -/
def run (args : SpawnArgs) : IO String 
goal: IO String

full_name: IO.Process.exit
code: @[extern "lean_io_exit"] opaque exit : UInt8 → IO α
goal: UInt8 → IO α

full_name: IO.AccessRight.write
code: structure AccessRight where
  read : Bool := false
  write : Bool := false
  execution : Bool := false
goal: Bool

full_name: IO.AccessRight.read
code: structure AccessRight where
  read : Bool := false
  write : Bool := false
  execution : Bool := false
goal: Bool

full_name: IO.AccessRight
code: structure AccessRight where
  read : Bool := false
  write : Bool := false
  execution : Bool := false
goal: Type

full_name: IO.AccessRight.execution
code: structure AccessRight where
  read : Bool := false
  write : Bool := false
  execution : Bool := false
goal: Bool

full_name: IO.AccessRight.flags
code: def AccessRight.flags (acc : AccessRight) : UInt32 
goal: UInt32

full_name: IO.FileRight.user
code: structure FileRight where
  user  : AccessRight := {}
  group : AccessRight := {}
  other : AccessRight := {}
goal: IO.AccessRight

full_name: IO.FileRight.group
code: structure FileRight where
  user  : AccessRight := {}
  group : AccessRight := {}
  other : AccessRight := {}
goal: IO.AccessRight

full_name: IO.FileRight.other
code: structure FileRight where
  user  : AccessRight := {}
  group : AccessRight := {}
  other : AccessRight := {}
goal: IO.AccessRight

full_name: IO.FileRight
code: structure FileRight where
  user  : AccessRight := {}
  group : AccessRight := {}
  other : AccessRight := {}
goal: Type

full_name: IO.FileRight.flags
code: def FileRight.flags (acc : FileRight) : UInt32 
goal: UInt32

full_name: IO.Prim.setAccessRights
code: @[extern "lean_chmod"] opaque Prim.setAccessRights (filename : @& FilePath) (mode : UInt32) : IO Unit
goal: IO Unit

full_name: IO.setAccessRights
code: def setAccessRights (filename : FilePath) (mode : FileRight) : IO Unit 
goal: IO Unit

full_name: IO.Ref
code: /-- References -/
abbrev Ref (α : Type) 
goal: Type

full_name: IO.instMonadLiftSTRealWorldBaseIO
code: instance : MonadLift (ST IO.RealWorld) BaseIO 
goal: MonadLift (ST IO.RealWorld) BaseIO

full_name: IO.mkRef
code: def mkRef (a : α) : BaseIO (IO.Ref α) 
goal: BaseIO (IO.Ref α)

full_name: _private.«.lake».packages.lean4.src.lean.Init.System.IO.0.IO.CancelToken.ref
code: /--
Mutable cell that can be passed around for purposes of cooperative task cancellation: request
cancellation with `CancelToken.set` and check for it with `CancelToken.isSet`.

This is a more flexible alternative to `Task.cancel` as the token can be shared between multiple
tasks.
-/
structure CancelToken where
  private ref : IO.Ref Bool
goal: IO.Ref Bool

full_name: IO.CancelToken
code: /--
Mutable cell that can be passed around for purposes of cooperative task cancellation: request
cancellation with `CancelToken.set` and check for it with `CancelToken.isSet`.

This is a more flexible alternative to `Task.cancel` as the token can be shared between multiple
tasks.
-/
structure CancelToken where
  private ref : IO.Ref Bool
goal: Type

full_name: IO.CancelToken.new
code: /-- Creates a new cancellation token. -/
def new : BaseIO CancelToken 
goal: BaseIO IO.CancelToken

full_name: IO.CancelToken.set
code: /-- Activates a cancellation token. Idempotent. -/
def set (tk : CancelToken) : BaseIO Unit 
goal: BaseIO Unit

full_name: IO.CancelToken.isSet
code: /-- Checks whether the cancellation token has been activated. -/
def isSet (tk : CancelToken) : BaseIO Bool 
goal: BaseIO Bool

full_name: _private.«.lake».packages.lean4.src.lean.Init.System.IO.0.IO.CancelToken.isSetExport
code: @[export lean_io_cancel_token_is_set]
private def isSetExport 
goal: BaseIO Bool

full_name: IO.FS.Stream.ofHandle
code: @[export lean_stream_of_handle]
def ofHandle (h : Handle) : Stream 
goal: IO.FS.Stream

full_name: IO.FS.Stream.Buffer.pos
code: structure Buffer where
  data : ByteArray := ByteArray.empty
  pos  : Nat := 0
goal: Nat

full_name: IO.FS.Stream.Buffer.data
code: structure Buffer where
  data : ByteArray := ByteArray.empty
  pos  : Nat := 0
goal: ByteArray

full_name: IO.FS.Stream.Buffer
code: structure Buffer where
  data : ByteArray := ByteArray.empty
  pos  : Nat := 0
goal: Type

full_name: IO.FS.Stream.ofBuffer
code: def ofBuffer (r : Ref Buffer) : Stream 
goal: IO.FS.Stream

full_name: IO.FS.withIsolatedStreams
code: /-- Run action with `stdin` emptied and `stdout+stderr` captured into a `String`. -/
def withIsolatedStreams [Monad m] [MonadFinally m] [MonadLiftT BaseIO m] (x : m α)
    (isolateStderr := true) : m (String × α) 
goal: m (String × α)

full_name: Lean.Eval
code: /-- Typeclass used for presenting the output of an `#eval` command. -/
class Eval (α : Type u) where
  -- We default `hideUnit` to `true`, but set it to `false` in the direct call from `#eval`
  -- so that `()` output is hidden in chained instances such as for some `IO Unit`.
  -- We take `Unit → α` instead of `α` because ‵α` may contain effectful debugging primitives (e.g., `dbg_trace`)
  eval : (Unit → α) → (hideUnit : Bool := true) → IO Unit
goal: Type u

full_name: Lean.Eval.eval
code: /-- Typeclass used for presenting the output of an `#eval` command. -/
class Eval (α : Type u) where
  -- We default `hideUnit` to `true`, but set it to `false` in the direct call from `#eval`
  -- so that `()` output is hidden in chained instances such as for some `IO Unit`.
  -- We take `Unit → α` instead of `α` because ‵α` may contain effectful debugging primitives (e.g., `dbg_trace`)
  eval : (Unit → α) → (hideUnit : Bool := true) → IO Unit
goal: (Unit → α) → optParam Bool true → IO Unit

full_name: Lean.instEval
code: instance instEval [ToString α] : Eval α 
goal: Lean.Eval α

full_name: Lean.instEvalOfRepr
code: instance [Repr α] : Eval α 
goal: Lean.Eval α

full_name: Lean.instEvalUnit
code: instance : Eval Unit 
goal: Lean.Eval Unit

full_name: Lean.instEvalIO
code: instance [Eval α] : Eval (IO α) 
goal: Lean.Eval (IO α)

full_name: Lean.instEvalBaseIO
code: instance [Eval α] : Eval (BaseIO α) 
goal: Lean.Eval (BaseIO α)

full_name: Lean.runEval
code: def runEval [Eval α] (a : Unit → α) : IO (String × Except IO.Error Unit) 
goal: IO (String × Except IO.Error Unit)

full_name: termPrintln!__
code: syntax "println! " (interpolatedStr(term) <|> term) : term
goal: Lean.ParserDescr

full_name: «_aux_.lake_packages_lean4_src_lean_Init_System_IO___macroRules_termPrintln!___1»
code: macro_rules
  | `(println! $msg:interpolatedStr) => `((IO.println (s! $msg) : IO Unit))
  | `(println! $msg:term)            => `((IO.println $msg : IO Unit))
goal: Lean.Macro