不带参数的视图函数的正确类型注释
Correct type annotation for a view function which takes no argument
我目前正在学习 Elm,我知道这是一个菜鸟问题,但我似乎无法正确输入注释这个 return 只是一个纯 div.
的函数
header =
div [] [ text "Hello" ]
输入注释此函数的准确方法是什么?
正确的注释是这样的:
header : Html msg
header =
div [] [ text "Hello" ]
以后你可以使用 Elm REPL 来查找某物的类型:
> import Html exposing (..)
> div [] [ text "Hello" ]
{ type = "node", tag = "div", facts = {}, children = {}, namespace = <internal structure>, descendantsCount = 0 }
: Html.Html msg
冒号后的部分为签名,即Html.Html msg
我目前正在学习 Elm,我知道这是一个菜鸟问题,但我似乎无法正确输入注释这个 return 只是一个纯 div.
的函数header =
div [] [ text "Hello" ]
输入注释此函数的准确方法是什么?
正确的注释是这样的:
header : Html msg
header =
div [] [ text "Hello" ]
以后你可以使用 Elm REPL 来查找某物的类型:
> import Html exposing (..)
> div [] [ text "Hello" ]
{ type = "node", tag = "div", facts = {}, children = {}, namespace = <internal structure>, descendantsCount = 0 }
: Html.Html msg
冒号后的部分为签名,即Html.Html msg