In scripting, interactive environment (including notebooks), in editors without intellisense (e. g. when you want to quickly edit a file and you don't open it from IDE) people often misspell an identifier or forget to include the namespace. Trying to compile, they get a very unhelpful error about undefined identifier.
Solution
The idea here is to help the user with suggesting what should be there instead. Two ways:
First, let's check if there's a type or function with a similar identifier in the opened namespaces and suggest that
Then, crawl down the opened namespaces to check if the type needs another namespace imported
Details
To determine close identifiers we could use something like Levenstein's algorithm, doesn't look like a problem. However, in the latter case it is more complicated:
The compiler will need to store all BCL types' names in RAM? Then it could quickly search over them
It should also crawl down over 3rd party packages. Then again, there's no mapping namespace-assembly, so at most we can do is to load those types too and search over them.
Examples
2.
open System.Collections.Generic
val list = new Listt<T>()
- No "Listt<T>" found. Maybe you meant List<T>?
2.
open System.Collections
val list = new List<T>()
- No "List<T>" found. Maybe forgot to open System.Collections.Generic?
Problem
In scripting, interactive environment (including notebooks), in editors without intellisense (e. g. when you want to quickly edit a file and you don't open it from IDE) people often misspell an identifier or forget to include the namespace. Trying to compile, they get a very unhelpful error about undefined identifier.
Solution
The idea here is to help the user with suggesting what should be there instead. Two ways:
Details
To determine close identifiers we could use something like Levenstein's algorithm, doesn't look like a problem. However, in the latter case it is more complicated:
Examples
2.
2.