title: Scheme Racket Shadowed variable checking
body: <p>I need function to check is variable shadowed or not? Function should return #t or #f based on that is variable shadowed or not.
  I used DrRacket for implementing code (<a href="http://docs.racket-lang.org/plai/plai-scheme.html" rel="nofollow">#lang plai</a>). So far, I have this...</p>
  
  <pre><code>#lang plai
  
  (define-type WAE
    [num (n number?)]
    [add (lhs WAE?)(rhs WAE?)]
    [sub (lhs WAE?)(rhs WAE?)]
    [with (name symbol?)(named-expr WAE?)(body WAE?)]
    [id (name symbol?)])
  
  (define (parse sexpr)
    (cond
      [(number? sexpr) (num sexpr)]
      [(symbol? sexpr) (id sexpr)]
      [(list? sexpr)
        (case (first sexpr)
          [(add) (add (parse (second sexpr)) (parse (third sexpr)))]
          [(sub) (sub (parse (second sexpr)) (parse (third sexpr)))]
          [(with) (with (first (second sexpr)) 
                        (parse (second (second sexpr)))
                        (parse(third sexpr)) )]]
       [else (error "unexpected token")]))
  
  (define (symbol&lt;? a b)
    (string&lt;? (symbol-&gt;string a) (symbol-&gt;string b)))
  </code></pre>
  
  <p>This is function that checks if variable is shadowed, but it dont works</p>
  
  <pre><code>(define (shadowed? wae)
    (let 
      ([l(type-case WAE wae
        [num (n) n]
        [add (lft rght) (+ (shadowed-variable? lft) (shadowed-variable? rght))]
        [sub (lft rght) (- (shadowed-variable? lft) (shadowed-variable? rght))]
        [with (x i b) (shadowed-variable? (sub b x (shadowed-variable? i)))]
        [id (s) (error 'shadowed-variable? "free variable")])]) 
      (if (remove-duplicates (flatten l) symbol=?) #t #f)))
  </code></pre>