6 ms·
Example-Driven Development
- deleted 10y ago[deleted]
- dleslie 10y agoOh cool! ;; Inputs (one per line): '(a b c d) ;; Desired output: '(1 2 3 4) ;; Suggestions: ;; No matches found. Damn :(
- dleslie 10y agoOn further inspection it seems severely limited: ;; Inputs (one per line): '(a b c d) ;; Desired output: '(a b) ;; Suggestions: ;; No matches found.
- bloaf 10y agoInteresting that this fails, since removing one element was an example they considered. Maybe they should include the length of the lists as "magic numbers" which they then use to generate functions. For example, here they might generate the functions take_the_first_2 and remove_the_last_(4-2) as candidates.
- lukeschlather 10y agoThe example they considered was removing the first element of the list, while that example is removing the last element. In terms of computational cost, this makes sense: removing the last element of a list in lisp takes linear time with the size of the list, while removing the first element takes constant time. (If you're returning a copy this is moot, but if you're modifying in-place this could be a problem.)
- azeirah 10y agoPerhaps this suggest thing could do with some kind of a genetic algorithm searching for new functions that seem to do the right thing..
- catnaroek 10y agoWould you actually want to use software written like this? You submit a bug report or feature request, and the maintainer tells you: “Okay, let's see whether my AI can make sense of it...”
- taneq 10y ago> “Okay, let's see whether my AI can make sense of it...” "I'll pass your feedback on to the devs" by any other name would sound as sweet.
- deleted 10y ago[deleted]
- bonniemuffin 10y agoThis is pretty neat. I've definitely spent hours scribbling examples on a sheet of paper trying to come up with the correct math to go from my desired input to output for one or a few examples of input/output. Two drawbacks to this kind of solution, that I can think of: (1) the examples I'm thinking of are pretty complicated and I can't imagine this could solve them for me, and (2) playing with numbers on a sheet of paper is kind of fun, and jumping straight to the answer would remove that bit of fun from my life.
- naveen99 10y agoIt's been posted before, but anyway: Flashfill from excel sdk: https://microsoft.github.io/prose/documentation/flashfill/usage/ https://microsoft.github.io/prose/documentation/flashfill/us... Keyword: program synthesis
- Nullabillity 10y agoHoogle[1] is also a pretty awesome example of this. It doesn't track the values themselves, but in Haskell there are usually only so many (sensible) functions for a given type which mitigates it a bit. [1]: https://www.haskell.org/hoogle/ https://www.haskell.org/hoogle/
- catnaroek 10y agoParametricity actually cuts the number of possible functions at a given type much more effectively than any small number of examples: http://cstheory.stackexchange.com/questions/19548/how-can-relational-parametricity-be-motivated http://cstheory.stackexchange.com/questions/19548/how-can-re...
- catnaroek 10y ago> “Hey $COLLEAGUE, is there any function that takes this list and returns a list like this?” Go back to your cubicle, grab a piece of paper, clarify your thoughts, describe what you want in the general case, provide at least 3 examples, possibly more of there are lots of tricky corner cases. And only then come back. Thanks.
- mberning 10y agoIf you like this you should look at the demos for Pharo. It takes this concept to another level. Very cool project.
- eonil 10y agoWhat if we combine this with AI?
- imh 10y agoI'm working on that! Long story short, it's hard. Most functions are big ones, and knowing where to look in the infinite set of functions is a big challenge. But it's a super fun problem :-)
- neilparikh 10y agoThere's also Magic Haskeller [0], which generates potential Haskell functions from predicates. It's surprisingly good. [0]: http://nautilus.cs.miyazaki-u.ac.jp/~skata/MagicHaskeller.html http://nautilus.cs.miyazaki-u.ac.jp/~skata/MagicHaskeller.ht...
- catnaroek 10y agoThe difference in sophistication between supplying individual individual examples and supplying predicates is like that between unit testing and property-based testing. One method is brutish, being invented by and for the abstraction-challenged; the other at least tries to investigate general properties of the desired solution.
- eru 10y agoI do agree with you, though I'd suggest being nicer about it if not in general then at least outside of preaching to the choir.
- vertex-four 10y agoThis is, overall, a huge issue with much of the Haskell and pure functional programming community that puts people off - there's a minority of people who view what the vast, vast majority of the world's programmers do as beneath them, and the programmers in question as stupid. The community doesn't appear to do enough to weed these people out.
- catnaroek 10y ago(0) I don't even like Haskell that much: https://news.ycombinator.com/item?id=12177685 https://news.ycombinator.com/item?id=12177685 (1) My original post is just a statement of fact about how abstraction skills shape one's testing strategies. Suggesting that this has anything to do with functional programming is a total non-sequitur.
- 10y ago
- hyperdeficit 10y agoI watched the video of a Pharo demo linked in the article and it was amazing. I don't know how much of that capability comes from the way Smalltalk is built vs just a clever IDE feature. I imagine this would be much easier to implement in a language with strong typing since the vast majority of possible matches could be ruled out with a simple signature check instead of evaluation. Having a feature like this would be very useful when teaching people how to program since it would help answer a lot of the basic questions that get asked.
- erdevs 10y agoConnecting something like this to github and other large public repos would be fun. Similarly for pseudocode rather than only ins/outs. Maybe code analysis for similar implementations to (or optimizations of) what you're in the middle of developing. Have long wondered about this, but never got around to dinking with it at all. Cool to see things along these lines.
- chaostheory 10y agoApple's Playground is another alternative https://developer.apple.com/swift/playgrounds/ https://developer.apple.com/swift/playgrounds/
- YeGoblynQueenne 10y agoIt feels strange saying this but finding a function from a set of inputs and a set of outputs is what machine learning is all about.
- catnaroek 10y agoNot all function spaces are equally easy to search. If you're looking for a continuous, possibly even monotonic, real map that approximates a given data set, fine, just perform a regression. If you want to attach one of finitely many tags to every element of a data set, fine, just use a clustering algorithm or perform a correspondence analysis. But, can you find higher-order functions using these techniques? Or can you find arbitrary computable functions on the integers using these techniques? Note that the integers don't have a very good notion of “sufficiently near”, unlike the reals.
- eru 10y ago> Note that the integers don't have a very good notion of “sufficiently near”, unlike the reals. You could use the p-adic norm. But that will probably not be the right notion for most applications.
- YeGoblynQueenne 10y agoMy bad, I misunderstood the intent behind this project (and I mixed it up in my mind with Barliman, elsewhere on HN at the time). This searches through a list of predefined (built-in?) functions and finds one that can match the given inputs and outputs. That sounds pretty cool and rather handy and although it's a form of machine learning (or function approximation in any case) it's not trying to sell itself off as anything it isn't, which was my initial concern. My bad for overreacting.
- whatgoodisaroad 10y agoThis seems to me like a less-formal (and consequently less powerful) implementation of type completion in dependent-type systems and theorem provers such as Agda or Coq.
- runeks 10y agoI believe you are correct. The advantage, on the other hand, is that you don't have to first acquire a PhD in mathematics and then learn Coq/Agda. Seriously though, simpler interfaces can add a lot of value, but only if the increase in ease of use makes up for the decrease in expressiveness.
- DanWaterworth 10y agoYou don't need a PhD to use dependent types. I don't have a Bachelor's.
- forgottenacc56 10y agoI've never had a problem tracking down the function or language construct I need with Google.