相关疑难解决方法(0)

F#转发类型声明

我偶然发现了F#中的这个问题.假设,我想声明两种相互引用的类型:


type firstType = 
     | T1 of secondType
     //................

type secondType =
     | T1 of firstType  
     //................    
Run Code Online (Sandbox Code Playgroud)

我该怎么做,所以编译器不会生成错误?

syntax recursion f# types mutual-recursion

32
推荐指数
1
解决办法
4041
查看次数

如何在OCaml中定义两个相互引用的类型?

下面的代码将报告语法错误消息:

type 'a edge = 
  |Empty 
  |End of 'a * 'a vertex * 'a vertex and
type 'a vertex = 
  |Empty
  |Vertex of 'a * 'a edge list;;
Run Code Online (Sandbox Code Playgroud)

如何定义两种相互引用的类型?

recursion ocaml types

3
推荐指数
1
解决办法
1142
查看次数

标签 统计

recursion ×2

types ×2

f# ×1

mutual-recursion ×1

ocaml ×1

syntax ×1