Justin Blank
07/14/2019, 4:22 PMFoo
. To do that, I need a Bar
, a Baz
and a Frob
, so then I have to figure out how to construct each of those. Maybe Bar
is available from a local variable, I have a getter for a Baz
, but I have to build the Frob
out of some other bits I have.
I had the idea of a tool that constructs various recipes for getting to your target type based on the local variables and functions you have in scope. Sort of a multi-stage autocomplete. Do any of you know if this is an idea that’s been explored?Garth Goldwater
07/14/2019, 4:48 PMJustin Blank
07/14/2019, 4:51 PMJustin Blank
07/14/2019, 4:52 PMJustin Blank
07/14/2019, 5:17 PMPhilipp Krüger
07/14/2019, 6:27 PMJustin Blank
07/14/2019, 6:36 PMKartik Agaram
Provider
. But using it only convinced me that tooling here is deeply counter-productive. Making it easy to construct nouns only digs you deeper into the Kingdom of Nouns.[1] Soon things suck just as much as before, except now your old approaches to manage the problem no longer work. No, the solution lies in the other direction, in treating huge graphs of objects as a code smell that indicates bad design.
[1] https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.htmlDrewverlee
07/14/2019, 10:21 PMDrewverlee
07/14/2019, 10:22 PMalltom
07/15/2019, 5:31 AMThe second interface is an extension to autocomplete, where the system replaces keywords in a text editor with syntactically correct code. This interface is aimed more at expert programmers using an integrated development environment (IDE). As an example of this interface, imagine that a programmer wants to add the next line of text from a stream to a list, using Java. A sloppy completion interface would let them enter "add line" and the system might suggest something like "lines.add(in.readLine())".Maybe skip down to the “Quack Eclipse Plugin” heading.
Justin Blank
07/15/2019, 12:49 PMclass Thing {
private Baz baz;
private String s;
Foo doStuff(Bar bar) {
// what goes here
}
I’d want to synthesize:
Foo doStuff(Bar bar) {
Frob frob = new Frob(s);
return new Foo(bar, baz, frob);
}
Justin Blank
07/15/2019, 12:51 PMFrob
, and can get one, given what I have. In general, if it’s a common type like String
, you’ll probably have to introduce a template, or placeholder argument, as you won’t be able to know which String
is appropriate. But for more specific types, you have a reasonable chance of guessing correctly.Justin Blank
07/15/2019, 12:52 PMStefan
07/15/2019, 1:09 PM_
where you want the compiler to tell you which type it expects. Details and example here: https://wiki.haskell.org/GHC/Typed_holes
As far as I know all you get from Haskell at this point is the expected type and a list of types “in scope” at that point. Idris, I believe, is a language that takes this further and tries to suggest what code you’re likely to write, and also supports this with a feature called “interactive editing”. I haven’t used Idris, so I don’t know how good it is at inferring the correct type if it is not trivial and needs some indirection, as in your example.Drewverlee
07/15/2019, 1:40 PMalltom
07/15/2019, 3:58 PMStefan
07/15/2019, 4:05 PMKartik Agaram
Garth Goldwater
07/15/2019, 6:58 PMJustin Blank
07/15/2019, 7:14 PMcore.logic
..curious why you specifically mention miniKanren?Alex Miller
07/15/2019, 7:37 PM