OSDN Git Service
Simon Forman [Sun, 21 Jul 2019 14:32:20 +0000 (07:32 -0700)]
Tiny edits. Almost nothing.
Simon Forman [Sun, 21 Jul 2019 02:34:56 +0000 (19:34 -0700)]
Remove cuts from branch combinator.
Simon Forman [Sun, 21 Jul 2019 02:26:11 +0000 (19:26 -0700)]
Add mod, gcd, and hypot; term_expansion for math ops.
Simon Forman [Sun, 21 Jul 2019 00:36:58 +0000 (17:36 -0700)]
Fold try_both_branches/4 into branch combo.
Simon Forman [Sun, 21 Jul 2019 00:32:03 +0000 (17:32 -0700)]
Replace ? with plain ol' def/2.
As much fun as it was using ? as an operator, now that all the defs live in a text file you don't see it in the Prolog code anymore.
This way I get to use sweet sweet ASCII (except for the ? symbol in the copyright notice.)
Simon Forman [Sun, 21 Jul 2019 00:19:35 +0000 (17:19 -0700)]
WTF error handler.
Made it check that the unknown term really isn't a literal, definition, function, or combinator.
Simon Forman [Sat, 20 Jul 2019 23:57:19 +0000 (16:57 -0700)]
If I comment out the WTF handler...
...then the branch combinator works as intended. (Although the constraint-based stuff was also cool, it would have captured information from the comparison.)
?- joy(`[32 >] [++] [--] ifte`, Si, So).
Si = [_6598|_6600],
So = [_6598+1|_6600] ;
Si = [_6598|_6600],
So = [_6598-1|_6600] ;
false.
?- sjc(hmm, `[32 >] [++] [--] ifte`).
func(hmm, [A|B], [A+1|B]).
true ;
func(hmm, [A|B], [A-1|B]).
true ;
false.
Simon Forman [Sat, 20 Jul 2019 23:45:28 +0000 (16:45 -0700)]
Try to handle expressions in branch combinator.
If the expression isn't 'true' or 'false' atoms then we assume it's a comparison expression and try to check its truth value.
If this fails then it will try both branches, to allow for e.g. compilation. THis almost works, but there's a choice point or something that gets hit before it tries the false path,
?- joy(` [32 >] [++] [--] ifte`, Si, So).
Si = [_2076|_2078],
So = [_2076+1|_2078] ;
wtf? +
Si = [_2076|_2078],
So = [[+], 1, _2076|_2078] ;
Si = [_2076|_2078],
So = [_2076-1|_2078] ;
wtf? -
Si = [_2076|_2078],
So = [[-], 1, _2076|_2078] ;
wtf? branch
Si = [_2076|_2078],
So = [[branch], [++], [--], _2076>32, _2076|_2078] ;
wtf? swap
Si = [_2076|_2078],
So = [[swap, branch], [--], [++], _2076>32, _2076|_2078] ;
wtf? first
Si = [_2076|_2078],
So = [[first, [++], [--], swap, branch], [_2076>32|_2078], _2076|_2078]
etc...
Simon Forman [Sat, 20 Jul 2019 23:38:48 +0000 (16:38 -0700)]
Handle exceptions in comparison ops.
You can't compare logic vars, so just bunt.
Simon Forman [Tue, 16 Jul 2019 16:53:48 +0000 (09:53 -0700)]
More readable genrec.
Explicit quoting is slightly more overhead but worth it I think to show what's going on more clearly.
Simon Forman [Tue, 16 Jul 2019 16:46:55 +0000 (09:46 -0700)]
A little helper function to see compiled expressions.
Example from ordered binary tree notebook:
?- sjc(tree_add_Ee, `pop swap rolldown rrest ccons`).
func(tree_add_Ee, [_, [_, _|C], A, B|D], [[A, B|C]|D]).
true .
Simon Forman [Tue, 16 Jul 2019 15:59:24 +0000 (08:59 -0700)]
Clear out CLP(FD) functions.
I like them but then you are constrained (pun intended) to only using integers. I'll probably bring them back at some point, either as an alternate implementation or their own commands.
Simon Forman [Tue, 16 Jul 2019 15:42:45 +0000 (08:42 -0700)]
Opps! Here's the implementation of bool.
Simon Forman [Tue, 16 Jul 2019 15:41:28 +0000 (08:41 -0700)]
Add bool function to mimic Python semantics.
Simon Forman [Tue, 16 Jul 2019 06:02:08 +0000 (23:02 -0700)]
Change comparison ops to not use CLP(FD).
Simon Forman [Tue, 16 Jul 2019 03:55:41 +0000 (20:55 -0700)]
Implement genrec combinator.
Simon Forman [Tue, 16 Jul 2019 03:55:11 +0000 (20:55 -0700)]
Minor cleanup of defs.
Simon Forman [Mon, 15 Jul 2019 23:11:49 +0000 (16:11 -0700)]
Move all definitions to defs.txt.
Simon Forman [Mon, 15 Jul 2019 23:01:59 +0000 (16:01 -0700)]
Retract previous definitions before asserting new ones.
Simon Forman [Mon, 15 Jul 2019 22:53:07 +0000 (15:53 -0700)]
Load definitions from a file.
This paves the way to regularize the defs between Python and Prolog (and and future other) implementations.
Simon Forman [Mon, 15 Jul 2019 22:50:22 +0000 (15:50 -0700)]
Very minor docs change.
Simon Forman [Mon, 15 Jul 2019 19:53:48 +0000 (12:53 -0700)]
Parse joy definitions from text.
This way a definitions file can be shared between Python Joy and Prolog Joy.
Simon Forman [Mon, 15 Jul 2019 19:28:01 +0000 (12:28 -0700)]
New combinator infrst == infra first
Three uses means it's time for a refactor.
Simon Forman [Mon, 15 Jul 2019 18:20:13 +0000 (11:20 -0700)]
nullary combinator as definition.
That eliminates all the recursive calls to thun/3 (outside of thun itself, which is tail recursive.) That means that this Joy interpreter is now fully CPS.
All state is contained in the stack and expression, nothing is hidden in the Prolog "call stack".
Simon Forman [Mon, 15 Jul 2019 06:02:10 +0000 (23:02 -0700)]
Infra as definition.
Simon Forman [Mon, 15 Jul 2019 05:48:18 +0000 (22:48 -0700)]
Reimplement app1 and app2 as definitions.
This eliminates three recursive calls to thun/3.
Simon Forman [Mon, 15 Jul 2019 04:58:20 +0000 (21:58 -0700)]
Got enough definitions, sort them.
Simon Forman [Mon, 15 Jul 2019 04:14:50 +0000 (21:14 -0700)]
Switch to symbolic math (from CLP(FD).)
A wee bit of error reporting of unknown terms.
New functions: pm plus-or-minus and neg negate; new combinator dupdip.
Simon Forman [Wed, 8 May 2019 06:23:53 +0000 (23:23 -0700)]
Docs on Start Up Sequence
Simon Forman [Wed, 8 May 2019 00:45:39 +0000 (17:45 -0700)]
Stop hg ignoring the build dir.
I want to include the HTML output of sphinx so you can view it without having to install sphinx.
Simon Forman [Tue, 7 May 2019 20:49:27 +0000 (13:49 -0700)]
More docs...
Simon Forman [Tue, 7 May 2019 17:23:43 +0000 (10:23 -0700)]
A bit more on the docs.
Simon Forman [Tue, 7 May 2019 17:00:52 +0000 (10:00 -0700)]
Move VUI package/module graph.
Simon Forman [Tue, 7 May 2019 06:06:36 +0000 (23:06 -0700)]
screenshot
Simon Forman [Tue, 7 May 2019 06:05:50 +0000 (23:05 -0700)]
A start on docs for VUI.
It's hella crude yet.
Simon Forman [Tue, 7 May 2019 02:43:36 +0000 (19:43 -0700)]
Welcome to the Sphinx 1.8.5 quickstart utility.
Simon Forman [Tue, 7 May 2019 02:08:48 +0000 (19:08 -0700)]
Rebuilt MANIFEST file.
Simon Forman [Mon, 6 May 2019 20:54:55 +0000 (13:54 -0700)]
Use ~/.thun instead of ~/.joypy as default JOY_HOME.
And some copyright notices I missed.
Simon Forman [Mon, 6 May 2019 20:32:08 +0000 (13:32 -0700)]
Well, that seems to work.
python -m joy.vui
With PyGame installed that starts the "VUI" on my system. Neat.
The initial joy home (~/.joypy) is not quite compatible with the one set up by the GUI code. One simple way to fix that would be to e,g, make this use ~/.thun instead.
Simon Forman [Mon, 6 May 2019 20:28:44 +0000 (13:28 -0700)]
Update initial joy home dir contents BLOB.
Simon Forman [Mon, 6 May 2019 20:26:07 +0000 (13:26 -0700)]
Update imports, copyright notices.
Simon Forman [Mon, 6 May 2019 20:09:45 +0000 (13:09 -0700)]
Some images generated by pyreverse or whatever.
Simon Forman [Mon, 6 May 2019 20:07:01 +0000 (13:07 -0700)]
Initial bring over of VUI code. (Won't work yet.)
Simon Forman [Mon, 6 May 2019 19:47:30 +0000 (12:47 -0700)]
See https://www.metalevel.at/acomip/
Simon Forman [Sat, 4 May 2019 14:53:02 +0000 (07:53 -0700)]
Minor cleanup.
Simon Forman [Sat, 4 May 2019 13:57:14 +0000 (06:57 -0700)]
Change name from alpha to tmi.
Simon Forman [Fri, 3 May 2019 22:21:29 +0000 (15:21 -0700)]
A Tracing Meta-Interpreter for Thun
Simon Forman [Fri, 3 May 2019 22:21:06 +0000 (15:21 -0700)]
Some docs, and a thing to print out the dictionary after compilation.
Simon Forman [Fri, 3 May 2019 03:39:30 +0000 (20:39 -0700)]
Minor cleanup and comments.
Simon Forman [Thu, 2 May 2019 19:41:23 +0000 (12:41 -0700)]
linker//1 works on ASM not IR. (rename variable)
Simon Forman [Thu, 2 May 2019 19:33:52 +0000 (12:33 -0700)]
Add some comments, minor rearrangement.
Simon Forman [Thu, 2 May 2019 17:18:58 +0000 (10:18 -0700)]
Make get//1 handle lists of pairs which it passes off to get//2.
(I could remove more punctuation by making the (key, value) pairs implicit.)
Move compile_program//2 to just under do//0.
Simon Forman [Thu, 2 May 2019 15:38:15 +0000 (08:38 -0700)]
Minor cleanup.
Remove the pass0//2 DCG rule and unfold it in compile_program//2 rule. Move init//0 to be with the rest of the state DCG code.
Simon Forman [Thu, 2 May 2019 04:55:46 +0000 (21:55 -0700)]
Minor cleanup.
It turns out that the binary_number relation is used in such a way that it needs to be able to backtrack to preprend leading zeros to the list of bits it constructs to automatically build bitfields of a given width (with the collect//2 DCG.)
Simon Forman [Sun, 28 Apr 2019 15:16:38 +0000 (08:16 -0700)]
binary_number/2 is more efficient if you strip off 0's first.
Simon Forman [Sun, 28 Apr 2019 14:59:47 +0000 (07:59 -0700)]
Bring in the (sort of) compiler.
Simon Forman [Sat, 27 Apr 2019 05:13:45 +0000 (22:13 -0700)]
Very minor cleanup.
Simon Forman [Sat, 27 Apr 2019 04:58:15 +0000 (21:58 -0700)]
Treat defs in thun/3 relation.
Allow for "compilation" of new func/3 rules.
Add comment of crude grammar for Joy syntax.
Minor rearrangements.
show_joy_compile uses portray_clause/1.
Simon Forman [Sat, 25 Aug 2018 00:05:42 +0000 (17:05 -0700)]
I just want to publish this right quick.
Simon Forman [Fri, 24 Aug 2018 23:52:00 +0000 (16:52 -0700)]
The Prolog version of Joy.
Simon Forman [Fri, 24 Aug 2018 23:48:15 +0000 (16:48 -0700)]
A bunch of docs.
Things have kind of run away with me. I've been working in Prolog for
the last month or so. I'm not yet sure how to bring it together with the
Python code.
Simon Forman [Fri, 24 Aug 2018 23:46:18 +0000 (16:46 -0700)]
The version of Python with Anaconda is lightly newer.
Simon Forman [Thu, 2 Aug 2018 21:22:42 +0000 (14:22 -0700)]
Add binary functions.
Simon Forman [Wed, 1 Aug 2018 19:26:50 +0000 (12:26 -0700)]
In progress..
Simon Forman [Wed, 1 Aug 2018 17:59:07 +0000 (10:59 -0700)]
Working on compiler.
I have a simple dataflow thingy for some Yin and Yang functions.
Simon Forman [Sun, 22 Jul 2018 18:53:02 +0000 (11:53 -0700)]
Minor UI bugs.
I should nail this down better. Command selections like ' []' were
failing to evaluate.
Simon Forman [Sun, 22 Jul 2018 18:51:47 +0000 (11:51 -0700)]
Oh python, oh unicode.
Simon Forman [Sun, 22 Jul 2018 18:50:34 +0000 (11:50 -0700)]
Load JOY_HOME/definitions.txt
You still can't edit other text files from within the UI, but at least
now you have a place to persist your own definitions over restarts.
I thought about having a [definitions] section in the config INI file,
but for some reason I prefer a separate definitions.txt file. I dunno.
Might change it in future.
Simon Forman [Sun, 22 Jul 2018 17:14:45 +0000 (10:14 -0700)]
TEXT_BINDINGS stay in textwidget.py.
Simon Forman [Sun, 22 Jul 2018 03:19:38 +0000 (20:19 -0700)]
Rework the default JOY_HOME contents.
Simon Forman [Sun, 22 Jul 2018 00:56:53 +0000 (17:56 -0700)]
Config file and CLI arg parser.
Simon Forman [Fri, 20 Jul 2018 19:33:06 +0000 (12:33 -0700)]
Loop and while combinators.
Simon Forman [Thu, 19 Jul 2018 22:37:35 +0000 (15:37 -0700)]
Futzing with types.
Simon Forman [Thu, 19 Jul 2018 22:18:42 +0000 (15:18 -0700)]
Getting back to parity after jumble.
Polytypes module folded into types module, with all the actual type
information done when you load the library module. Some definitions can
be inferred from their body expression, others need to be
CombinatorJoyType wrapped. Still to do: loop.
Simon Forman [Thu, 19 Jul 2018 19:38:19 +0000 (12:38 -0700)]
Working to get types right.
Simon Forman [Thu, 19 Jul 2018 00:47:19 +0000 (17:47 -0700)]
Fix TextJoyType inheritance.
Simon Forman [Thu, 19 Jul 2018 00:06:51 +0000 (17:06 -0700)]
Log types at startup.
Simon Forman [Wed, 18 Jul 2018 23:14:32 +0000 (16:14 -0700)]
Add some logging.
Simon Forman [Wed, 18 Jul 2018 23:13:57 +0000 (16:13 -0700)]
Cache the results of type checking.
Simon Forman [Wed, 18 Jul 2018 21:55:39 +0000 (14:55 -0700)]
Removing polytypes; some pylint hints.
Simon Forman [Wed, 18 Jul 2018 03:52:57 +0000 (20:52 -0700)]
Definitions infer stack effects.
At start-up defs that DON'T type check are permitted (so you can use e.g.
loop, map, etc.) in the definitions "source", but then the user-facing
inscribe command only allows you to define new commands that DO
type-check. The ideal solution here is to get inference working for the
loopy words. (In the meantime you can select and execute their
definition text directly. That's not (yet!) type-checked.)
Simon Forman [Wed, 18 Jul 2018 03:09:17 +0000 (20:09 -0700)]
Nearly there maybe, maybe not.
Simon Forman [Wed, 18 Jul 2018 00:12:27 +0000 (17:12 -0700)]
Moving right along.
A little clunky but it seems to work so far.
Simon Forman [Tue, 17 Jul 2018 19:43:24 +0000 (12:43 -0700)]
So fra, so good...
Simon Forman [Tue, 17 Jul 2018 17:49:09 +0000 (10:49 -0700)]
i got used to it, but Jupyter likes 4
Simon Forman [Tue, 17 Jul 2018 17:47:50 +0000 (10:47 -0700)]
in the middle, just want to 2ify my indents...
Simon Forman [Tue, 17 Jul 2018 17:35:11 +0000 (10:35 -0700)]
TextJoyType and inscribe command.
I took the plunge and added the meta-command "inscribe" to the library.
This is, of course, a very dangerous and powerful command. Use it
wisely.
Simon Forman [Tue, 17 Jul 2018 03:28:53 +0000 (20:28 -0700)]
A few more stack effects.
Simon Forman [Tue, 17 Jul 2018 02:10:16 +0000 (19:10 -0700)]
expectations_of_definition() and some helper infer funcs.
Simon Forman [Tue, 17 Jul 2018 01:43:40 +0000 (18:43 -0700)]
More stack effects, and modify the key bindings.
Simon Forman [Mon, 16 Jul 2018 16:11:25 +0000 (09:11 -0700)]
Update docs.
Simon Forman [Mon, 16 Jul 2018 03:43:26 +0000 (20:43 -0700)]
Make sure we've got all the docs, etc.
Simon Forman [Mon, 16 Jul 2018 03:37:52 +0000 (20:37 -0700)]
Fix bugs
Type checking e.g. sum or product.
Any type accepts complex numbers.
Lots of the math functions now just use Number rather than more specific
poly-types.
Simon Forman [Sun, 15 Jul 2018 21:06:10 +0000 (14:06 -0700)]
That "fix" wasn't a fix.
It broke other stuff. What I really wanted to do was change the stack
effect of 'clear'.
Simon Forman [Sun, 15 Jul 2018 20:57:11 +0000 (13:57 -0700)]
Fix up stacks for type checking.
Sometimes (e.g. 'clear') the () at the end of the stack was tripping up
the unify() function.
Simon Forman [Sun, 15 Jul 2018 18:48:08 +0000 (11:48 -0700)]
Some integration with Type Checking.
Now the UI highlights commands and numbers as you move the mouse, numbers
are blue, commands that type-check are green, commands that fail to
type-check are orange and will not be interpreted, and if there is no
stack effect information available for a command it is grey but you can
still attempt to execute it.
You can still evaluate whole expressions by selceting them and
right-inter-clicking before you release the left button, or by putting
the cursor on a line and typing ctrl-enter, which will run the whole
line. These expressions are NOT (yet) type-checked.
Simon Forman [Sun, 15 Jul 2018 03:58:43 +0000 (20:58 -0700)]
Much globals. Wow.
Simon Forman [Sun, 15 Jul 2018 03:55:34 +0000 (20:55 -0700)]
Minor cleanup.
Simon Forman [Sun, 15 Jul 2018 03:47:04 +0000 (20:47 -0700)]
Move load_stack() to StackDisplayWorld.
Simon Forman [Sun, 15 Jul 2018 02:51:31 +0000 (19:51 -0700)]
Move StackDisplayWorld into world.py