玩榆树checkboxes example。我试图在view
, label []
[ br [] []
, input [ type' "checkbox", checked model.underline, onCheck Underline ] []
, text "underline"
]
进入一个单独的功能并使用它三次。到目前为止,我有......
makeLabel : String -> Bool -> Msg -> Html Msg
makeLabel caption bool msg =
label []
[ br [] []
, input [ type' "checkbox", checked bool, onCheck msg ] []
, text caption
]
我会像
一样使用它makeLabel "underline" model.underline Underline
但后来我收到以下错误
Function `makeLabel` is expecting the 3rd argument to be:
Msg
But it is:
Bool -> Msg
当用户更改复选框时,如何传递makeLabel函数以执行正确的操作?
type Msg
= Red Bool
| Underline Bool
| Bold Bool
我不明白如何在不包含标签(Underline Bool)的情况下将联合类型(下划线)传递给函数
答案 0 :(得分:4)
问题在于您的类型签名,而不是代码。试试这个:
makeLabel : String -> Bool -> (Bool -> Msg) -> Html Msg