jackfirth / resyntax

A Racket refactoring engine
Apache License 2.0
56 stars 10 forks source link

Suggest `for*/ormap` and `for*/andmap` when appropriate #176

Open jackfirth opened 1 year ago

jackfirth commented 1 year ago

Resyntax currently refactors this code:

(ormap (lambda (p)
         (ormap (lambda (e)
                  (and (exporting-libraries? e) e))
                (part-to-collect p)))
       (collect-info-parents ci))

Into this:

(for/or ([p (in-list (collect-info-parents ci))])
  (ormap (lambda (e)
           (and (exporting-libraries? e) e))
         (part-to-collect p)))

Ideally, it should recognize the nested ormap case and produce this instead:

(for*/or ([p (in-list (collect-info-parents ci))]
          [e (in-list (part-to-collect p))])
  (and (exporting-libraries? e) e))

Same goes for andmap.