Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在elm中更新内部记录_Elm - Fatal编程技术网

如何在elm中更新内部记录

如何在elm中更新内部记录,elm,Elm,我有这个型号 type alias Model = { exampleId : Int , groupOfExamples : GroupExamples } type alias GroupExamples = { groupId : Int , results : List String } 在我的更新函数中,如果我想更新exampleId,如下所示: { model | exampleId = updatedValue } 但是,如果我需要更新,例如,G

我有这个型号

type alias Model = 
  { exampleId : Int
  , groupOfExamples : GroupExamples
  }

type alias GroupExamples = 
  { groupId : Int
  , results : List String
  }
在我的更新函数中,如果我想更新exampleId,如下所示:

 { model | exampleId = updatedValue }
但是,如果我需要更新,例如,GroupExamples中的results值,该怎么办

在该语言中进行此操作的唯一方法是分解外部记录,如下所示:

let
示例=model.groupof示例
newExamples={examples | results=[“whatever”]}
在里面
{model | groupOfExamples=newExamples}
此外,还提供了允许您:

set(groupOfExamples=>results)[“whatever”]模型
-当您有嵌套的数据结构时