This is a demo of
- CHR
- Serving CHR, complicated by CHR's need to run in a single thread
- interfacing Snap! with Prolog
- dealing with Snap! not liking sessions
-
Download the latest Snap.zip from https://github.com/jmoenig/Snap/releases/tag/v5.1.0
-
unzip in the cookingwithsnap directory, you'll get a directory Snap-5.1.0
-
cd cookingwithsnap/prolog
-
swipl cooking.pl
-
?- go.
-
load Snap-5.1.0/index.html into browser to get a default snap project
-
Load the file cookingwithsnap/cookingwithsnap.xml via the document icon in UI, or by drag and drop onto Snap UI.
-
click the green flag
-
Drag ingredients (for now just the egg) into the pan
Snap! running in the browser sends HTTP requests to a SWI-Prolog server. The server formulates a pair of goals. The action goal to initiate change, and a return goal whose last argument is bound with the information to be returned to Snap!
These are passed via message queues to a dedicated thread that handles the CHR productions.
The result is passed back via another message queue and bound to the last argument.
CHR server lifted from