We capture here some of the caveats and syntactic sugars here.
module Lang.syntaxQuirks where
open import Lang.dataStructures
open import Agda.Builtin.Equality
Mostly short-forms of various stuff used more often.
The implicit parameter {m : ℕ}
common to all constructors can be abstracted out into the data
definition:
data _≤′_ : ℕ → ℕ → Set where
: {m : ℕ} → m ≤′ m
≤′-refl : {m : ℕ} → {n : ℕ} → m ≤′ n → m ≤′ succ n ≤′-step
is same as
data _≤′₁_ (m : ℕ) : ℕ → Set where
: m ≤′₁ m
≤′₁-refl : {n : ℕ} → m ≤′₁ n → m ≤′₁ succ n ≤′₁-step
data
The previous technique also works for concrete parameters:
data _≤″_ : ℕ → ℕ → Set where
: ∀ {m n k} → m + n ≡ k → m ≤″ k ≤″
is same as
data _≤″₁_ (m : ℕ) : ℕ → Set where
: ∀ {n k} → m + n ≡ k → m ≤″₁ k ≤+
which is same as
data _≤″₂_ (m : ℕ) (k : ℕ) : Set where
: ∀ {n} → m + n ≡ k → m ≤″₂ k ≤+
Arguments that can be inferred by the compiler can be left out with an _
:
: (A : Set) (len : ℕ) → Vec A len → ℕ
length = zero
length A zero [] = len length A len somevec
: (A : Set) (len : ℕ) → Vec A len → ℕ
length' = zero
length' A zero [] _ = len length' A len
: (A : Set) (len : ℕ) → Vec A len → ℕ
length'' = zero
length'' A zero [] _ len _ = len length''
Though these are generally ill-advised as they may cause confusion when used unwisely.