I will do a PR for this on the reference guide then and see what others think.
I’ve been jumping around the documentation trying to work out all of the things I need to do to make a ‘proper’ racket project. e.g. rackunit tests, module, contracts etc. Does anyone know if there is a single checklist or simple document that gives a basic project layout?
Ignore me. Found the raco pkg docs. I think that’s what I need.
@marian.petruk has joined the channel
@mark.warren Although I haven’t used it raco pkg new
might be a good head-start. Otherwise, I think I’ve ~cargo-culted~ thoughtfully researched various Racket projects on Git{Hub Lab} for ideas.
@mark.warren A good start: https://blog.racket-lang.org/2017/10/tutorial-creating-a-package.html
@mark.warren A little on unit tests: https://beautifulracket.com/explainer/unit-testing.html
@notjack i got somewhere in the end :slightly_smiling_face: #lang racket
(require racket/list)
(require datalog)
(define blah (make-theory))
(datalog blah
(! (statement sales "are willing to work within a new environment (editor)"))
(! (statement managers "get in the way"))
(! (validation managers "get in the way"))
(! (validation sales "do not want to maintain a database"))
(! (:- (learning C X)
(statement C X)
(validation C X)))
(! (:- (statement C X)
(statement C X)))
; (! (:- (assumption C X)
; (statement C X)
; (not (validation C X))))
;(! (validation sales "are willing to work within a new environment (editor)"))
)
(define learnings (datalog blah (? (learning C X))))
(define statements (datalog blah (? (statement C X))))
;assumptions = statements that are not validated
;(remove-duplicates '(a b b a))
(define assumptions (remove* learnings statements))
@chris613 nice! Good idea to move the negation logic outside of datalog entirely
gone a little futher actually
(define (add-assumption-rule hm)
(datalog blah
(! (assumption (hash-ref hm 'C) (hash-ref hm 'X)))))
(map add-assumption-rule (remove*
(datalog blah (? (learning C X)))
(datalog blah (? (statement C X)))))
could probably be cleaned up quite a bit :slightly_smiling_face:
I don’t know enough datalog to know what that does exactly :stuck_out_tongue:
so really all ive done is implimented the idea of “every statement must be either validated or unvalidated” by reading in the original ruleset, figuring out the missing rules programatically and adding them back in to the logic DB for future use sort of thing
ohhh, I see now
It’s neat how well a language-oriented-programming approach works here. You’ve cleanly split the logic surrounding the entire rule database from the logic of the individual rules themselves, by using racket code for one and datalog code for the other.
Does anyone know if there is a way to automatically create nested attributes in syntax patterns? For example, let’s say I have
(define-syntax-class B
(pattern c))
(define-syntax-class A
(pattern b:B))
Is there any way to automatically generate nested attributes, so I can do something like this: (syntax-parse #'hello-world
[x:A #'x.b.c])
without having to redefine A like this: (define-syntax-class A
(pattern the-b:B
#:with b.c #'the-b.c))
@michaelmmacleod I don’t know of anything that’s completely automatic, but you can use the #:attributes
keyword to expose nested attributes without having to use #:with
on each one: (define-syntax-class A
#:attributes (b b.c)
(pattern b:B))
oh my goodness thank you so much :slightly_smiling_face:. I can’t believe I didn’t see that haha.
I’ve got at least 50 lines of #:with clauses in my program
I didn’t know about it either for like my first several years of using syntax/parse
it’s difficult to find out about