{"size": 1928, "ext": "scrbl", "max_stars_repo_path": "scribblings/helpful.scrbl", "max_stars_repo_name": "sorawee/helpful", "max_stars_repo_stars_event_min_datetime": "2022-01-24T05:47:57.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T06:56:51.000Z", "max_issues_repo_path": "scribblings/helpful.scrbl", "max_issues_repo_name": "sorawee/helpful", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scribblings/helpful.scrbl", "max_forks_repo_name": "sorawee/helpful", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.6779661017, "max_line_length": 132, "alphanum_fraction": 0.6701244813}
#lang scribble/manual
@require[scribble/example
         @for-label[helpful
                    (except-in racket/base #%top)]]

@title{helpful: suggests a closest variable name on unbound identifier error.}
@author[@author+email["Sorawee Porncharoenwase" "sorawee.pwase@gmail.com"]]

@defmodule[helpful]

This module provides an ability to suggest a closest variable name on unbound identifier error.
Simply use @racket[(require helpful)] where you want this feature.

The definition of ``closest'' is according to the @link["https://en.wikipedia.org/wiki/Levenshtein_distance"]{Levenshtein distance}.

@section{Examples}

@examples[
  #:label #f
  (code:comment @#,elem{Suggestion for a @tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{module binding}})
  (eval:error
    (module test racket
      (require helpful)
      (define (fact x)
        (cond
          [(zero? x) 1]
          [else (* x (fac (sub1 x)))]))))
  (code:comment @#,elem{Suggestion for a @tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{local binding}})
  (eval:error
    (module test racket
      (require helpful)
      (define (fact x)
        (cond
          [(zero? x) 1]
          [else (* x (fact (sub1 y)))]))))
  (code:comment @#,elem{Suggestion for an imported identifier})
  (eval:error
    (module test racket
      (require helpful)
      (defun (fact) 1)))
  (code:comment @#,elem{No suggestion outside a @racket[module] or @hash-lang[]})
  (require helpful)
  (eval:error (let ([x 1]) y))
]

@section{Limitations}

The feature only affects code in a @racket[module] or a @hash-lang[].
Because @link["http://calculist.blogspot.com/2009/01/fexprs-in-scheme.html"]{top level is hopeless},
the feature is disabled for the REPL.

The feature only works reliably for code at @tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{phase level} 0.

@section{API}

@defform[(#%top . x)]{
  Does what's described above.
}
