{"size": 1515, "ext": "scrbl", "max_stars_repo_path": "kw-ctc/kw-ctc.scrbl", "max_stars_repo_name": "bennn/syntax-parse-example", "max_stars_repo_stars_event_min_datetime": "2017-05-18T22:15:56.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-17T13:13:05.000Z", "max_issues_repo_path": "kw-ctc/kw-ctc.scrbl", "max_issues_repo_name": "bennn/syntax-parse-example", "max_issues_repo_issues_event_min_datetime": "2017-05-18T22:54:53.000Z", "max_issues_repo_issues_event_max_datetime": "2021-10-19T02:58:50.000Z", "max_forks_repo_path": "kw-ctc/kw-ctc.scrbl", "max_forks_repo_name": "bennn/syntax-parse-example", "max_forks_repo_forks_event_min_datetime": "2017-05-19T14:27:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T09:36:54.000Z"}
{"max_stars_count": 22, "max_issues_count": 20, "max_forks_count": 6, "avg_line_length": 36.0714285714, "max_line_length": 102, "alphanum_fraction": 0.6092409241}
#lang syntax-parse-example
@require[
  (for-label racket/base racket/contract racket/math syntax/parse syntax-parse-example/kw-ctc/kw-ctc)]

@(define kw-ctc-eval
   (make-base-eval '(require racket/contract racket/math syntax-parse-example/kw-ctc/kw-ctc)))

@title{Generate Contracts for Keyword Functions}
@stxbee2021["dstorrs" 19]
@nested[#:style 'inset @emph{Adapted from the
  @hyperlink["https://docs.racket-lang.org/struct-plus-plus/index.html" @tt{struct-plus-plus}]
  module, which contains many other interesting macros (@stxbee2021-issue{18}).}]

@; =============================================================================

@defmodule[syntax-parse-example/kw-ctc/kw-ctc]{}

@defform[(kw-ctc (dom-spec ...) cod-spec)
         #:grammar ([dom-spec [id]
                              [id ctc-expr]
                              [(id default)]
                              [(id default) ctc-expr]]
                    [cod-spec ctc-expr])]{
  Shorthand to write contracts for functions that expect only keyword arguments.

  @examples[#:eval kw-ctc-eval
    (struct pumpkin [name weight color])
    (define/contract (make-pumpkin #:name name #:weight weight #:color [color "Dark Orange"])
      (kw-ctc ([name] [weight natural?] [(color _) string?]) pumpkin?)
      (pumpkin name weight color))
    (make-pumpkin #:name 'roger #:weight 140)
    (make-pumpkin #:name #false #:weight 117 #:color "Indigo")
    (eval:error (make-pumpkin #:weight 999))
  ]

  Implementation:

  @racketfile{kw-ctc.rkt}

}

