Clean up type inference.
I looked through it and it's actually not that bad. I hope if you read it alongside the notebook documenting it it's not too hard to grok.
Since the system only uses the type checker in the GUI at one call site, it might make sense to pull all the type info out of the library module into the type module, just to keep the library clean and readable. Really, I'd like to throw it out and delegate to Prolog. It would be a bit rich, sitting on TCL/Tk, Python, and Prolog, eh? On the other hand it's not that hard to install Python and SWI Prolog, and there's a Python-to-Prolog bridge lib.
If I delegate type checking to Prolog I might as well delegate evaluation too, since it's going to happen anyway.
At that point the GUI is a front-end for Prolog. Should I chuck the Joypy implementation in the bin?
Here's a query in Prolog:
sforman@bock:~/Desktop/ArchLayer/System/source/Thun$ swipl thun/thun.pl Warning: /home/sforman/Desktop/ArchLayer/System/source/Thun/thun/thun.pl:868: Singleton variables: [List,Item] Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.3) SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software. Please run ?- license. for legal details. For online help and background, visit http://www.swi-prolog.org For built-in help, use ?- help(Topic). or ?- apropos(Word). ?- joy(`23 18 +`, Si, So). So = [int(41)|Si] ; false. ?-
Using Pyswip:
In [1]: from pyswip import Prolog In [2]: prolog = Prolog() In [3]: prolog.consult('thun.pl') Warning: /home/sforman/Desktop/ArchLayer/System/source/Thun/thun/thun.pl:868: Singleton variables: [List,Item] In [4]: q = prolog.query('joy(`23 18 +`, Si, So)') In [5]: next(q) Out[5]: {'Si': Variable(102), 'So': [Functor(17838221,1,41)]} In [6]: next(q) --------------------------------------------------------------------------- StopIteration Traceback (most recent call last) <ipython-input-6-e98e88d97d37> in <module> ----> 1 next(q) StopIteration:
Ah well.
Pengines are promising, but more than I want to get into just to ditch the Python type stuff.
The code kind of got away from me at the end of the typing stuff, and then I got all into Prolog and neglected it more.
I'm tempted to rip it all out and make SWI-Prolog a hard dependency. It seems a shame, but the Prolog code is just so much more elegant that it almost hurts to look at the Python version.
I really really like having the GUI (written in Python/Tkinter (which of course is really TCL/Tk under the hood) be able to "know" whether to try to execute a word or not. At least you don't have to separately install TCL/TK like you would SWI Prolog (if I remove the Python type lib.)
In any event, the existing stuff is a mess. The library module is fugly and confusing. The docs are stale.