为什么不减少函数调用?如何在编译时验证映射是否包含键值对?
import Data.SortedMap
N : SortedMap String Type
N = fromList
[ ("a", Nat)
, ("b", String)
]
t : lookup "a" N = Just Nat
t = Refl
Type mismatch between
Just Nat = Just Nat (Type of Refl)
and
lookup "a" (fromList [("a", Nat), ("b", String)]) = Just Nat (Expected type)
Specifically:
Type mismatch between
Just Nat
and
lookup "a" (fromList [("a", Nat), ("b", String)])
答案 0 :(得分:2)
它必须与SortedMap
的实现有关,因为使用普通List
的版本可以按预期工作:
N : List (String, Type)
N =
[ ("a", Nat)
, ("b", String)
]
t : lookup "a" N = Just Nat
t = Refl
根据文档Data.SortedMap.lookup
也是合计的,因此应减少。也许原因是SortedMap
中的函数和数据类型似乎具有导出限定符,而Data.List中的函数和数据类型使用了public export
。