簡體   English   中英

我們需要在 Agda 符號中的每個參數之間放置符號嗎?

[英]Do we need to put symbol between each argument in Agda's notation?

正如我在標題中所描述的,假設的代碼應該是這樣的:

data Mode : Set where
  ⇛ : Mode
  ⇚ : Mode

infix  4  _⊢_

data _⊢_ : Context → Term → Mode → Type → Set where
  ⊢-int : ∀ {Γ n}
    → Γ ⊢ (lit n) ⇛ Int

它給了我錯誤

Mode → Type → Set should be a sort, but it isn't
when checking that the inferred type of an application
  Mode → Type → Set
matches the expected type
  _30

我有點知道類型是什么。 為了處理它,我可能需要在它們之間放置一些無意義的符號,例如

data _⊢_._._ where

這不好看,我厭倦了寫那些。 只是想知道這種情況的任何解決方案?

您可以將模式直接硬編碼到數據類型聲明中,並創建兩個單獨的數據類型:

data _⊢_⇛_ : Context → Term → Type → Set where
  ⊢-int : ∀ {Γ n}
    → Γ ⊢ lit n ⇛ Int

data _⊢_⇚_ : Context → Term → Type → Set where

請注意,Agda 能夠識別出中的_⊢_⇛_Mode中的不同,因此沒有歧義(除非您還添加_⊢_ ,此時事情變得模棱兩可)。

或者,你可以做到

data Mode : Set where
  _⇛_ : Term → Type → Mode
  _⇚_ : Term → Type → Mode

infix 4  _⊢_
infix 5 _⇛_ _⇚_

data _⊢_ : Context → Mode → Set where
  ⊢-int : ∀ {Γ n}
    → Γ ⊢ lit n ⇛ Int

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM