我需要有两个相互引用的课程.在Ocaml有没有办法做出其中一个的前瞻宣言?
(我不认为这可能与单词更容易and).
或者也许它是可能的,但不同于我尝试的方式?
我在下面的代码中遇到类型问题(一些简单的模块功能图实现).似乎这些类型生活在自己的生活中.
我已经type t = NotaEdge | Edge of int*v*v在模块Edge中实现了,这个类型在Graph模块中变成了type edge = E.t.对我来说一切似乎都很好,除了事实上我无法在其上进行模式匹配,因为构造函数Edge在模块Graph中仍未定义.
当我尝试与Edge(l,n,m)匹配时,函数完全正常:#Error:Unbound构造函数Edge
希望有人可以很好地展示它,先提前:)
module Vertex : Vertex with type label = int =
struct
type t = NotaNode | Node of int
type label = int
exception No of string
Run Code Online (Sandbox Code Playgroud)
...
module Edge : Edge with type label = int and type v = Vertex.t =
struct
type v = Vertex.t
type t = NotaEdge | Edge of int*v*v
type label = int
exception No …Run Code Online (Sandbox Code Playgroud) 我正在Ocaml中编写一个简单的游戏,使用它的模块Graphics来执行绘图和交互.我遇到了将Graphics.read_key()所有印刷机排队等待以后使用的问题,因此当我按住键一段时间后,许多"按下"被放入内存中.发布后,仍然会执行操作.
有没有办法从这个队列中删除条目,或者只是(甚至更好)不排队它们?