diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-09-23 21:01:17 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-09-23 22:23:47 +0200 |
commit | 0c0142881f769b6c42a8a69bec490ba9e98ccf48 (patch) | |
tree | 515f790266a701a590f04ea589436c54ed3c44b7 /module/hnh/module-introspection.scm | |
parent | Move graphviz to main tree. (diff) | |
download | calp-0c0142881f769b6c42a8a69bec490ba9e98ccf48.tar.gz calp-0c0142881f769b6c42a8a69bec490ba9e98ccf48.tar.xz |
Move all generally usable scripts to module dir.
Diffstat (limited to 'module/hnh/module-introspection.scm')
-rw-r--r-- | module/hnh/module-introspection.scm | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/module/hnh/module-introspection.scm b/module/hnh/module-introspection.scm new file mode 100644 index 00000000..83e561f1 --- /dev/null +++ b/module/hnh/module-introspection.scm @@ -0,0 +1,22 @@ +(define-module (hnh 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)) |