Search code examples
agdaliterate-programming

Hide parts of a line from LaTeX output


Is there a way to hide parts of a line from the LaTeX output?

For whole lines, this works:

\begin{code}
foo : Tm Γ t
\end{code}
\begin{code}[hide]
foo = someHiddenDefinitionOfFoo
\end{code}

but what if I want to hide parts of a line, e.g. parts of a type signature? For example, suppose I have this Agda signature:

sub-⊢*⊇ : ∀ {Γ Δ Θ t} (σ : Γ ⊢* Δ) (Δ⊇Θ : Δ ⊇ Θ) (e : Tm Θ t) →
  sub (σ ⊢*⊇ Δ⊇Θ) e ≡ sub σ (ren Δ⊇Θ e)

but I'd like it to look like this in the LaTeX output:

sub-⊢*⊇ : ∀ σ Δ⊇Θ e → sub (σ ⊢*⊇ Δ⊇Θ) e ≡ sub σ (ren Δ⊇Θ e)

Is this possible?


Solution

  • The most robust approach for doing this kind of thing is to use anonymous modules for the arguments you want to hide:

    sub-⊢*⊇ : ∀ {Γ Δ Θ t} (σ : Γ ⊢* Δ) (Δ⊇Θ : Δ ⊇ Θ) (e : Tm Θ t) →
      sub (σ ⊢*⊇ Δ⊇Θ) e ≡ sub σ (ren Δ⊇Θ e)
    

    thus becomes

    module _ {Γ Δ Θ t} where
    
     sub-⊢*⊇ : (σ : Γ ⊢* Δ) (Δ⊇Θ : Δ ⊇ Θ) (e : Tm Θ t) →
       sub (σ ⊢*⊇ Δ⊇Θ) e ≡ sub σ (ren Δ⊇Θ e)
    

    If you're willing to use a very basic sed script to postprocess the LaTeX file to erase simple {var} arguments, you should be able to get your intended goal with something like:

    module _ {Γ Δ Θ t} where
    
     sub-⊢*⊇ : ∀ σ Δ⊇Θ e → sub {Γ} (σ ⊢*⊇ Δ⊇Θ) e ≡ sub σ (ren {Δ} {Θ} Δ⊇Θ e)