Last active
December 30, 2015 13:09
-
-
Save joshrotenberg/7834235 to your computer and use it in GitHub Desktop.
macro expand result when include-lib'ing in LFE
This file contains hidden or 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
| > (macroexpand '(include-lib "webmachine/include/webmachine.hrl")) | |
| (progn | |
| (defrecord wm_reqdata | |
| method | |
| scheme | |
| version | |
| peer | |
| sock | |
| wm_state | |
| disp_path | |
| path | |
| raw_path | |
| path_info | |
| path_tokens | |
| app_root | |
| response_code | |
| max_recv_body | |
| max_recv_hunk | |
| req_cookie | |
| req_qs | |
| req_headers | |
| req_body | |
| resp_redirect | |
| resp_headers | |
| resp_body | |
| resp_range | |
| host_tokens | |
| port | |
| notes)) | |
| > |
This file contains hidden or 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
| > (macroexpand-all '(include-lib "webmachine/include/webmachine.hrl")) | |
| (progn | |
| (progn | |
| (eval-when-compile | |
| (define-function wm_reqdata-field-index | |
| (match-lambda | |
| (('method) 2) | |
| (('scheme) 3) | |
| (('version) 4) | |
| (('peer) 5) | |
| (('sock) 6) | |
| (('wm_state) 7) | |
| (('disp_path) 8) | |
| (('path) 9) | |
| (('raw_path) 10) | |
| (('path_info) 11) | |
| (('path_tokens) 12) | |
| (('app_root) 13) | |
| (('response_code) 14) | |
| (('max_recv_body) 15) | |
| (('max_recv_hunk) 16) | |
| (('req_cookie) 17) | |
| (('req_qs) 18) | |
| (('req_headers) 19) | |
| ((...) ...) | |
| (...)...)) | |
| (define-function wm_reqdata-field-update | |
| (lambda (is def) | |
| (letrec-function ((l | |
| (match-lambda | |
| (((cons f (cons v is)) i) | |
| (l | |
| is | |
| (setelement | |
| (call 'erlang | |
| '- | |
| (wm_reqdata-field-index f) | |
| 1) | |
| i | |
| v))) | |
| (((list f) _) | |
| (call 'erlang | |
| 'error | |
| (tuple 'missing_value 'wm_reqdata f))) | |
| ((() i) i)))) | |
| (let ((i (l is (list_to_tuple def)))) (tuple_to_list i)))))) | |
| (define-macro make-wm_reqdata | |
| (match-lambda | |
| ((fds $ENV) | |
| (let ((def | |
| (list | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined...))) | |
| (cons | |
| 'tuple | |
| (cons (list 'quote 'wm_reqdata) (wm_reqdata-field-update fds def))))))) | |
| (define-macro match-wm_reqdata | |
| (match-lambda | |
| ((fds $ENV) | |
| (let ((def (list '_ '_ '_ '_ '_ '_ '_ '_ '_ '_ '_ '_ ...))) | |
| (cons | |
| 'tuple | |
| (cons (list 'quote 'wm_reqdata) (wm_reqdata-field-update fds def))))))) | |
| (define-macro is-wm_reqdata | |
| (match-lambda | |
| (((list rec) $ENV) (list 'is_record rec (list 'quote 'wm_reqdata) 27)))) | |
| (define-macro set-wm_reqdata | |
| (match-lambda | |
| (((cons rec fds) $ENV) | |
| (letrec-function ((l | |
| (match-lambda | |
| (((cons f (cons v is)) r) | |
| (l | |
| is | |
| (list | |
| 'setelement | |
| (wm_reqdata-field-index ...) | |
| r...))) | |
| (((list f) _) | |
| (call 'erlang 'error (tuple 'missing_value ...))) | |
| ((() i) i)))) | |
| (l fds rec))))) | |
| (define-macro emp-wm_reqdata | |
| (match-lambda | |
| ((fds $ENV) | |
| (let ((def (list ''_ ''_ ''_ ''_ ''_ ''_ ''_ ''_ ''_ ...))) | |
| (cons | |
| 'tuple | |
| (cons (list 'quote 'wm_reqdata) (wm_reqdata-field-update fds def))))))) | |
| (define-macro wm_reqdata-method | |
| (match-lambda ((() $ENV) 2) (((list rec) $ENV) (list 'element 2 rec)))) | |
| (define-macro set-wm_reqdata-method | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 2 rec new)))) | |
| (define-macro wm_reqdata-scheme | |
| (match-lambda ((() $ENV) 3) (((list rec) $ENV) (list 'element 3 rec)))) | |
| (define-macro set-wm_reqdata-scheme | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 3 rec new)))) | |
| (define-macro wm_reqdata-version | |
| (match-lambda ((() $ENV) 4) (((list rec) $ENV) (list 'element 4 rec)))) | |
| (define-macro set-wm_reqdata-version | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 4 rec new)))) | |
| (define-macro wm_reqdata-peer | |
| (match-lambda ((() $ENV) 5) (((list rec) $ENV) (list 'element 5 rec)))) | |
| (define-macro set-wm_reqdata-peer | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 5 rec new)))) | |
| (define-macro wm_reqdata-sock | |
| (match-lambda ((() $ENV) 6) (((list rec) $ENV) (list 'element 6 rec)))) | |
| (define-macro set-wm_reqdata-sock | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 6 rec ...)))) | |
| (define-macro wm_reqdata-wm_state | |
| (match-lambda ((() $ENV) 7) (((list rec) $ENV) (list 'element ...)))) | |
| (define-macro set-wm_reqdata-wm_state | |
| (match-lambda (((list rec ...) $ENV) (list 'setelement ...)))) | |
| (define-macro wm_reqdata-disp_path (match-lambda ((() ...) 8) ((...) ...))) | |
| (define-macro set-wm_reqdata-disp_path (match-lambda ((...) ...))) | |
| (define-macro wm_reqdata-path (match-lambda (...) ...)) | |
| (define-macro set-wm_reqdata-path (match-lambda ...)) | |
| (define-macro wm_reqdata-raw_path (...)) | |
| (define-macro set-wm_reqdata-raw_path ...) | |
| (define-macro ...) | |
| (...)...)) |
This file contains hidden or 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
| > (macroexpand-all '(include-lib "webmachine/include/webmachine.hrl")) | |
| (progn | |
| (extend-module | |
| (file | |
| #("/Users/josh/github/lfe-webmachine/deps/webmachine/include/webmachine.hrl" | |
| 1)) | |
| (export (ping 2)) | |
| (file | |
| #("/Users/josh/github/lfe-webmachine/deps/webmachine/include/wm_reqdata.hrl" | |
| 1)) | |
| (file | |
| #("/Users/josh/github/lfe-webmachine/deps/webmachine/include/webmachine.hrl" | |
| 4))) | |
| (progn | |
| (eval-when-compile | |
| (define-function wm_reqdata-field-index | |
| (match-lambda | |
| (('method) 2) | |
| (('scheme) 3) | |
| (('version) 4) | |
| (('peer) 5) | |
| (('sock) 6) | |
| (('wm_state) 7) | |
| (('disp_path) 8) | |
| (('path) 9) | |
| (('raw_path) 10) | |
| (('path_info) 11) | |
| (('path_tokens) 12) | |
| (('app_root) 13) | |
| (('response_code) 14) | |
| (('max_recv_body) 15) | |
| (('max_recv_hunk) 16) | |
| (('req_cookie) 17) | |
| (('req_qs) 18) | |
| ((...) ...) | |
| (...)...)) | |
| (define-function wm_reqdata-field-update | |
| (lambda (is def) | |
| (letrec-function ((l | |
| (match-lambda | |
| (((cons f (cons v is)) i) | |
| (l | |
| is | |
| (setelement (call 'erlang '- (...) ...) i v))) | |
| (((list f) _) | |
| (call 'erlang | |
| 'error | |
| (tuple 'missing_value 'wm_reqdata f))) | |
| ((() i) i)))) | |
| (let ((i (l is (list_to_tuple def)))) (tuple_to_list i)))))) | |
| (define-macro make-wm_reqdata | |
| (match-lambda | |
| ((fds $ENV) | |
| (let ((def | |
| (list | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined | |
| ''undefined...))) | |
| (cons | |
| 'tuple | |
| (cons (list 'quote 'wm_reqdata) (wm_reqdata-field-update fds def))))))) | |
| (define-macro match-wm_reqdata | |
| (match-lambda | |
| ((fds $ENV) | |
| (let ((def (list '_ '_ '_ '_ '_ '_ '_ '_ '_ '_ '_ ...))) | |
| (cons | |
| 'tuple | |
| (cons (list 'quote 'wm_reqdata) (wm_reqdata-field-update fds def))))))) | |
| (define-macro is-wm_reqdata | |
| (match-lambda | |
| (((list rec) $ENV) (list 'is_record rec (list 'quote 'wm_reqdata) 27)))) | |
| (define-macro set-wm_reqdata | |
| (match-lambda | |
| (((cons rec fds) $ENV) | |
| (letrec-function ((l | |
| (match-lambda | |
| (((cons f (cons v is)) r) | |
| (l is (list 'setelement (...) ...))) | |
| (((list f) _) (call 'erlang 'error (tuple ...))) | |
| ((() i) i)))) | |
| (l fds rec))))) | |
| (define-macro emp-wm_reqdata | |
| (match-lambda | |
| ((fds $ENV) | |
| (let ((def (list ''_ ''_ ''_ ''_ ''_ ''_ ''_ ''_ ...))) | |
| (cons | |
| 'tuple | |
| (cons (list 'quote 'wm_reqdata) (wm_reqdata-field-update fds def))))))) | |
| (define-macro wm_reqdata-method | |
| (match-lambda ((() $ENV) 2) (((list rec) $ENV) (list 'element 2 rec)))) | |
| (define-macro set-wm_reqdata-method | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 2 rec new)))) | |
| (define-macro wm_reqdata-scheme | |
| (match-lambda ((() $ENV) 3) (((list rec) $ENV) (list 'element 3 rec)))) | |
| (define-macro set-wm_reqdata-scheme | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 3 rec new)))) | |
| (define-macro wm_reqdata-version | |
| (match-lambda ((() $ENV) 4) (((list rec) $ENV) (list 'element 4 rec)))) | |
| (define-macro set-wm_reqdata-version | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 4 rec new)))) | |
| (define-macro wm_reqdata-peer | |
| (match-lambda ((() $ENV) 5) (((list rec) $ENV) (list 'element 5 rec)))) | |
| (define-macro set-wm_reqdata-peer | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 5 rec new)))) | |
| (define-macro wm_reqdata-sock | |
| (match-lambda ((() $ENV) 6) (((list rec) $ENV) (list 'element 6 ...)))) | |
| (define-macro set-wm_reqdata-sock | |
| (match-lambda (((list rec new) $ENV) (list 'setelement 6 ...)))) | |
| (define-macro wm_reqdata-wm_state | |
| (match-lambda ((() $ENV) 7) (((list ...) $ENV) (list ...)))) | |
| (define-macro set-wm_reqdata-wm_state (match-lambda (((...) ...) (...)))) | |
| (define-macro wm_reqdata-disp_path (match-lambda ((...) ...) (...))) | |
| (define-macro set-wm_reqdata-disp_path (match-lambda (...))) | |
| (define-macro wm_reqdata-path (match-lambda ...)) | |
| (define-macro set-wm_reqdata-path (...)) | |
| (define-macro wm_reqdata-raw_path ...) | |
| (define-macro ...) | |
| (...)...) | |
| (define-function ping | |
| (match-lambda ((ReqData State) (when) (tuple 'pong ReqData State))))) | |
| > |
This file contains hidden or 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
| -export([ping/2]). | |
| -include("wm_reqdata.hrl"). | |
| ping(ReqData, State) -> | |
| {pong, ReqData, State}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment