181 points · by dunefox · 4y ago · 45 comments
I hope holes & case-splitting get into many more languages.
Edit: it’s addressed in the Wingman’s landing page FAQ.
> Wingman is built on top of HLS, and that's the reason it doesn't require dedicated editor support.
The project’s source code also lives in HLS, as a plugin: https://github.com/haskell/haskell-language-server/tree/mast...
f :: YourTestInput -> CorrectAndPerformantAdventOfCodeSolution
f = _
---Seriously though, even after writing Haskell primarily for years, I've never done hole-driven development and I'm still not sure what I'm missing. I tried once — granted, that was a long time ago — but I didn't get it. This post[0] suggests I'm not alone in thinking this.
I'm glad Wingman exists and I think branding it nicely like this is the right thing to do, but I think I need to see more concrete examples to really see the magic. Probably something like Gary Bernhardt's Destroy All Software screencast series. It's one thing for someone to tell you that vim is fast, but it's another thing entirely watching the tool come to life in the hands of an expert. I imagine it's a similar thing for Wingman — I still have this mental block where I'm picturing the tool conjuring up an undefined for each hole, which is exactly what the documentation suggests the tool doesn't do. I would love to see someone use Wingman to quickly hammer out an Advent of Code puzzle, or even something more real-world like an Esqueleto query (but is that even possible?)
[0]: https://bitemyapp.com/blog/please-stop-using-typed-holes/
There are more fundamental objections to typed holes - but Wingman is kind of the answer to those concerns - with typed holes you're filling in types from the expressions, with Wingman you're doing pretty much the opposite - synthesizing programs from the type.
Now there might be usability issues with Wingman as well, but it represents a different direction - more suitable for type-driven development.
https://www.youtube.com/watch?v=y8OnoxKotPQ
https://www.youtube.com/watch?v=DYvhC_RdIwQ
Shout out to the Galactus team!
The way the tooling has progressed recently imo is that being proven in real-time.
Some other cool tooling advancements since then that come to mind are.. Nix integration (both nixpkgs and haskell.nix), ghc heapview, ghcjs, a glut of formatters, ghcid (is this that new?)
Generation with ML and then filtering with the typechecker/compiler for valid results could be a really powerful pair.
I think the key thing is that sometimes there are multiple ways to answer something. For example consider this type:
[Maybe a] -> [a]
It takes a list of optional values and returns non-optional values. The ‘obvious’ semantics in Haskell could be achieved with: f [] = []
f (Nothing:xs) = f xs
f (Just x:xs) = x:f xs
And there are plenty of other ways to write that function. But you could also write functions like g xs = []
h xs = reverse (f xs)
j [Just a, Just b] = [b, a, b]
j _ = []
And all three would satisfy the type above. So the type may be a sufficient input to the tool as the programmer may select the suggestion, but it wouldn’t be sufficient input to the compiler as the compiler could just guess the wrong thing.In this situation, choosing “Fill in hole”, Wingman always just fails with a “ran out of gas”-error.
(Using GHC 8.10.7)
Sure, it's easy money, but also boring, lol
I then had the realization that if someone manages to genuinely automate programming, humans will wind up still being in the loop to confirm that the generated code is reasonable under the hood, and to be sure we have people who understand what it's doing and why.
If I'm right about that, code review chops will be worthwhile in the long haul.
Of course, there is just that existential risk that the machines recognizes the profit distributions we are taking are negatively impacting their margins - and ability to survive. :(
Where all this goes, nobody knows! But it won't be boring.