<< Back to previous view

[LOGIC-49] minimal map type for unifying only part of a map Created: 31/Aug/12  Updated: 28/Jul/13  Resolved: 12/Oct/12

Status: Closed
Project: core.logic
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: David Nolen Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: File 49-partial-map.diff     File 49-partial-map.diff     Text File 49-partial-map.patch    

 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?



 Comments   
Comment by Kevin Lynagh [ 12/Oct/12 12:44 PM ]

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.

Comment by David Nolen [ 12/Oct/12 1:10 PM ]

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.

Comment by Kevin Lynagh [ 12/Oct/12 1:16 PM ]

Also on the Github: https://github.com/lynaghk/core.logic/tree/partial-map

Comment by Kevin Lynagh [ 12/Oct/12 1:31 PM ]

Patch without !_ sugar.

Comment by Kevin Lynagh [ 12/Oct/12 1:47 PM ]

Add patch, not diff.

Comment by David Nolen [ 12/Oct/12 1:52 PM ]

fixed, http://github.com/clojure/core.logic/commit/9b340ea4fff2f4dad50b0f9631054e713b895fe8

Generated at Mon Sep 01 17:11:40 CDT 2014 using JIRA 4.4#649-r158309.