如何定义相互递归类型
How to define mutually recursive types
我有以下代码:
type cellInfo('a) = {
index: int,
column: column('a),
id: string
};
type cellInfoFn('a) = cellInfo('a) => ReasonReact.reactElement;
type column('a) = {
header: string,
accessor: accessor('a),
id: option(string),
cell: cellInfoFn('a),
};
了解每种类型如何相互依赖。
我收到以下错误消息:
[1] 12 │ type cellInfo('a) = {
[1] 13 │ index: int,
[1] 14 │ column: column('a),
[1] 15 │ id: string
[1] 16 │ };
[1]
[1] This type constructor's parameter, `column`, can't be found. Is it a typo?
如何处理相互递归类型定义?
相互递归定义必须用and
分隔。这适用于 let
定义和 type
定义:
type cellInfo('a) = {
index: int,
column: column('a),
id: string
}
and cellInfoFn('a) = cellInfo('a) => ReasonReact.reactElement
and column('a) = {
header: string,
accessor: accessor('a),
id: option(string),
cell: cellInfoFn('a),
};
我有以下代码:
type cellInfo('a) = {
index: int,
column: column('a),
id: string
};
type cellInfoFn('a) = cellInfo('a) => ReasonReact.reactElement;
type column('a) = {
header: string,
accessor: accessor('a),
id: option(string),
cell: cellInfoFn('a),
};
了解每种类型如何相互依赖。
我收到以下错误消息:
[1] 12 │ type cellInfo('a) = {
[1] 13 │ index: int,
[1] 14 │ column: column('a),
[1] 15 │ id: string
[1] 16 │ };
[1]
[1] This type constructor's parameter, `column`, can't be found. Is it a typo?
如何处理相互递归类型定义?
相互递归定义必须用and
分隔。这适用于 let
定义和 type
定义:
type cellInfo('a) = {
index: int,
column: column('a),
id: string
}
and cellInfoFn('a) = cellInfo('a) => ReasonReact.reactElement
and column('a) = {
header: string,
accessor: accessor('a),
id: option(string),
cell: cellInfoFn('a),
};