Ticket #40397

Clean up type inference.

Date d'ouverture: 2020-05-10 01:51 Dernière mise à jour: 2020-05-17 05:10

Rapporteur:
Propriétaire:
État:
Atteints
Composant:
Priorité:
3
Sévérité:
3
Résolution:
Won't Fix
Fichier:
Aucun

Détails

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.

Ticket History (3/7 Histories)

2020-05-10 01:51 Updated by: sforman
  • New Ticket "Clean up type inference." created
2020-05-11 09:01 Updated by: None
2020-05-17 02:00 Updated by: sforman
Commentaire

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.

2020-05-17 03:17 Updated by: sforman
Commentaire

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?

2020-05-17 03:48 Updated by: sforman
Commentaire

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.

2020-05-17 05:01 Updated by: sforman
Commentaire

Pengines are promising, but more than I want to get into just to ditch the Python type stuff.

2020-05-17 05:10 Updated by: sforman
  • Résolution Update from Aucun to Won't Fix
  • État Update from Ouvert to Atteints

Attachment File List

No attachments

Modifier

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Connexion