Skip to content

Instantly share code, notes, and snippets.

@leque
Created May 2, 2012 18:28
Show Gist options
  • Save leque/2578985 to your computer and use it in GitHub Desktop.
Save leque/2578985 to your computer and use it in GitHub Desktop.
library-has-module? 風にモジュールの export を取り出す
(use util.match)
(define (library-exports path name)
(match (guard (_ (else #f))
(call-with-input-file path read
:if-does-not-exist #f))
(('define-module (? (cut eq? name <>)) . forms)
(any (match-lambda
(('export . names)
names)
(_ #f))
forms))
(_ #f)))
(library-fold '*.*
(lambda (name path knil)
(cond ((library-exports path name) =>
(lambda (exports)
(acons name exports knil)))
(else
knil)))
'()
:strict? #f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment