문제

I stumbled across this problem in F#. Suppose, I want to declare two types that reference each other:


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

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

How do I do that, so the compiler does not generate an error?

도움이 되었습니까?

해결책

You use 'and':

type firstType = 
     | T1 of secondType

and secondType =
     | T1 of firstType

다른 팁

I figured it. It's:


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

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

The limitation is that the types have to be declared in the same file.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top