在elm中解构列表列表
我试图在elm(0.18)中对列表列表进行解构。下面是函数调用:在elm中解构列表列表,elm,Elm,我试图在elm(0.18)中对列表列表进行解构。下面是函数调用: twoColumns [ [ Widget1, Widget2 ] , [ Widget3, Widget4 ] ] 调用此函数的: twoColumns : List List Widget -> Html Msg twoColumns listoflists = case listoflists of listLeft :: listRight :: _
twoColumns
[ [ Widget1, Widget2 ]
, [ Widget3, Widget4 ]
]
调用此函数的:
twoColumns : List List Widget -> Html Msg
twoColumns listoflists =
case listoflists of
listLeft :: listRight :: _ ->
div []
[ div [ class "col-md-6" ] (parsingOperation listLeft)
, div [ class "col-md-6" ] (parsingOperation listRight)
]
_ ->
div [] [ text "Error" ]
(假设parseOptions接受列表小部件
作为参数。)
这看起来像是简单的解构,但我得到了一个错误:
Tag `::` is causing problems in this pattern match.
71| listLeft :: listRight :: _ ->
^^^^^^^^^^^^^^^^^^^^^^^^^^
The pattern matches things of type:
List a
But the values it will actually be trying to match are:
List List Widget
有什么想法吗
注意:当我尝试使用模式
(listLeft::listRight::)
时,elm格式将其还原为上面的模式。列表小部件
应改为列表(列表小部件)
。因为列表小部件
的意思完全不同(而且毫无意义)。然而,这很有趣,为什么Elm编译器甚至允许列表小部件
。我猜这是编译器的一个bug。列表小部件
应该是列表(列表小部件)
。因为列表小部件
的意思完全不同(而且毫无意义)。然而,这很有趣,为什么Elm编译器甚至允许列表小部件
。我猜这是编译器的一个bug