There is a good explanation of recursive data types in Elm here .
If you try to compile your data types, you will get the following error:
This type alias is part of a mutually recursive set of type aliases.
4|>type alias Player =
5|> { name : String
6|> , team : Team
7|> }
The following type aliases are mutually recursive:
┌─────┐
│ V
│ Player
│ │
│ V
│ Team
└─────┘
You need to convert at least one `type alias` into a `type`. This is a kind of
subtle distinction, so definitely read up on this before you make a fix:
<https://github.com/elm-lang/elm-compiler/blob/0.17.0/hints/recursive-alias.md>
You can also deal with this in a different way. I prefer to use links IDlike
type alias ID = Int
type alias PlayerList = Dict ID PLayer
type alias TeamList = Dict ID Team
type alias Player =
{ name : String
, teamID : ID
}
type alias Team =
{ name : String
, players : List ID
}
: null . . , :
type alias Player =
{ name : String
, teamID : Maybe ID
}
List String Maybe. [] ( ) "" ( ).
PS: , . , , : , , ( ) X.
, ( ): , 3 (1 + 2 ).