Documentation

Hale.Base.System.IO

IO mode for opening files.

$$\text{IOMode} ::= \text{readMode} \mid \text{writeMode} \mid \text{appendMode} \mid \text{readWriteMode}$$

  • readMode : IOMode

    Open for reading.

  • writeMode : IOMode

    Open for writing (truncates existing content).

  • appendMode : IOMode

    Open for appending.

  • readWriteMode : IOMode

    Open for both reading and writing.

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[reducible, inline]

      Handle is an alias for Lean's IO.FS.Handle.

      $$\text{Handle} \triangleq \text{IO.FS.Handle}$$

      Equations
      Instances For

        Standard input stream.

        $$\text{stdin} : \text{IO}\ \text{IO.FS.Stream}$$

        Equations
        Instances For

          Standard output stream.

          $$\text{stdout} : \text{IO}\ \text{IO.FS.Stream}$$

          Equations
          Instances For

            Standard error stream.

            $$\text{stderr} : \text{IO}\ \text{IO.FS.Stream}$$

            Equations
            Instances For
              @[inline]

              Write a string to a handle.

              $$\text{hPutStr} : \text{Handle} \to \text{String} \to \text{IO}\ \text{Unit}$$

              Equations
              Instances For

                Write a string followed by a newline to a handle.

                $$\text{hPutStrLn} : \text{Handle} \to \text{String} \to \text{IO}\ \text{Unit}$$

                Equations
                Instances For
                  @[inline]

                  Read a line from a handle.

                  $$\text{hGetLine} : \text{Handle} \to \text{IO}\ \text{String}$$

                  Equations
                  Instances For
                    @[inline]

                    Flush a handle's output buffer.

                    $$\text{hFlush} : \text{Handle} \to \text{IO}\ \text{Unit}$$

                    Equations
                    Instances For
                      @[inline]

                      Read all remaining contents from a handle.

                      $$\text{hGetContents} : \text{Handle} \to \text{IO}\ \text{String}$$

                      Uses Lean's readToEnd which reads until EOF.

                      Equations
                      Instances For
                        def System.SysIO.withFile {α : Type} (path : FilePath) (mode : IOMode) (f : HandleIO α) :
                        IO α

                        Open a file with the given mode, use it via the callback, then return.

                        $$\text{withFile} : \text{FilePath} \to \text{IOMode} \to (\text{Handle} \to \text{IO}\ \alpha) \to \text{IO}\ \alpha$$

                        The handle is scoped to the callback f.

                        Equations
                        Instances For
                          @[inline]

                          Convenience: write a string to stdout.

                          $$\text{putStr} : \text{String} \to \text{IO}\ \text{Unit}$$

                          Equations
                          Instances For
                            @[inline]

                            Convenience: write a string with newline to stdout.

                            $$\text{putStrLn} : \text{String} \to \text{IO}\ \text{Unit}$$

                            Equations
                            Instances For

                              Convenience: read a line from stdin.

                              $$\text{getLine} : \text{IO}\ \text{String}$$

                              Equations
                              Instances For