Created
May 2, 2012 18:28
-
-
Save leque/2578985 to your computer and use it in GitHub Desktop.
library-has-module? 風にモジュールの export を取り出す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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