2415dbe555d2

Export symbols and add a few sanity checks
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 08 Jul 2016 17:03:54 +0000
parents 55019395ba93
children 8c853f632f8c
branches/tags (none)
files package.lisp src/wam/ui.lisp

Changes

--- a/package.lisp	Wed Jul 06 20:41:56 2016 +0000
+++ b/package.lisp	Fri Jul 08 17:03:54 2016 +0000
@@ -1,6 +1,3 @@
-(defpackage #:bones
-  (:use #:cl)
-  (:export #:hello))
 
 (defpackage #:bones.utils
   (:use
@@ -69,6 +66,42 @@
     #:bones.circle
     #:bones.quickutils
     #:bones.utils)
+  (:export
+    #:make-database
+    #:with-database
+    #:with-fresh-database
+
+    #:invoke-rule
+    #:invoke-fact
+    #:invoke-facts
+
+    #:rule
+    #:fact
+    #:facts
+
+    #:push-logic-frame
+    #:pop-logic-frame
+    #:finalize-logic-frame
+    #:push-logic-frame-with
+
+    #:invoke-query
+    #:invoke-query-all
+    #:invoke-query-map
+    #:invoke-query-do
+    #:invoke-query-find
+    #:invoke-prove
+
+    #:query
+    #:query-all
+    #:query-map
+    #:query-do
+    #:query-find
+    #:prove
+
+    #:call
+    #:?
+    #:!
+    )
   (:import-from #:optima
     #:match)
   (:shadowing-import-from #:cl-arrows
@@ -110,3 +143,45 @@
     #:query-one
     #:query-all))
 
+
+
+
+(defpackage #:bones
+  (:use #:cl #:bones.wam)
+  (:export
+    #:make-database
+    #:with-database
+    #:with-fresh-database
+
+    #:invoke-rule
+    #:invoke-fact
+    #:invoke-facts
+
+    #:rule
+    #:fact
+    #:facts
+
+    #:push-logic-frame
+    #:pop-logic-frame
+    #:finalize-logic-frame
+    #:push-logic-frame-with
+
+    #:invoke-query
+    #:invoke-query-all
+    #:invoke-query-map
+    #:invoke-query-do
+    #:invoke-query-find
+    #:invoke-prove
+
+    #:query
+    #:query-all
+    #:query-map
+    #:query-do
+    #:query-find
+    #:prove
+
+    #:call
+    #:?
+    #:!
+
+    ))
--- a/src/wam/ui.lisp	Wed Jul 06 20:41:56 2016 +0000
+++ b/src/wam/ui.lisp	Fri Jul 08 17:03:54 2016 +0000
@@ -35,6 +35,7 @@
 
 ;;;; Assertion
 (defun invoke-rule (head &rest body)
+  (assert *database* (*database*) "No database.")
   (wam-logic-frame-add-clause! *database*
                                (list* (normalize-term head)
                                       (mapcar #'normalize-term body)))
@@ -62,12 +63,15 @@
 
 ;;;; Logic Frames
 (defun push-logic-frame ()
+  (assert *database* (*database*) "No database.")
   (wam-push-logic-frame! *database*))
 
 (defun pop-logic-frame ()
+  (assert *database* (*database*) "No database.")
   (wam-pop-logic-frame! *database*))
 
 (defun finalize-logic-frame ()
+  (assert *database* (*database*) "No database.")
   (wam-finalize-logic-frame! *database*))
 
 (defmacro push-logic-frame-with (&body body)
@@ -79,6 +83,7 @@
 
 ;;;; Querying
 (defun perform-query (terms result-function)
+  (assert *database* (*database*) "No database.")
   (run-query *database* (mapcar #'normalize-term terms)
              :result-function result-function))