Documentation

Lean.Elab.Task

Task creation utilities for Lean's tactic monads. #

This file provides asTask and asTask' functions for various monads (CoreM, MetaM, TermElabM, TacticM), which convert monadic computations into tasks that run in parallel while preserving state.

Each asTask function returns:

The asTask' variants omit the cancellation hook for convenience.

Note: Calling IO.cancel on t.map f does not cancel t, so these functions are careful to construct cancellation hooks connected to the underlying task rather than various maps of it.

Given a monadic value in CoreM, creates a task that runs it in the current state, returning

  • a cancellation hook and
  • a monadic value with the cached result (and subsequent state as it was after running).

The task is run with a fresh CancelToken in its context, so it can detect cancellation via Core.checkInterrupted. The cancellation hook sets this token.

Uses Core.wrapAsync internally to properly handle name generators and heartbeats.

Note: We only set the cancel token and don't call IO.cancel task. We're uncertain whether IO.cancel is also necessary - it may be required for tasks that use IO.checkCanceled instead of Core.checkInterrupted.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    def Lean.Core.CoreM.asTask' {α : Type} (t : CoreM α) :

    Given a monadic value in CoreM, creates a task that runs it in the current state, returning a monadic value with the cached result (and subsequent state as it was after running).

    Equations
    Instances For

      Given a monadic value in MetaM, creates a task that runs it in the current state, returning

      • a cancellation hook and
      • a monadic value with the cached result (and subsequent state as it was after running).
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def Lean.Meta.MetaM.asTask' {α : Type} (t : MetaM α) :

        Given a monadic value in MetaM, creates a task that runs it in the current state, returning a monadic value with the cached result (and subsequent state as it was after running).

        Equations
        Instances For

          Given a monadic value in TermElabM, creates a task that runs it in the current state, returning

          • a cancellation hook and
          • a monadic value with the cached result (and subsequent state as it was after running).
          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Given a monadic value in TermElabM, creates a task that runs it in the current state, returning a monadic value with the cached result (and subsequent state as it was after running).

            Equations
            Instances For

              Given a monadic value in TacticM, creates a task that runs it in the current state, returning

              • a cancellation hook and
              • a monadic value with the cached result (and subsequent state as it was after running).
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Given a monadic value in TacticM, creates a task that runs it in the current state, returning a monadic value with the cached result (and subsequent state as it was after running).

                Equations
                Instances For