<commit_before>#lang racket/base

(require racket/contract/base
         racket/contract/combinator
         racket/private/set
         racket/private/set-types
         racket/generic
         racket/private/for
         (for-syntax racket/base))

(provide (all-from-out racket/private/set)
         (all-from-out racket/private/set-types)
         set/c)

(define/subexpression-pos-prop/name
  real-set/c-name (set/c elem/c
                         #:cmp [cmp 'dont-care]
                         #:kind [kind 'immutable]
                         #:lazy? [_lazy?
                                  (not (and (equal? kind 'immutable)
                                            (flat-contract? elem/c)))])
  (define lazy? (and _lazy? #t))
  (define cmp/c
    (case cmp
      [(dont-care) any/c]
      [(equal) set-equal?]
      [(eqv) set-eqv?]
      [(eq) set-eq?]
      [else (raise-arguments-error 'set/c
                                   "invalid #:cmp argument"
                                   "#:cmp argument" cmp)]))
  (define kind/c
    (case kind
      [(dont-care) any/c]
      [(mutable-or-weak) (or/c set-weak? set-mutable?)]
      [(mutable) set-mutable?]
      [(weak) set-weak?]
      [(immutable) set?]
      [else (raise-arguments-error 'set/c
                                   "invalid #:kind argument"
                                   "#:kind argument" kind)]))
  (case cmp
    [(eqv eq)
     (unless (flat-contract? elem/c)
       (raise-arguments-error
        'set/c
        "element contract must be a flat contract for eqv? and eq?-based sets"
        "element contract" (contract-name elem/c)
        "#:cmp option" cmp))]
    [else
     (unless (chaperone-contract? elem/c)
       (raise-argument-error 'set/c "chaperone-contract?" elem/c))])
  (cond
    [(and (eq? kind 'immutable)
          (not lazy?)
          (flat-contract? elem/c))
     (flat-set-contract elem/c cmp kind lazy?)]
    [(chaperone-contract? elem/c)
     (chaperone-set-contract elem/c cmp kind lazy?)]
    [else
     (impersonator-set-contract elem/c cmp kind lazy?)]))

(struct set-contract [elem/c cmp kind lazy?])

(define (set-contract-name ctc)
  (define elem/c (set-contract-elem/c ctc))
  (define cmp (set-contract-cmp ctc))
  (define kind (set-contract-kind ctc))
  `(set/c ,(contract-name elem/c)
          ,@(if (eq? cmp 'dont-care)
                `[]
                `[#:cmp (quote ,cmp)])
          ,@(if (eq? kind 'immutable)
                `[]
                `[#:kind (quote ,kind)])
          ,@(if (equal? (set-contract-lazy? ctc)
                        (flat-contract? elem/c))
                '()
                `(#:lazy? ,(set-contract-lazy? ctc)))))

(define (set-contract-first-order ctc)
  (define cmp (set-contract-cmp ctc))
  (define kind (set-contract-kind ctc))<commit_msg>fix set/c name method<commit_after>#lang racket/base

(require racket/contract/base
         racket/contract/combinator
         racket/private/set
         racket/private/set-types
         racket/generic
         racket/private/for
         (for-syntax racket/base))

(provide (all-from-out racket/private/set)
         (all-from-out racket/private/set-types)
         set/c)

(define/subexpression-pos-prop/name
  real-set/c-name (set/c elem/c
                         #:cmp [cmp 'dont-care]
                         #:kind [kind 'immutable]
                         #:lazy? [_lazy? (lazy-default kind elem/c)])
  (define lazy? (and _lazy? #t))
  (define cmp/c
    (case cmp
      [(dont-care) any/c]
      [(equal) set-equal?]
      [(eqv) set-eqv?]
      [(eq) set-eq?]
      [else (raise-arguments-error 'set/c
                                   "invalid #:cmp argument"
                                   "#:cmp argument" cmp)]))
  (define kind/c
    (case kind
      [(dont-care) any/c]
      [(mutable-or-weak) (or/c set-weak? set-mutable?)]
      [(mutable) set-mutable?]
      [(weak) set-weak?]
      [(immutable) set?]
      [else (raise-arguments-error 'set/c
                                   "invalid #:kind argument"
                                   "#:kind argument" kind)]))
  (case cmp
    [(eqv eq)
     (unless (flat-contract? elem/c)
       (raise-arguments-error
        'set/c
        "element contract must be a flat contract for eqv? and eq?-based sets"
        "element contract" (contract-name elem/c)
        "#:cmp option" cmp))]
    [else
     (unless (chaperone-contract? elem/c)
       (raise-argument-error 'set/c "chaperone-contract?" elem/c))])
  (cond
    [(and (eq? kind 'immutable)
          (not lazy?)
          (flat-contract? elem/c))
     (flat-set-contract elem/c cmp kind lazy?)]
    [(chaperone-contract? elem/c)
     (chaperone-set-contract elem/c cmp kind lazy?)]
    [else
     (impersonator-set-contract elem/c cmp kind lazy?)]))

(struct set-contract [elem/c cmp kind lazy?])

(define (lazy-default kind elem/c)
  (not (and (equal? kind 'immutable)
            (flat-contract? elem/c))))

(define (set-contract-name ctc)
  (define elem/c (set-contract-elem/c ctc))
  (define cmp (set-contract-cmp ctc))
  (define kind (set-contract-kind ctc))
  `(set/c ,(contract-name elem/c)
          ,@(if (eq? cmp 'dont-care)
                `[]
                `[#:cmp (quote ,cmp)])
          ,@(if (eq? kind 'immutable)
                `[]
                `[#:kind (quote ,kind)])
          ,@(if (equal? (set-contract-lazy? ctc)
                        (lazy-default kind elem/c))
                '()
                `(#:lazy? ,(set-contract-lazy? ctc)))))

(define (set-contract-first-order ctc)
  (define cmp (set-contract-cmp ctc))
  (define kind (set-contract-kind ctc))
{'fraction_non_alphanumeric': 0.15125155334635185, 'fraction_numerical': 0.0, 'mean_word_length': 1.7270087124878992, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7462390', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1870, 'n_words': 426}