kenbot / goggles

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

Improve error messages #1

Closed kenbot closed 7 years ago

kenbot commented 7 years ago

I want the macro user-errors to look something like:

  Section     | Source      | Target      | Optic type
  ------------+-------------+-------------+--------------------------
  $bunches    |             | List[Bunch] | 
  *           | List[Bunch] | Bunch       | Traversal
  .banana     | Bunch       | Banana      | Lens
  .foo        | Banana      | Int         | Lens
  .$evenPrism | Int         | Int         | Prism, returning Optional
  .foo        | Banana *** ERROR: "Banana" doesn't match "Int"
  .bar

  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"

The type & optic information is all there, although the suggestions might need a bit of work.

kenbot commented 7 years ago

The table is done; the suggestions can be moved to another ticket to complete later.