internal vs external representation

Ross Boylan <[email protected]> Sun, 13 Apr 2014 11:07:00 -0700
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <1397412420.5844.27.camel@localhost>
Essentially I'm looking for a kind of reverse of portray. Portray goes
from an internal representation (for prolog) to an external
representation (for a person).  I'd like to go from user input in the
external form to the internal form.

Following Richard O'Keefe's advice I used structurally explicit forms
for some of my constructs.  An auxiliary program (in python) converts
from a friendlier form of input, so
input (external representation) -> internal representation
3/1/12 -> when(date(2012, 3, 1), seq(0))
myos~/a/b/c -> path([myos, a, b, c]).

portray then does the reverse mapping (even in the debugger, which is
quite nice).

My question is how I can get the first mappings for interactive queries.
E.g., now I must type
deep_descendants(path([oscorn1, usr, local, root]), when(date(2011,12,
28), seq(999)), G)
to get G (a graph).

I would like to be able to type
deep_descendants(oscorn1~/usr/local/root, 12/28/11#9999, G).

Is there a way to do that, or something close to it?

Maybe with some kind of helpers, e.g.,
make_when(12/28/11#9999, When), make_path(oscorn1~/usr/local/root,
Path), deep_descendants(Path, When, Graph).
But that's a little clunky, and maybe the arguments need to be strings.

Thanks.
Ross Boylan

P.S. I see Richard has a whole chapter in his "Craft of Prolog" about
findall, setof and bagof, which would have answered my earlier question
about them if I'd seen it.