Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by example #12

Open
ghost opened this issue Nov 11, 2016 · 4 comments
Open

Search by example #12

ghost opened this issue Nov 11, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 11, 2016

Type searches often find many results you have to look through. You then either have to know what each function's name means, or hope the function's author has described what it does well.

We talked before with @knewter (sadly the recording was lost) about being able to give Elm Search the data you have (input), and the data you want (output), and for it to narrow down your search for you. As an example, String.reverse could be found with "123" -> "321".

To begin with, there could be an extra field for "123" -> "321", as well as the existing field for String -> String. The results from String -> String could be narrowed down by giving "123" to every function found, filtering by ones that return "321". In time, String -> String could be inferred from "123" -> "321" the way the compiler does it now.

This could form the foundation of a tool that could write complete programs for you, based on your specifying what data you have (inputs), and what data you want (output). You would also be doing test-driven development.

@ghost
Copy link
Author

ghost commented Nov 25, 2016

I've made a function that filters a list of functions by output given an input, but all the functions have to have the same signature. That's okay as "123" -> "321" only has one signature (String -> String), rather than that and all of the close matches that Elm Search also gives you (e.g. List String -> String) when the query is String -> String. It'd be great to talk with you @klaftertief about how the search works, to see if I can isolate just the functions with the exact type signature of the data.

@klaftertief
Copy link
Owner

Sorry for bring absent. I'm busy until a parental leave starting in one or two weeks. Will get back to you then...

@ghost
Copy link
Author

ghost commented Nov 27, 2016

Cool! I'll try to figure things out in the meantime.

@ghost
Copy link
Author

ghost commented Dec 3, 2016

Thought I'd record this test case from a question on Slack.
" asdf asdf" -> "asdfasdf"
(String.words >> String.concat) works (found by http://klaftertief.github.io/elm-search/?q=String+-%3E+String).
As does String.filter ((/=) ' ').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant