Skip to content

Better syntax for chained updates to functions and finite maps #616

Open
@mn200

Description

@mn200

Chained updates look bad:

  (k1 =+ v1) ((k2 =+ v2) f)

or

   f |+ (k1,v1) |+ (k2,v2)

Recent p/printing hacking for a paper suggests that these could be rendered as

   f ⦇k1:=v1; k2:=v2⦈

or (if in ASCII)

   f (|k1:= v1; k2:=v2|)

I'm also confident that these syntaxes could be parsed.

If we didn't want to overload functions and finite maps, we could use slightly different magic brackets for each.

f ⦅k1 := v1; k2 := v2⦆

In ASCII, this could be (< .... >) or similar.

One variation is possible: finite maps could also be viewed as record-like, and its bracket-syntax could be seen as the way to specify literal values. Then, the updating syntax would require with (or if you wanted the update (new values) on the left). I.e.,

   ⦅k1 := v1; k2 := v2⦆

would be the 2-element finite map, and

   fm with ⦅k1 := v1; k2 := v2⦆

would be the finite map that extended fm with those values. One could also write

   ⦅k1 := v1; k2 := v2⦆ ⊌ fm

for the same semantics (though the underlying term would be different).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions