{"size": 1622, "ext": "scrbl", "max_stars_repo_path": "kw-utils/docs/partial.scrbl", "max_stars_repo_name": "AlexKnauth/kw-utils", "max_stars_repo_stars_event_min_datetime": "2015-12-07T01:34:35.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-09T23:57:57.000Z", "max_issues_repo_path": "kw-utils/docs/partial.scrbl", "max_issues_repo_name": "AlexKnauth/kw-utils", "max_issues_repo_issues_event_min_datetime": "2016-01-26T22:27:53.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-26T17:45:58.000Z", "max_forks_repo_path": "kw-utils/docs/partial.scrbl", "max_forks_repo_name": "AlexKnauth/kw-utils", "max_forks_repo_forks_event_min_datetime": "2016-01-26T21:28:35.000Z", "max_forks_repo_forks_event_max_datetime": "2016-09-02T17:08:40.000Z"}
{"max_stars_count": 4, "max_issues_count": 4, "max_forks_count": 2, "avg_line_length": 31.1923076923, "max_line_length": 90, "alphanum_fraction": 0.5807644883}
#lang scribble/manual

@(require scribble/eval
          (for-label kw-utils/partial
                     racket/base
                     racket/contract/base
                     racket/function
                     ))

@title{Partial application with keywords}

@defmodule[kw-utils/partial]

@defproc*[([(partial [f procedure?] [arg any/c] ... [#:<kw> kw-arg any/c] ...) procedure?]
           [(partial [#:<kw> kw-arg any/c] ...) procedure?])]{
Similar to @racket[curry], but better thought of as a generalization of
@racketidfont{partial} from @racketmodname[rackjure]. Unlike @racket[curry],
(but like the @racketmodname[rackjure] version), it does not care about function
arity, and so has much simpler behavior, so that
@racket[((partial f in-arg ...) out-arg ...)] is equivalent to
@racket[(f in-arg ... out-arg ...)] no matter what arity @racket[f] has.
It also generalizes this idea to include keyword arguments.
@examples[
  (require kw-utils/partial)
  ((partial + 1 2))
  ((partial + 1) 2)
  ((partial +) 1 2)
  ((partial) + 1 2)
  (define (KE #:m m #:v v)
    (* 1/2 m v v))
  ((partial KE) #:m 2 #:v 1)
  ((partial KE #:m 2) #:v 1)
  ((partial KE #:m 2 #:v 1))
  ((partial) KE #:m 2 #:v 1)
  ((partial #:m 2) KE #:v 1)
]}

@defproc[(app [f procedure?] [arg any/c] ... [#:<kw> kw-arg any/c] ...) any]{
A procedure for normal function application.
@racket[(partial #:<kw> kw-arg ... ...)] is equivalent to
@racket[(partial app #:<kw> kw-arg ... ...)].
@examples[
  (require kw-utils/partial)
  (+ 1 2)
  (app + 1 2)
  (define (KE #:m m #:v v)
    (* 1/2 m v v))
  (KE #:m 2 #:v 1)
  (app KE #:m 2 #:v 1)
]}

