F# forward type declarations

前端 未结 3 1279
终归单人心
终归单人心 2020-11-28 13:04

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


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


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 13:59

    You use 'and':

    type firstType = 
         | T1 of secondType
    
    and secondType =
         | T1 of firstType
    

提交回复
热议问题