aboutsummaryrefslogtreecommitdiff
path: root/scripts/module-introspection.scm
blob: ba455cfc3c20dd614dcf98c352103de7bde80916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(define-module (module-introspection)
  :use-module (srfi srfi-1)
  :use-module (hnh util)
  :export (unique-symbols
           find-module-declaration
           module-declaration?
           ))


(define (unique-symbols tree)
  (uniq
   (sort* (filter symbol? (flatten tree))
          string<? symbol->string)))

(define (module-declaration? form)
  (cond ((null? form) #f)
        ((not (pair? form)) #f)
        (else (eq? 'define-module (car form)))))

(define (find-module-declaration forms)
  (and=> (find module-declaration? forms)
         cadr))