started snippet ideas file

This commit is contained in:
Anton-4 2021-07-30 20:31:06 +02:00
parent 2538ad3080
commit ad49c9a27d

45
editor/snippet-ideas.md Normal file
View File

@ -0,0 +1,45 @@
I think snippet insertion would make for an awesome demo that shows off the potential of the editor and a basic version would not be that difficult to implement.
With snippet insertion I mean the following:
say you have a list of Person records, people in scope
you press some keyboard shortcut
a text field pops up
you enter "sort"
we show autocomplete options like sort people by firstName, sort people by lastName and sort people by age. The recommendations can be that good because we know people is the only list in scope and we know which fields are in the Person record.
you navigate to sort people by age, press enter and we show in the autocomplete popup: sort people by age descending and sort people by age ascending.
you navigate to sort people by age ascending and press Enter
The correct Roc code is inserted
This is most useful for beginning Roc programmers, but I could see it saving time for experts as well.
Novice to expert programmers who are new to Roc can also perfectly describe what they want to happen but may not know the correct syntax, names of builtin functions...
Other useful snippet commands for beginning Roc programmers might be empty dict, lambda function, split strVal into chars...
Some more advanced snippets: post jsonVal to urlVal, connect to amazon S3, insert function of common algorithm like: sieve of erathostenes, greatest common divider...
This could remove the need for a lot of googling/stackoverflow, creating a delightful experience that sets us apart from other editors.
And contrary to stackoverflow/github copilot, snippets will be written by Roc experts or be easily editable by us. They can also be guaranteed to work for a specific Roc and library version because we update, version, and test them.
A nice goal to aim for is that the user never needs/wants to leave the editor to look things up.
We have way more context inside the editor so we should be able to do better than any general-purpose search engine.
I think the snippet insertion commands also set us up for quality interaction with users using voice input.
The CC0 license seems like a good fit for the snippets.
Fuzzy matching should be done to suggest a closest fuzzy match, so if the user types the snippet command `empty Map`, we should suggest `empty Dict`.
# Snippet ideas
## Pure Text Snippets
Pure text snippets are not templates and do not contain typed holes.
Fish hooks are used when subvariants should be created e.g.: <collection> means this pure text snippets should be created for all Roc collections such as Dict, Set, List...
- command: empty <collection>
+ example: empty dict >> `{::}`
- command: <common algorithm>
+ example: sieve of erathostenes >> `inserts function for sieve of erathostenes`
+ common algorithms: sieve of erathostenes, greatest common divisior, prime factorisation, A* path finding, Dijkstra's algorithm, Breadth First Search...
## Snippets with Typed Holes
- command: sort ^List^ (by ^Record Field^) {ascending/descending}
+ example: sort people by age descending >> TODO