为什么编译器无法识别此类型别名?

时间:2020-02-03 19:25:30

标签: elm type-alias

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

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 }

1 个答案:

答案 0 :(得分:4)

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

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

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