Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are rules with required bindings supported somehow? #205

Closed
kipz opened this issue Apr 25, 2023 · 3 comments
Closed

Are rules with required bindings supported somehow? #205

kipz opened this issue Apr 25, 2023 · 3 comments

Comments

@kipz
Copy link

kipz commented Apr 25, 2023

I'm trying to create a Rule that forces some vars to be bound. In this case, ?name:

  (d/q '[:find ?greeting
         :in $ %
         :where
         (say-hello "kipz" ?greeting)]
       db
       '[[(say-hello [?name] ?result)
          [(ground "hello, ") ?greeting]
          [(str ?greeting ?name) ?result]]])

But this unexpectedly fails warning of unbound vars:

; Execution error (ExceptionInfo) at datalevin.query/check-bound (query.cljc:751).
; Insufficient bindings: #{?name__auto__9} not bound in [(str ?greeting__auto__9 ?name__auto__9) ?greeting]

Without the [..bound vars..] notation, all works just fine:

(d/q '[:find ?greeting
         :in $ %
         :where
         (say-hello "kipz" ?greeting)]
       db
       '[[(say-hello ?name ?result)
          [(ground "hello, ") ?greeting]
         [(str ?greeting ?name) ?result]]])

->>

#{["hello, kipz"]}
@huahaiy
Copy link
Contributor

huahaiy commented Apr 25, 2023

Have you tried this in datascript?

@kipz
Copy link
Author

kipz commented Apr 26, 2023

Have you tried this in datascript?

Tried just now, and same result in datascript.

@kipz
Copy link
Author

kipz commented Apr 26, 2023

Just found this: tonsky/datascript#441

Sorry, I didn't realisze that Datascript provided the Datalog parser/engine.

@kipz kipz closed this as completed Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants