{"size": 2143, "ext": "scrbl", "max_stars_repo_path": "custom-write.scrbl", "max_stars_repo_name": "9999years/rebellion", "max_stars_repo_stars_event_min_datetime": "2019-05-28T21:50:27.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T21:21:52.000Z", "max_issues_repo_path": "custom-write.scrbl", "max_issues_repo_name": "9999years/rebellion", "max_issues_repo_issues_event_min_datetime": "2019-03-02T23:19:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-24T08:43:16.000Z", "max_forks_repo_path": "custom-write.scrbl", "max_forks_repo_name": "9999years/rebellion", "max_forks_repo_forks_event_min_datetime": "2019-02-01T22:21:26.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-24T04:35:35.000Z"}
{"max_stars_count": 73, "max_issues_count": 216, "max_forks_count": 20, "avg_line_length": 37.5964912281, "max_line_length": 80, "alphanum_fraction": 0.6593560429}
#lang scribble/manual

@(require (for-label racket/base
                     racket/contract/base
                     racket/math
                     racket/pretty
                     racket/struct
                     rebellion/custom-write
                     rebellion/type/struct
                     rebellion/type/tuple)
          (submod rebellion/private/scribble-evaluator-factory doc)
          (submod rebellion/private/scribble-cross-document-tech doc)
          scribble/example)

@(define make-evaluator
   (make-module-sharing-evaluator-factory
    #:public (list 'racket/pretty
                   'rebellion/custom-write
                   'rebellion/type/struct
                   'rebellion/type/tuple)
    #:private (list 'racket/base)))

@title{Custom Write Implementations}
@defmodule[rebellion/custom-write]

A @deftech{custom write implementation} is a function that prints values and is
suitable for use with @racket[prop:custom-write]. Custom write implementations
must satisfy the @racket[custom-write-function/c] contract.

@defthing[custom-write-function/c chaperone-contract?
          #:value (-> any/c output-port? custom-write-mode/c void?)]{
 A @tech/reference{contract} describing functions suitable for use with @racket[
 prop:custom-write].}

@defthing[custom-write-mode/c flat-contract?
          #:value (or/c boolean? 0 1)]{
 A @tech/reference{contract} describing the @racket[_mode] argument to functions
 matching @racket[custom-write-function/c]. See @racket[gen:custom-write] for
 details.}

@defproc[(make-named-object-custom-write
          [type-name symbol?]
          [#:name-getter get-name (-> any/c (or/c symbol? #false)) object-name])
         custom-write-function/c]{
 Constructs a @tech{custom write implementation} that prints values as opaque,
 unreadable, named objects, similar to the way functions are printed.

 @(examples
   #:eval (make-evaluator) #:once
   (struct person (name)
     #:property prop:object-name (struct-field-index name)
     #:property prop:custom-write (make-named-object-custom-write 'person))

   (person 'alyssa)
   (person 'jared)
   (person #false))}
