www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 67c343d5a44f5d9c80e27226c33456cc9d1d6bc8
parent 525563989f8a313cefedecfe864280a9fccac3da
Author: AlexKnauth <alexander@knauth.org>
Date:   Tue,  9 Aug 2016 18:00:03 -0500

document kw-formals->arity+keywords

Diffstat:
Mkw-utils/docs/arity+keywords.scrbl | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/kw-utils/docs/arity+keywords.scrbl b/kw-utils/docs/arity+keywords.scrbl @@ -3,6 +3,7 @@ racket/base scribble/eval (for-label kw-utils/arity+keywords + kw-utils/arity+keywords/syntax racket/base racket/contract/base racket/function @@ -10,6 +11,8 @@ @title[#:tag "arity+keywords.scrbl"]{arity+keywords} +@section{Procedure arities with keywords} + @defmodule[kw-utils/arity+keywords] @defstruct*[arity+keywords ([arity procedure-arity?] @@ -131,3 +134,32 @@ combines the @racket[arity+kws]es into one @racket[arity+keywords] instance in a (arity+keywords '(2 3) '(#:b) '(#:a #:b #:c #:e))) ]} +@section{Getting the arity from function arguments syntax} + +@defmodule[kw-utils/arity+keywords/syntax] + +@defproc[(kw-formals->arity+keywords [fmls-stx syntax?]) arity+keywords?]{ +Given the @racket[args] in @racket[(lambda args body)], returns an +@racket[arity+keywords] value representing the arity and keywords of +the function. + +@examples[ + (require kw-utils/arity+keywords/syntax) + (kw-formals->arity+keywords #'()) + (kw-formals->arity+keywords #'(a b c)) + (kw-formals->arity+keywords #'(a b [c 2])) + (kw-formals->arity+keywords #'(a b . rst)) + (kw-formals->arity+keywords #'(a #:b b)) + (kw-formals->arity+keywords #'(a #:b [b 1])) + (kw-formals->arity+keywords #'(#:a a . rst)) +]} + +@deftogether[[ + @defproc[(kw-formals->arity [fmls-stx syntax?]) normalized-arity?] + @defproc[(kw-formals->required-kws [fmls-stx syntax?]) (listof keyword?)] + @defproc[(kw-formals->allowed-kws [fmls-stx syntax?]) (listof keyword?)] +]]{ +Like @racket[kw-formals->arity+keywords], but just for the positional-argument +arity, required keywords, and allowed keywords. +} +