F#中的嵌套联合类型

Max*_*Max 5 f# types

有没有办法在F#中创建嵌套的联合类型?像这样的东西


type MainType =
    | A of
        | AA of int
        | AB of float
    | B of int   
Run Code Online (Sandbox Code Playgroud)

nlu*_*oni 2

不,您必须分隔类型(如 kvb 的帖子中所示)。我听说有计划将多态方差(如 ocaml 中的)添加到 F# 中,这将允许您做类似的事情。

在奥卡姆里,

type mainType =
    | A of [ `AA of int | `AB of float ]
    | B of int   
Run Code Online (Sandbox Code Playgroud)