如何在Purescript中将新字段添加到对象

如何在Purescript中将新字段添加到对象,purescript,Purescript,我首先介绍Purescript。 我将把新字段添加到对象中,并将其作为函数param发送。 但我找不到解决这个问题的好办法 比如说 oldFiled = { title : "title", description : "d" } newField = { time : "time" } //result after added new field oldFiled = { title : "title", description : "d", time : "time"

我首先介绍Purescript。 我将把新字段添加到对象中,并将其作为函数param发送。 但我找不到解决这个问题的好办法

比如说

oldFiled = {
 title : "title",
 description : "d" 
}
newField = {
  time : "time"
}
//result after added new field
oldFiled = {
  title : "title",
  description : "d",
  time : "time"
}

如何操作?

如果只是添加一个字段,您可以这样使用:

如果要合并记录,请查看Data.Record模块中的合并并集和分离函数

import Data.Record as Record
import Data.Symbol (SProxy(..))
oldFiled = {
 title : "title",
 description : "d" 
}
newFiled = Record.insert (SProxy :: _ "time") "time" oldFiled