
Example-Driven Development - jsnell
http://www.wilfred.me.uk/blog/2016/07/30/example-driven-development/
======
Nullabillity
Hoogle[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
Parametricity 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-
re...](http://cstheory.stackexchange.com/questions/19548/how-can-relational-
parametricity-be-motivated)

------
naveen99
It's been posted before, but anyway: Flashfill from excel sdk:
[https://microsoft.github.io/prose/documentation/flashfill/us...](https://microsoft.github.io/prose/documentation/flashfill/usage/)

Keyword: program synthesis

------
neilparikh
There'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.ht...](http://nautilus.cs.miyazaki-u.ac.jp/~skata/MagicHaskeller.html)

~~~
catnaroek
The 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
I 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
This 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.

~~~
mbrock
I think there's a mistake in imagining that there is a Haskell community or a
pure functional programming community and that people you come across
represent these communities.

Like, I'm a fan of the language, I do stuff with it, I worked with in
professionally, I chose my school specifically to pursue it in 2005...
sometimes I discuss topics related to it on the internet... but I don't really
see myself as a "community member," I don't represent a community when I
discuss, and the comments you're reacting to have nothing to do with me or my
values.

So if stuff I say is taken as representing some "community", that's ascribing
a false belonging and imagining a society where there's mostly just a loose
association of different individual nerds who sometimes collaborate in
different constellations.

Unless there's something systemically and blatantly wrong with some actual
existing community project, I think it makes more sense to criticize
individuals. There's no way to "weed out" people from the internet just
because their tone is annoying.

~~~
vertex-four
The thing is, people gravitate to languages where they can learn about the
language and its ecosystem from people they can get along with. Many people
avoid confrontation - especially when they're trying to learn about something.

If you don't get along with dudebros, you're going to avoid languages where
the IRC channels and forums and random online discussion about the language is
populated by dudebros - if you don't get along with people who speak
aggressively, you're going to avoid languages which you see people speaking
aggressively in support of - if you're really not a fan of active community
management a la codes of conduct, you're going to avoid languages where their
users speak in favour of such things.

Rinse and repeat a bunch of cycles, and whether there's a formal community or
not, there's a type of person who permeates discussion of the language and its
ecosystem, and is generally accepted by users of the language. Attempting to
avoid them is difficult, because the existing language users see no problem,
so you're stuck with a very limited number of places to learn, interact, and
ask questions without coming across them.

I don't think the people in question represent the community as a whole, but
they do represent what I'm signing up for when I need to communicate about the
language with others - in Haskell's case, there's a higher chance than with
most languages that I'm going to come across people who will proclaim I'm
stupid if I don't immediately and from birth know why XYZ abstraction is
amazing and universally good. And god forbid I disagree.

~~~
tome
> in Haskell's case, there's a higher chance than with most languages that I'm
> going to come across people who will proclaim I'm stupid if I don't
> immediately and from birth know why XYZ abstraction is amazing and
> universally good

It's terribly sad if this is true because it wasn't the case before.
Haskellers used to be very welcoming and very tolerant of beginners struggling
with the language, because we had all been through the same struggles
ourselves. I hope I'm correct when I say that the two public Haskell fora that
I participate in (Haskell Reddit and haskell-cafe) would never proclaim anyone
as stupid.

------
bonniemuffin
This 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.

------
hyperdeficit
I 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.

------
YeGoblynQueenne
It 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
Not 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
> 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.

------
mberning
If you like this you should look at the demos for Pharo. It takes this concept
to another level. Very cool project.

------
whatgoodisaroad
This 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
I 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
You don't need a PhD to use dependent types. I don't have a Bachelor's.

------
dleslie
Oh cool!

    
    
      ;; Inputs (one per line):
      '(a b c d)
    
      ;; Desired output:
      '(1 2 3 4)
    
      ;; Suggestions:
      ;; No matches found.
    

Damn :(

~~~
azeirah
Perhaps this suggest thing could do with some kind of a genetic algorithm
searching for new functions that seem to do the right thing..

~~~
catnaroek
Would 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
> “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.

------
erdevs
Connecting 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.

------
catnaroek
> “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.

------
chaostheory
Apple's Playground is another alternative

[https://developer.apple.com/swift/playgrounds/](https://developer.apple.com/swift/playgrounds/)

------
forgottenacc56
I've never had a problem tracking down the function or language construct I
need with Google.

------
eonil
What if we combine this with AI?

~~~
imh
I'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 :-)

