[英]Using Agda “rewrite” to prove “composition of maps is map of compositions”
[英]lookup using Maps from Data.Tree.AVL.Map in Agda
我不明白如何使用 Stdlib 提供的Map
。 我嘗試創建一個從String
到String
的Map
,它起作用了,但是每當我嘗試使用lookup
函數時,我都會遇到奇怪的錯誤:
這是我的代碼的簡化:
open import Data.Maybe
open import Data.String
open import Data.String.Properties
open import Data.Tree.AVL.Map (<-strictTotalOrder-≈) using (Map ; singleton ; lookup)
singletonMap : Map String
singletonMap = singleton "test" "a"
test : Maybe String
test = lookup singletonMap "test"
我收到以下錯誤:
(Data.Tree.AVL.Tree <-strictTotalOrder-≈
(Data.Tree.AVL.Value.const
(Relation.Binary.Bundles.StrictPartialOrder.Eq.setoid
(Relation.Binary.Bundles.StrictTotalOrder.strictPartialOrder
<-strictTotalOrder-≈))
String))
!=< String
when checking that the expression singletonMap has type
Relation.Binary.Bundles.StrictTotalOrder.Carrier
<-strictTotalOrder-≈
我什至無法理解發生了什么,看起來lookup
並不期望像singletonMap
這樣的參數,因為類型不匹配,但這怎么可能呢? 我使用singleton
創建它,函數具有以下類型(它們也可以在Data.Tree.AVL.Map中看到):
singleton : Key → V → Map V
lookup : Map V → Key → Maybe V
它們實際上是一樣的。
您正在鏈接到當前開發版本的文檔。 在較舊的已發布版本中, lookup
首先采用鍵,然后是Map
。 你應該寫
test : Maybe String
test = lookup "test" singletonMap
開發版本正准備發布 2.0 版本,對統一性的名稱進行重大更改(所有查找現在都具有Container -> Key -> Val
形式的類型,因為鍵的類型可能取決於容器的類型,但反之則不然)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.