core.match

Allow matching of map expressions to restrict the set of keys present in the value to a subset of a specified set of keys

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

It is useful, to be able to constrain a match on a map value to limit the set of keys present in the value, without enforcing that the keys are all present in the value.

The current :only option, enforces a strict matching of keys.

{{(let [x {:a 1} (match [x] [({:a _ :b _} :only [:a :b])])}} => doesn't match

This came up trying to write a precondition on the argument of a function, which allowed optional keys, but wanted to restrict the overall set of keys.

Activity

Hide
David Nolen added a comment - - edited
(match x
  ({:c 1} :has [:a :b]) :a0
  ...)

or

(match x
  ({:c 1} :contains [:a :b]) :a0
  ...)

Seems reasonable.

Show
David Nolen added a comment - - edited
(match x
  ({:c 1} :has [:a :b]) :a0
  ...)
or
(match x
  ({:c 1} :contains [:a :b]) :a0
  ...)
Seems reasonable.
Hide
David Nolen added a comment -

Ah misunderstood. You want something like :allowed.

Show
David Nolen added a comment - Ah misunderstood. You want something like :allowed.
Hide
David Nolen added a comment -

This is a variant of MATCH-70. You can not specify that some keys must be present by specifying the key and the specifying that the value of the key is a wildcard.

Show
David Nolen added a comment - This is a variant of MATCH-70. You can not specify that some keys must be present by specifying the key and the specifying that the value of the key is a wildcard.
David Nolen made changes -
Field Original Value New Value
Resolution Duplicate [ 3 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: