Replies: 3 comments 6 replies
-
Beta Was this translation helpful? Give feedback.
-
|
There is already Hindley-Milner type system implemented for SWI: https://www.swi-prolog.org/pack/list?p=type_check, we can port it to Scryer. |
Beta Was this translation helpful? Give feedback.
-
|
@jjtolton , a lot of what you're describing sounds like dependent types. I scroll down and see you're looking at Idris. That's the right track to be on. Seems as good a time as any to remind people of my own whack at this topic: https://github.com/mthom/scryer-shen I'm rewriting the Lisp side of the system in Common Lisp. Racket is a nicer and more elegant language than CL in many respects but I found I couldn't quite push it in the direction I want to go. The most ambitious is a stepwise proof tree visualizer allowing the user to pinpoint exactly where a proof went wrong (or right) in nicely rendered typography. The most opaque part of Shen is probably its very powerful but opaque type search process. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I'm looking for help with clarifying terminology on a category of problems that seem to relate to Prolog meta-interpreter work. I am interested in demonstrating how Prolog can be used for interesting type system work. (Note: that I am not suggesting the introduction of static types to Prolog, what I mean is that Prolog can be used to verify interesting properties of programs meant to be interpreted via meta-interpretation.)
The beauty of a meta-interpreter is that it can take the same code and execute it in a number of different ways. However, generally you cannot splice together meta-interpreters and expect them to work coherently.
Problem one: Type constraints
To make the example more concrete, let's say I have some code C that represents a user interface. Let's say I have a set of meta-interpreters that generate code suitable to translate C into React, vanilla JavaScript, or HTML5 canvas. Each of these would have the same set of features --
buttons,menus,tables, etc, which are all semantically encoded in C.Now let us focus in on the
typeof abuttonin C. It is clear that thetypeofbuttoncannot be considered in isolation. HTML5 canvas and React are for the most part incompatible user interface technologies, and I believe that any effort to make these two technologies work together in a general manner would be needlessly convoluted. (regardless of whether or not you believe this statement to be true, I request that we accept as a premise that there exist a set of componentscomponents(A)andcomponents(B)whereAandBare internally coherent but not interchangeable with the other)Going back to the
button, again it seems clear to me that thetypeofbutton-- thetypeofbuttonseems to depend on thetypeof all the other components in the set -- those that would be naturally generated by an internally consistent meta-interpreter. So once thetypeofbuttonis constrained by the choice of concrete type by another component, then we can know the concrete type of thebutton.However it is also clear that
buttonis a distinct thing fromtable, so it is not the case thatbuttoncan just be ANY type. At the very least it needs to be mutually exclusive fromtable.Problem two: descriptive or semantic typing
I am not sure that this problem is even a computable problem and not an aesthetic problem, but it is fairly clear (to me, anyway) that a
tableis not abutton. Even if we solve Problem 1, and we have a language that says "the type ofbuttondepends on the type oftable" and vice versa, this does not necessarily solve the problem of abuttonmust satisfy the semantic properties ofbuttonin all incarnations ofbuttonand atablemust satisfy all semantic properties of atablefor all manifestations oftable.In other words, what would make me certain that the React version of a
tableand the Canvas version of atablewould both have a title, rows, and columns? Or that abuttonisclickable? It seems like we must do more than simply "tag" abuttonas a "button" and atableas a "table".Here is another perhaps more concrete example -- if you are sending an HTTP Request, the final output might be a
stringorbytes. But it is clear that not ANYstringorbyteswill do -- it must be compliant with with the RFC standards for HTTP requests. This is a much more specific constraint thatstringorbytes.Problem three: type dependencies
The simplest version of this I can think of is
foo(A,B), but there is a constraint thatAmust be an integer and less thanB. We could of course check this at run time but that doesn't let us reason about the properties of the program itself.Or imagine a pair of functions,
foo(A,B)andbar(X,Y). We could imagine a more complex set of dependencies, but to keep it simple we could say thatA < B if X < Y(or variations on that them).Recap:
I am sure someone has probably thought of these problems before, and it has probably even been done in Prolog. But these are all just vague, fuzzy, imprecise observations problems I have run into and I would love some more formal terminology on these things if anyone has knowledge of them.
So I suppose the three categories of problems I'm curious about:
I realize this is very vague, it has taken me awhile just to formulate the question. If anyone has any leads on resources, I would be quite appreciative!
Beta Was this translation helpful? Give feedback.
All reactions