kenbot / goggles

Pleasant, yet principled Scala optics DSL
MIT License
196 stars 7 forks source link

Extra suggestions for error table #22

Open kenbot opened 7 years ago

kenbot commented 7 years ago

Implement suggestions to be show to the user for MacroUserErrors. For instance:

  Perhaps you meant one of these methods in Bunch?
    .brian    : Bunch => String
    .burgle   : Bunch => Int

  There is a monocle.Lens[Bunch, Int] in scope called "banana", did you mean 
  to interpolate it?  ie. get"$bunches*.$banana.foo.$evenPrism"

Here for a failed name, we are suggesting similar names that would have worked. Matching no-arg method names by first letter is probably sophisticated enough.

Also, a common user error is to name an optic in scope, accidentally leaving out the "$" that would allow it to be interpolated. We can typecheck the symbol, and if it corresponds to a monocle optic with the correct types, we can list it as a suggestion.