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
Equations
Equations
- instMonadEIO = inferInstanceAs (Monad (EStateM ε IO.RealWorld))
Equations
- instMonadFinallyEIO = inferInstanceAs (MonadFinally (EStateM ε IO.RealWorld))
Equations
- instMonadExceptOfEIO = inferInstanceAs (MonadExceptOf ε (EStateM ε IO.RealWorld))
Equations
- instOrElseEIO = { orElse := MonadExcept.orElse }
Equations
- instInhabitedEIO = inferInstanceAs (Inhabited (EStateM ε IO.RealWorld α))
Equations
Equations
Equations
- BaseIO.toEIO act s = match act s with | EStateM.Result.ok a s => EStateM.Result.ok a s
Equations
- EIO.toBaseIO act s = match act s with | EStateM.Result.ok a s => EStateM.Result.ok (Except.ok a) s | EStateM.Result.error ex s => EStateM.Result.ok (Except.error ex) s
Equations
- EIO.catchExceptions act h s = match act s with | EStateM.Result.ok a s => EStateM.Result.ok a s | EStateM.Result.error ex s => h ex s
Equations
- BaseIO.toIO act = liftM act
Equations
- unsafeBaseIO fn = match EStateM.run fn () with | EStateM.Result.ok a a_1 => a
Equations
- unsafeEIO fn = unsafeBaseIO (EIO.toBaseIO fn)
Run act
in a separate Task
.
This is similar to Haskell's 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.
See BaseIO.asTask
.
See BaseIO.asTask
.
Equations
- BaseIO.mapTasks f tasks prio = BaseIO.mapTasks.go f prio tasks []
Equations
- BaseIO.mapTasks.go f prio (t :: ts) _fun_discr = BaseIO.bindTask t (fun a => BaseIO.mapTasks.go f prio ts (a :: _fun_discr)) prio
- BaseIO.mapTasks.go f prio [] _fun_discr = BaseIO.asTask (f (List.reverse _fun_discr)) prio
EIO
specialization of BaseIO.asTask
.
Equations
- EIO.asTask act prio = BaseIO.asTask (EIO.toBaseIO act) prio
EIO
specialization of BaseIO.mapTask
.
Equations
- EIO.mapTask f t prio = BaseIO.mapTask (fun a => EIO.toBaseIO (f a)) t prio
EIO
specialization of BaseIO.bindTask
.
Equations
- EIO.bindTask t f prio = BaseIO.bindTask t (fun a => EIO.catchExceptions (f a) fun e => pure { get := Except.error e }) prio
EIO
specialization of BaseIO.mapTasks
.
Equations
- EIO.mapTasks f tasks prio = BaseIO.mapTasks (fun as => EIO.toBaseIO (f as)) tasks prio
Equations
- IO.ofExcept e = match e with | Except.ok a => pure a | Except.error e => throw (IO.userError (toString e))
Monotonically increasing time since an unspecified past point in milliseconds. No relation to wall clock time.
Monotonically increasing time since an unspecified past point in nanoseconds. No relation to wall clock time.
Read bytes from a system entropy source. Not guaranteed to be cryptographically secure.
If nBytes = 0
, return immediately with an empty buffer.
IO
specialization of EIO.asTask
.
Equations
- IO.asTask act prio = EIO.asTask act prio
IO
specialization of EIO.mapTask
.
Equations
- IO.mapTask f t prio = EIO.mapTask f t prio
IO
specialization of EIO.bindTask
.
Equations
- IO.bindTask t f prio = EIO.bindTask t f prio
IO
specialization of EIO.mapTasks
.
Equations
- IO.mapTasks f tasks prio = EIO.mapTasks f tasks prio
Check if the task's cancellation flag has been set by calling IO.cancel
or dropping the last reference to the task.
Wait until any of the tasks in the given list has finished, then return its result.
Helper method for implementing "deterministic" timeouts. It is the number of "small" memory allocations performed by the current execution thread.
- read: IO.FS.Mode
- write: IO.FS.Mode
- readWrite: IO.FS.Mode
- append: IO.FS.Mode
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.
Equations
- IO.FS.instInhabitedStream = { default := { isEof := default, flush := default, read := default, write := default, getLine := default, putStr := default } }
Replaces the stdin stream of the current thread and returns its previous value.
Replaces the stdout stream of the current thread and returns its previous value.
Replaces the stderr stream of the current thread and returns its previous value.
Equations
- IO.FS.Handle.mk fn Mode bin = IO.FS.Handle.mkPrim fn (IO.FS.Handle.fopenFlags Mode bin)
Remove given directory. Fails if not empty; see also IO.FS.removeDirAll
.
Equations
- IO.FS.withFile fn mode f = IO.FS.Handle.mk fn mode true >>= f
Equations
- IO.FS.Handle.putStrLn h s = IO.FS.Handle.putStr h (String.push s (Char.ofNat 10))
Equations
- IO.FS.Handle.readToEnd h = IO.FS.Handle.readToEnd.loop h ""
Equations
- IO.FS.readBinFile fname = do let h ← IO.FS.Handle.mk fname IO.FS.Mode.read true IO.FS.Handle.readBinToEnd h
Equations
- IO.FS.readFile fname = do let h ← IO.FS.Handle.mk fname IO.FS.Mode.read false IO.FS.Handle.readToEnd h
Equations
- IO.FS.lines fname = do let h ← IO.FS.Handle.mk fname IO.FS.Mode.read false IO.FS.lines.read h #[]
Equations
- IO.FS.writeBinFile fname content = do let h ← IO.FS.Handle.mk fname IO.FS.Mode.write true IO.FS.Handle.write h content
Equations
- IO.FS.writeFile fname content = do let h ← IO.FS.Handle.mk fname IO.FS.Mode.write false IO.FS.Handle.putStr h content
Equations
- IO.FS.Stream.putStrLn strm s = IO.FS.Stream.putStr strm (String.push s (Char.ofNat 10))
Equations
- IO.FS.instReprDirEntry = { reprPrec := [anonymous] }
Equations
- IO.FS.DirEntry.path entry = entry.root / { toString := entry.fileName }
- dir: IO.FS.FileType
- file: IO.FS.FileType
- symlink: IO.FS.FileType
- other: IO.FS.FileType
Equations
- IO.FS.instReprFileType = { reprPrec := [anonymous] }
Equations
- IO.FS.instBEqFileType = { beq := [anonymous] }
Equations
- IO.FS.instReprSystemTime = { reprPrec := [anonymous] }
Equations
- IO.FS.instBEqSystemTime = { beq := [anonymous] }
Equations
- IO.FS.instOrdSystemTime = { compare := [anonymous] }
Equations
- IO.FS.instInhabitedSystemTime = { default := { sec := default, nsec := default } }
- accessed : IO.FS.SystemTime
- modified : IO.FS.SystemTime
- byteSize : UInt64
- type : IO.FS.FileType
Equations
- IO.FS.instReprMetadata = { reprPrec := [anonymous] }
Equations
- System.FilePath.isDir p = do let a ← EIO.toBaseIO (System.FilePath.metadata p) match a with | Except.ok m => pure (m.type == IO.FS.FileType.dir) | Except.error a => pure false
Equations
- System.FilePath.pathExists p = do let a ← EIO.toBaseIO (System.FilePath.metadata p) pure (Except.toBool a)
Return all filesystem entries of a preorder traversal of all directories satisfying enter
, starting at p
.
Symbolic links are visited as well by default.
Equations
- System.FilePath.walkDir p enter = Prod.snd <$> StateT.run (System.FilePath.walkDir.go enter p) #[]
Equations
- IO.withStdin h x = do let prev ← liftM (IO.setStdin h) tryFinally x (discard (liftM (IO.setStdin prev)))
Equations
- IO.withStdout h x = do let prev ← liftM (IO.setStdout h) tryFinally x (discard (liftM (IO.setStdout prev)))
Equations
- IO.withStderr h x = do let prev ← liftM (IO.setStderr h) tryFinally x (discard (liftM (IO.setStderr prev)))
Equations
- IO.println s = IO.print (String.push (toString s) (Char.ofNat 10))
Equations
- IO.eprintln s = IO.eprint (String.push (toString s) (Char.ofNat 10))
Equations
- One or more equations did not get rendered due to their size.
Create given path and all missing parents as directories.
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.
- piped: IO.Process.Stdio
- inherit: IO.Process.Stdio
- null: IO.Process.Stdio
Equations
- IO.Process.Stdio.toHandleType _fun_discr = match _fun_discr with | IO.Process.Stdio.piped => IO.FS.Handle | IO.Process.Stdio.inherit => Unit | IO.Process.Stdio.null => Unit
- stdin : IO.Process.Stdio
- stdout : IO.Process.Stdio
- stderr : IO.Process.Stdio
- cmd : String
- cwd : Option System.FilePath
- stdin : IO.Process.Stdio.toHandleType cfg.stdin
- stdout : IO.Process.Stdio.toHandleType cfg.stdout
- stderr : IO.Process.Stdio.toHandleType cfg.stderr
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.
Run process to completion and capture output.
Equations
- One or more equations did not get rendered due to their size.
Run process to completion and return stdout on success.
Equations
- One or more equations did not get rendered due to their size.
Equations
- IO.AccessRight.flags acc = let r := if acc.read = true then 4 else 0; let w := if acc.write = true then 2 else 0; let x := if acc.execution = true then 1 else 0; UInt32.lor r (UInt32.lor w x)
Equations
- One or more equations did not get rendered due to their size.
Equations
- IO.setAccessRights filename mode = IO.Prim.setAccessRights filename (IO.FileRight.flags mode)
Equations
- IO.instMonadLiftSTRealWorldBaseIO = { monadLift := fun {α} => id }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Run action with stdin
emptied and stdout+stderr
captured into a String
.
Equations
- One or more equations did not get rendered due to their size.
Typeclass used for presenting the output of an #eval
command.
Equations
- Lean.instEval = { eval := fun a x => IO.println (toString (a ())) }
Equations
- Lean.instEval_1 = { eval := fun a x => IO.println (repr (a ())) }
Equations
- Lean.instEvalUnit = { eval := fun u hideUnit => if hideUnit = true then pure () else IO.println (repr (u ())) }
Equations
- Lean.instEvalIO = { eval := fun x x_1 => do let a ← x () Lean.Eval.eval (fun x => a) true }
Equations
Equations
- One or more equations did not get rendered due to their size.