[Haskell-cafe] searching a function by providing examples of
input/ouput pairs
Richard O'Keefe
ok at cs.otago.ac.nz
Thu Mar 18 23:04:46 EDT 2010
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.
More information about the Haskell-Cafe
mailing list