(Solved) Silly syntax question


#1

I am not sure how to write something quite trivial :blush:

let Example =
      { Type = { foo : Natural, bar : { name : Text, namespace : Text } }
      , default = { foo = 1, bar.namespace = "test" }
      }

in  

-- Example::{=} with bar.name = "test"
-- Example::{bar.name = "test"}

#2

@PierreR:

let Bar =
      { Type = { name : Text, namespace : Text }, default.namespace = "test" }

let Example =
      { Type = { foo : Natural, bar : Bar.Type }
      , default = { foo = 1, bar = Bar.default }
      }

in  Example::{ bar = Bar::{ name = "test" } }

Record completion currently only works 1 level deep. One thing I would like to eventually do is make it work more than one level deep, but it’s low on my priority list at the moment.


#3

@Gabriel439 thanks for your quick reply.

The limitation is a bit annoying in practice because it forces to expose more complexity (both Example and Bar) to the client code but sure it is not urgent.


#4

If somebody would like to get to this before I do, the main idea for generalizing the feature is to change how the operator desugars. Currently SomeRecord::{ foo.bar = 1, baz = True } desugars to:

(SomeRecord.default // { foo.bar = 1, baz = True }) : SomeRecord.Type

… and you would be able to generalize it to work with nesting by instead desugaring it to:

(SomeRecord.default with foo.bar = 1 with baz = True) : SomeRecord.Type