如何摆脱 Elm 中输入错误的结束?

How to get away with end of input error in Elm?

我正在学习 Elm,完成本教程后,我从头开始创建一个新应用程序,但是当我在视图中添加新的 HTML 标记时,出现错误。

我的代码:

module Main exposing (..)

import Html exposing (..)
import Html.Attributes exposing (..)


main : Html a
main =
    span [ class "welcome-message" ] [ text "Hello, World!" ]
    , h1 [class "headline"] [text "Hello"]

错误:

Detected errors in 1 module.

-- SYNTAX PROBLEM ----------------------------------------------------- 

Main.elm I ran into something unexpected when parsing your code! 

10|     , h1 [class "headline"] [text "Hello"]         

^ I am looking for one of the following things:     
end of input     
whitespace

我在 Windows 10.

上使用 Visual Studio 代码

我的编辑器配置为使用 LF 和 4 个空格缩进。

我在 PowerShell 上使用 elm-reactor。

您的代码无效 Elm 代码:​​逗号只能出现在列表(或记录)的元素之间。此外,您不能在顶层有两个 Html 节点,因此您需要将它们包装在一个元素中。在这种情况下,您可能希望将两者包装在 div [] []:

main : Html a
main =
    div []
        [ span [ class "welcome-message" ] [ text "Hello, World!" ]
        , h1 [ class "headline" ] [ text "Hello" ]
        ]