[racket] Question about syntax splicing and formatting of the resulting code body

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Fri Jan 11 23:23:02 EST 2013

The inference collection (
http://planet.racket-lang.org/display.ss?package=inference.plt&owner=williams)
in PlaneT is a hybrid forward and backward chaining inference engine that
is written entirely in Racket. It uses a (rete-like) rule network
internally. We have used it internally for several projects. The
documentation and examples are still a bit weak - which is, of course, my
fault - but I'd be happy to help others learn it.

Doug

On Wed, Jan 9, 2013 at 8:48 AM, Ray Racine <ray.racine at gmail.com> wrote:

> Sorry off topic, but Forward Production Rete Rules Engines, such fond
> memories.   An exact blueprint to code one from scratch is below.  Jess is
> license encumbered, Drools is not, but I expect you've already run across
> it.
>
> And many, many moons long gone, I did an impl in SML that compiled under
> MLton  which was PDQ.  Then a buddy of mine with some assistance did what
> is AFAIK still the only mult-threaded / concurrent implementation (in Java)
> of a Reta alpha/beta network using a sort of "zipper" algo on the network
> graph.  It's still out there http://www.zilonis.org/ , not used by anyone
> AFAIK, though we believe a few folks did take the code internally.   We had
> it in production for awhile long ago (ad targeting on web).   Rumor was
> Forgy also built a concurrent solution, but you had to model the Rete in a
> DSL and it compiled to Java code.  Never caught on.
>
> Oh and yes of course, the Zilonis version has a "tiny" scheme interpreter
> built in to write capable of simple calculations, regex matches etc in the
> rules.
> Production Matching for Large Learning Systems (Rete/UL)<http://docs.codehaus.org/download/attachments/8082/CMU-CS-95-113.pdf?version=1&modificationDate=1092858118000>
>
>
> by Robert B. Doorenbos
>
>
> On Wed, Jan 9, 2013 at 8:36 AM, Grant Rettke <grettke at acm.org> wrote:
>
>> Hi,
>>
>> I have the goal of inserting some Jess (http://herzberg.ca.sandia.gov/)
>> code inside of a Scribble interaction environment (eventually I will have a
>> language to evaluate this but I'm not there yet). Here is the relevant part
>> of the code I have to do that:
>>
>> #lang racket
>>
>> (define (my-read-syntax src in)
>>   (define path-ls (get-path in))
>>   (define path (list->string path-ls))
>>   (define fis (open-input-file #:mode 'text path))
>>   (define datums (let loop ()
>>                    (let* ((datum (read fis)))
>>                      (cond ((eof-object? datum) empty)
>>                            (else (cons datum (loop)))))))
>>   (close-input-port fis)
>>   (datum->syntax #f datums))
>>
>> This does load the file and insert it into Scribble eg:
>>
>> (interaction
>>     #:eval
>>     my-evaluator
>>     ((watch all)
>>      (reset)
>>      (defrule do-anything "A rule for anything." ?ne <- (anything) =>
>> (printout t "Someone did something.") (retract ?ne))
>>      (assert (anything))
>>      (run)))))
>>
>> There are two things I'm still not doing correctly though:
>>
>> #1. I've collected the contents of that file into a list of datums that
>> looks like this in DrRacket's console:
>>
>> '((watch all)
>>   (reset)
>>   (defrule
>>    do-anything
>>    "A rule for anything."
>>    ?ne
>>    <-
>>    (anything)
>>     =>
>>    (printout t "Someone did something.")
>>    (retract ?ne))
>>   (assert (anything))
>>   (run))
>>
>> I don't want those inserted as a list though, I only want the contents
>> inserted. Up above I see why it is happening, but I am not successfully
>> splicing it in my attempts. What is the right way?
>>
>> #2. The code body is formatted at least in the output in DrRacket. When
>> it is inserted into the Scribble environment, though, it loses some of it's
>> formatting namely the defrule and right arrow appear in the same line. That
>> said, when Scribble renders it, all of the code is rendered on the same
>> line like this:
>>
>> > ((watchall)(reset)(defruledo-anything"A rule for anything."?ne<-(
>> anything)=>(printoutt"Someone did something.")(retract?ne))(assert(
>> anything))(run))
>>
>> =>: arrow not allowed as an expression
>>
>> How may I read in that file and then generated a syntax object that
>> retains the indentation and new lines?
>>
>> #3. Am I generally going about this in an OK manner? My next part of the
>> plan to make a simple language whose only purpose in life is to evaluate
>> Jess code and print out the results; I want to be able to use Scribble for
>> any other Lispy language out there at least the interaction environment.
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130111/eb909684/attachment.html>

Posted on the users mailing list.