如何在榆树中将Maybe(List)转换为Just List?

问题描述 投票:0回答:1

我有一个由字符串列表组成的列表,声明为

type alias Model =
    {board : List (List String)
    }

init : Model
init =
    {board = 
         [ ["","",""]
          ,["","",""]
         ,["","",""]
           ]
     }

在我的更新功能中,我试图通过]访问列表的内部元素>

 (getAt col (getAt row model.board))

尽管尝试编译它时收到以下错误。如何从Maybe List转换为Just List或简单地List?

The 2nd argument to `getAt` is not what I expect:

65|                         (getAt col (getAt row model.board))
                                        ^^^^^^^^^^^^^^^^^^^^^
This `getAt` call produces:

    Maybe (List String.String)

But `getAt` needs the 2nd argument to be:

    List a

我有一个由字符串列表组成的列表,声明为类型别名Model = {board:List(列表字符串)} init:Model init = {board = [[“”,“”,“”], [“”,“”,...

list elm maybe
1个回答
0
投票

首先回答您的问题:使用case .. ofcase .. of

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.