0
我有一个类型:尝试在Elm中解构类型时类型不匹配?
type MenuItem msg
= MenuItem
{ attributes : List (Attribute msg)
, children : List (Html msg)
}
这是一个NavBar
的一部分。然后,我有一个函数renderItems
呈现的MenuItem
个清单:
renderItems : List (MenuItem msg) -> Html msg
renderItems items =
ul [ class "nav-list" ] (List.map renderItem items)
renderItems
,你可以看到,来电renderItem
,它看起来像这样:
renderItem : MenuItem msg -> Html msg
renderItem { attributes, children } =
li [ class "nav-item" ]
[ a ([ class "nav-link" ] ++ attributes)
children
]
但我在这里得到一个编译错误:
This record is causing problems in this pattern match.
14| renderItem { attributes, children } =
^^^^^^^^^^^^^^^^^^^^^^^^
The pattern matches things of type:
MenuItem msg
But the values it will actually be trying to match are:
{ c | attributes : a, children : b }
Detected errors in 1 module.
任何人都可以为我解释这个吗?我不明白这个错配。 attributes
和children
似乎相当不错。