core.logic

minimal map type for unifying only part of a map

Details

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

Description

currently it's a bit obnoxious that map unification must be over the entire map. It would be useful to have a new datatype - partial-map this would allow us to only match part of a map instead of the whole thing. Is this unsound?

  1. 49-partial-map.diff
    12/Oct/12 1:31 PM
    3 kB
    Kevin Lynagh
  2. 49-partial-map.diff
    12/Oct/12 1:16 PM
    3 kB
    Kevin Lynagh
  3. 49-partial-map.patch
    12/Oct/12 1:47 PM
    3 kB
    Kevin Lynagh

Activity

Hide
Kevin Lynagh added a comment -

How do you feel about letting partial map have a value meaning "don't unify with a map that has a key here". E.g.,

{:a ?x :b ?y} == {:a 1 :b 2 :c 3} => {:a 1 :b 2}

but

{:a ?x :b !_} == {:a 1 :b 2 :c 3} => nil

My use case is doing map matching + rewrites and in some cases I don't want a partial-map to match a map that already has some keys defined.

Show
Kevin Lynagh added a comment - How do you feel about letting partial map have a value meaning "don't unify with a map that has a key here". E.g., {:a ?x :b ?y} == {:a 1 :b 2 :c 3} => {:a 1 :b 2} but {:a ?x :b !_} == {:a 1 :b 2 :c 3} => nil My use case is doing map matching + rewrites and in some cases I don't want a partial-map to match a map that already has some keys defined.
Hide
David Nolen added a comment -

Sure, but this is a separate ticket. Also it should be expressible via a normal goal - not-has-keyo or some such. Once that's done we can think about sugar.

Show
David Nolen added a comment - Sure, but this is a separate ticket. Also it should be expressible via a normal goal - not-has-keyo or some such. Once that's done we can think about sugar.
Hide
Kevin Lynagh added a comment -
Show
Kevin Lynagh added a comment - Also on the Github: https://github.com/lynaghk/core.logic/tree/partial-map
Hide
Kevin Lynagh added a comment -

Patch without !_ sugar.

Show
Kevin Lynagh added a comment - Patch without !_ sugar.
Hide
Kevin Lynagh added a comment -

Add patch, not diff.

Show
Kevin Lynagh added a comment - Add patch, not diff.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: