Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested union types in F#

Tags:

types

f#

Is there any way to crate nested union types in F#? Something like this


type MainType =
    | A of
        | AA of int
        | AB of float
    | B of int   
like image 928
Max Avatar asked Sep 04 '09 19:09

Max


1 Answers

No, I don't think so. The doesn't seem to be much advantage over creating two separate union types like:

type NestedType =
| AA of int
| AB of float

type MainType =
| A of NestedType
| B of int

let mainValue = A (AA 1)
like image 72
kvb Avatar answered Oct 10 '22 04:10

kvb