Pergunta

Eu tropecei nesse problema em f#. Suponha que eu queira declarar dois tipos que se referem:


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

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

Como faço isso, então o compilador não gera um erro?

Foi útil?

Solução

Você usa 'e':

type firstType = 
     | T1 of secondType

and secondType =
     | T1 of firstType

Outras dicas

Eu imaginei isso. Seu:


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

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

A limitação é que os tipos precisam ser declarados no mesmo arquivo.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top