Documentation

Lake.Build.Job.Monad

Job Monad #

This module contains additional definitions for Lake Job. In particular, it defines JobM, which uses BuildContext, which contains OpaqueJobs, hence the module split.

@[reducible, inline]
abbrev Lake.JobM (α : Type) :

The monad of asynchronous Lake jobs.

While this can be lifted into FetchM, job action should generally be wrapped into an asynchronous job (e.g., via Job.async) instead of being run directly in FetchM.

Instances For
    @[inline]

    Construct a FetchM monad from its full functional representation.

    Instances For
      @[inline]

      Convert a JobM monad to its full functional representation.

      Instances For
        @[implicit_reducible, instance 10000]
        @[implicit_reducible]
        @[implicit_reducible]
        @[implicit_reducible]
        @[implicit_reducible]
        @[inline]

        Record that this job is trying to perform some action.

        Instances For
          @[inline]

          Returns the current job's build trace.

          Instances For
            @[inline]

            Sets the current job's build trace.

            Instances For
              @[inline]
              def Lake.newTrace (caption : String := "<nil>") :

              Replace the job's build trace with a new empty trace.

              Instances For
                @[inline]

                Mutates the job's trace, applying f to it.

                Instances For
                  @[inline]

                  Set the caption of the job's build trace.

                  Instances For
                    @[inline]

                    Returns the current job's build trace and removes it from the state.

                    Instances For
                      @[inline]

                      Sets the current job's trace and returns the previous one.

                      Instances For
                        @[inline]

                        Mix a trace into the current job's build trace.

                        Instances For
                          @[inline]
                          def Lake.addSubTrace {α : Type} (caption : String) (x : JobM α) :
                          JobM α

                          Runs x with a new trace and then mixes it into the original trace.

                          Instances For
                            @[reducible, inline]
                            abbrev Lake.SpawnM (α : Type) :

                            The monad used to spawn asynchronous Lake build jobs. Lifts into FetchM.

                            Instances For
                              @[inline]

                              Construct a SpawnM monad from its full functional representation.

                              Instances For
                                @[inline]

                                Convert a SpawnM monad to its full functional representation.

                                Instances For
                                  @[inline]
                                  def Lake.JobM.runSpawnM {α : Type} (x : SpawnM α) :
                                  JobM α
                                  Instances For
                                    @[inline]
                                    def Lake.FetchM.runJobM {α : Type} (x : JobM α) :

                                    Run a JobM action in FetchM.

                                    Generally, this should not be done, and instead a job action should be run asynchronously in a Job (e.g., via Job.async).

                                    Instances For
                                      @[inline]
                                      def Lake.JobM.runFetchM {α : Type} (x : FetchM α) :
                                      JobM α

                                      Run a FetchM action in JobM.

                                      Instances For
                                        @[inline]
                                        def Lake.Job.bindTask {m : Type u_1 → Type u_2} {β : Type u_1} {α : Type u_3} [Monad m] [OptDataKind β] (f : JobTask αm (JobTask β)) (self : Job α) :
                                        m (Job β)
                                        Instances For
                                          def Lake.Job.sync {α : Type} [OptDataKind α] (act : JobM α) (caption : String := "") :
                                          SpawnM (Job α)

                                          Returns a job that has synchronously performed act.

                                          Instances For
                                            def Lake.Job.async {α : Type} [OptDataKind α] (act : JobM α) (prio : Task.Priority := Task.Priority.default) (caption : String := "") :
                                            SpawnM (Job α)

                                            Spawn a job that asynchronously performs act.

                                            Instances For
                                              @[inline]
                                              def Lake.Job.wait {α : Type} (self : Job α) :

                                              Wait for a job to complete and return the result.

                                              Instances For
                                                @[inline]
                                                def Lake.Job.wait? {α : Type} (self : Job α) :

                                                Wait for a job to complete and return the produced value. If an error occurred, return none and discarded any logs produced.

                                                Instances For
                                                  def Lake.Job.await {α : Type} (self : Job α) :

                                                  Wait for a job to complete and return the produced value. Logs the job's log and throws if there was an error.

                                                  Instances For
                                                    def Lake.Job.mapM {β : Type} {α : Type u_1} [kind : OptDataKind β] (self : Job α) (f : αJobM β) (prio : Task.Priority := Task.Priority.default) (sync : Bool := false) :
                                                    SpawnM (Job β)

                                                    Apply f asynchronously to the job's output.

                                                    Instances For
                                                      def Lake.Job.bindM {β : Type} {α : Type u_1} [kind : OptDataKind β] (self : Job α) (f : αJobM (Job β)) (prio : Task.Priority := Task.Priority.default) (sync : Bool := false) :
                                                      SpawnM (Job β)

                                                      Apply f asynchronously to the job's output and asynchronously await the resulting job.

                                                      Instances For
                                                        @[inline]
                                                        def Lake.Job.zipResultWith {γ : Type u_1} {α : Type u_2} {β : Type u_3} [OptDataKind γ] (f : JobResult αJobResult βJobResult γ) (self : Job α) (other : Job β) (prio : Task.Priority := Task.Priority.default) (sync : Bool := false) :
                                                        Job γ

                                                        a.zipWith f b produces a new job c that applies f to the results of a and b. The job c errors if either a or b error.

                                                        Instances For
                                                          @[inline]
                                                          def Lake.Job.zipWith {γ : Type u_1} {α : Type u_2} {β : Type u_3} [OptDataKind γ] (f : αβγ) (self : Job α) (other : Job β) (prio : Task.Priority := Task.Priority.default) (sync : Bool := false) :
                                                          Job γ

                                                          a.zipWith f b produces a new job c that applies f to the results of a and b. The job c errors if either a or b error.

                                                          Instances For
                                                            def Lake.Job.add {α : Type u_1} {β : Type u_2} (self : Job α) (other : Job β) :
                                                            Job α

                                                            Merges this job with another, discarding its output and trace.

                                                            Instances For
                                                              def Lake.Job.mix {α : Type u_1} {β : Type u_2} (self : Job α) (other : Job β) :

                                                              Merges this job with another, discarding both outputs.

                                                              Instances For
                                                                def Lake.Job.mixList {α : Type u_1} (jobs : List (Job α)) (traceCaption : String := "<collection>") :

                                                                Merge a List of jobs into one, discarding their outputs.

                                                                Instances For
                                                                  def Lake.Job.mixArray {α : Type u_1} (jobs : Array (Job α)) (traceCaption : String := "<collection>") :

                                                                  Merge an Array of jobs into one, discarding their outputs.

                                                                  Instances For
                                                                    def Lake.Job.collectList {α : Type u_1} (jobs : List (Job α)) (traceCaption : String := "<collection>") :
                                                                    Job (List α)

                                                                    Merge a List of jobs into one, collecting their outputs into a List.

                                                                    Instances For
                                                                      def Lake.Job.collectArray {α : Type u_1} (jobs : Array (Job α)) (traceCaption : String := "<collection>") :
                                                                      Job (Array α)

                                                                      Merge an Array of jobs into one, collecting their outputs into an Array.

                                                                      Instances For
                                                                        def Lake.Job.collectVector {n : Nat} {α : Type u} [Nonempty α] (jobs : Vector (Job α) n) (traceCaption : String := "<collection>") :
                                                                        Job (Vector α n)

                                                                        Merge an Vector of jobs into one, collecting their outputs into an Array.

                                                                        Instances For