我很难在视图函数内呈现自定义类型列表。 这是模型:如何在elm中呈现列表?
type alias Guid = String
type alias User = String
type alias TaxonomyCategory =
{ id : Guid
, name: String
, updatedAt: Date
, updatedBy: User
, terms: List TaxonomyTerm
}
type TaxonomyTerm =
TaxonomyTerm
{ id : Guid
, name: String
, terms: List TaxonomyTerm
}
我试着用List.map功能的几种方法,但我总是结束了某种错误的消息。
The 2nd argument to function `ul` is causing a mismatch.
120| ul
121| []
122|> [ List.map renderTaxonomyTerm tc.terms ]
Function `ul` is expecting the 2nd argument to be:
List (VirtualDom.Node a)
But it is:
List (List (Html a))
我试过了,但我得到了另一个错误http://i.imgur.com/K03aq5D.png –
我打赌你可能想要定义TaxonomyTerm作为类型别名而不是新类型,例如, 'type别名TaxonomyTerm = {id:Guid,...}' –
但是然后我会在TaxonomyTerm中得到一个有关递归类型的错误 –