Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wouldn't use "update" since it imply that there is a modification of the value in the original record. This is possible with mutable field of course, but I think the feature of OCaml (and apparently, SML#) you're talking about is the `with` keyword:

    # type foo = { bar: int ; baz: string };;
    type foo = { bar : int; baz : string; }
    # let a = { bar = 42; baz = "hello" };;
    val a : foo = {bar = 42; baz = "hello"}
    # let b = {a with baz = "bye"};;
    val b : foo = {bar = 42; baz = "bye"}
    # a;;
    - : foo = {bar = 42; baz = "hello"}


You are completely right, thanks for the precision and code sample.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: