searching a function by providing examples of input/ouput pairs

Hi, I was looking at hoogle documentation when I remembered that there is some nice, but quite unusable, feature of squeak (smalltalk) which allows you to search function in the library by giving a list of pairs of inputs/ouputs. When I'm saying that it is quite unusable, I mean that squeak has to try _every_ function, some of which may be very slow to deliver a result, or require some side effects. But, piggibacking such a feature on top of hoogle would surely be more efficient: 1. infer types for arguments and outout 2. look for matching functions using google 3. test them Has anyone tried that before? If not I would be glad to. Paul

Sounds great!
Here are a few feature requests:
The I/O pair ([-1,4,-6],[1,4,6]) could yield "map abs" as a suggestion :)
The pairs ('a',False) and ('*',True) could yield "not . isAlpha" etc.
I realize that this (at least the composition part) will probably
increase complexity beyond what's acceptable...
/Jonas Duregård
On 18 March 2010 09:13, Paul Brauner
Hi,
I was looking at hoogle documentation when I remembered that there is some nice, but quite unusable, feature of squeak (smalltalk) which allows you to search function in the library by giving a list of pairs of inputs/ouputs.
When I'm saying that it is quite unusable, I mean that squeak has to try _every_ function, some of which may be very slow to deliver a result, or require some side effects.
But, piggibacking such a feature on top of hoogle would surely be more efficient:
1. infer types for arguments and outout 2. look for matching functions using google 3. test them
Has anyone tried that before? If not I would be glad to.
Paul _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Paul Brauner wrote:
feature [...] to search function in the library by giving a list of pairs of inputs/ouputs. [...]
But, piggibacking such a feature on top of hoogle would surely be more efficient:
1. infer types for arguments and outout 2. look for matching functions using google 3. test them
Sounds cool. Maybe you could use quickcheck properties instead of input-output-pairs. And what about using djinn to handle functions and algebraic data types? Tillmann

On Mar 18, 2010, at 9:13 PM, Paul Brauner wrote:
Hi,
I was looking at hoogle documentation when I remembered that there is some nice, but quite unusable, feature of squeak (smalltalk) which allows you to search function in the library by giving a list of pairs of inputs/ouputs.
The MethodFinder lets you _seek_ or search _for_ methods. It can even cope with permuted arguments. The query 2. 8. 4. produces answers 8 / 2 --> 4 8 // 2 --> 4 8 quo: 2 --> 4
When I'm saying that it is quite unusable, I mean that squeak has to try _every_ function, some of which may be very slow to deliver a result, or require some side effects.
Actually, no it _doesn't_ try every function. It has a long set of methods *not* try, whether because they are dangerous or because they are slow. And it is by design quite easy to extend this set. The query MethodFinder methodFor: #( ('time' 'timeOfDay') true) (intended answer #beginsWith: with the arguments swapped) runs in 24 milliseconds. Smalltalk has exception handling and timeouts, so methods that crash on the given arguments aren't a problem, and methods that take a long time are not a problem either. And they would not be a problem for Haskell. Methods that make unpleasant changes to the system state *could* be a problem but so far I haven't found it so; here of course Haskell does very well. I don't know whether the Haskell version of this considers permuting the arguments; perhaps not.

On Thu, Mar 18, 2010 at 09:13:40AM +0100, Paul Brauner wrote:
Hi,
I was looking at hoogle documentation when I remembered that there is some nice, but quite unusable, feature of squeak (smalltalk) which allows you to search function in the library by giving a list of pairs of inputs/ouputs.
When I'm saying that it is quite unusable, I mean that squeak has to try _every_ function, some of which may be very slow to deliver a result, or require some side effects.
But, piggibacking such a feature on top of hoogle would surely be more efficient:
1. infer types for arguments and outout 2. look for matching functions using google 3. test them
Has anyone tried that before? If not I would be glad to.
Take a look at MagicHaskeller; I think it does what you want. There was even a recent release on Hackage. http://nautilus.cs.miyazaki-u.ac.jp/~skata/MagicHaskeller.html http://hackage.haskell.org/package/MagicHaskeller Regards, Reid Barton
participants (5)
-
Jonas Almström Duregård
-
Paul Brauner
-
Reid Barton
-
Richard O'Keefe
-
Tillmann Rendel