我试图在Typed Racket中使用通用图形库,通过使用require/typed
导入它,但是我一直收到这些奇怪的长错误。是否有人成功地使类型检查器与通用图形库合作?
#lang typed/racket
(require/typed graph
[#:opaque Graph graph?]
[unweighted-graph/undirected ((Listof (List Any Any)) -> Graph)]
[add-edge! (Graph Any Any -> Void)])
(define g : Graph (unweighted-graph/undirected '((1 2) (1 3))))
(add-edge! g 2 3)
graph?: contract violation
any-wrap/c: Unable to protect opaque value passed as `Any`
value: #<unweighted-graph>
This warning will become an error in a future release.
in: the 1st argument of
a part of the or/c of
(or/c
struct-predicate-procedure?/c
(-> Any boolean?))
contract from: (interface for graph?)
import/typed
还是require/typed
?我相当确定你是指后者,但这可能是问题的原因? - Lazerbeak12345require/typed
,而import
是我的笔误。但这并没有引起任何问题。 - Alex MacLean