Elm记录速记法

Elm记录速记法,elm,Elm,为了更好地使用JavaScript进行函数式编程,我开始学习Elm 在JavaScript中,有对象速记符号: const foo = 'bar'; const baz = { foo }; // { foo: 'bar' }; 我想知道榆树里有没有类似的东西?我这样问是因为我有以下模型: type alias Model = { title : String , description : String , tag : String , tags : List

为了更好地使用JavaScript进行函数式编程,我开始学习Elm

在JavaScript中,有对象速记符号:

const foo = 'bar';
const baz = { foo }; // { foo: 'bar' };
我想知道榆树里有没有类似的东西?我这样问是因为我有以下模型:

type alias Model =
    { title : String
    , description : String
    , tag : String
    , tags : List String
    , notes : List Note
    }


type alias Note =
    { title : String
    , description : String
    , tags : List String
    }
以及一个
update
函数,该函数在接收到
AddNote
操作时,将注释添加到注释数组并清除输入:

AddNote ->
            { model | notes = model.notes ++ [ { title = model.title, description = model.description, tags = model.tags } ], title = "", description = "", tag = "" }
我知道在函数定义中可以“解构”记录,但我认为即使在返回类型中,我也必须显式地键入记录的每个键

AddNote ->
    { model | notes = model.notes ++ [ getNote model ], title = "", description = "", tag = "" }


getNote : Model -> Note
getNote { title, description, tags } =
    { title = title, description = description, tags = tags }

没有类似于JavaScript对象的速记记录符号

但是,类型别名也可以用作构造函数,因此您可以使用如下内容:

getNote : Model -> Note
getNote { title, description, tags } =
    Note title description tags