【问题标题】:Why is the compiler not recognizing this type alias?为什么编译器无法识别此类型别名?
【发布时间】:2020-02-03 19:25:30
【问题描述】:

有谁知道为什么编译器无法识别此类型别名?

viewBoardCanvas : Model -> Html Msg
viewBoardCanvas model =
    case model.game of
        Nothing -> Options.div [] [ Button.render Mdl [ 0 ] model.mdl [] [ text "Start Game" ] ]
        Just Game -> text "I'm a game!"

它说它找不到模式游戏,但在我的 Types.elm 文件中有。

type alias Game = { board : Html Msg , players : List Player }

type alias Model = { resume : List ResumeSections , mdl : Material.Model , route : Route , game : Maybe Game }

【问题讨论】:

    标签: elm type-alias


    【解决方案1】:

    在 Elm 中,变量名必须以小写字母开头。在您的Just Game 案例中,问题在于Game 是大写的。

    将其更改为以下内容,它应该可以工作:

    Just game -> text "I'm a game!"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-29
      • 2023-03-11
      • 2020-06-30
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多