<commit_before>#lang typed/racket/base
(provide
  record
  record-struct
  )

(require
  (for-syntax
    racket/base
    ))

(define-syntax (record-struct stx)
  (syntax-case stx (:)
    ((_ (name type-params ...) ((field-name : field-type) ...) struct-rest ...)
     #'(begin
         (struct (type-params ...) name ((field-name : field-type) ...)
                 #:transparent struct-rest ...)))))

(define-syntax record
  (syntax-rules ()
    ((_ (name type-params ...) field ...)
     (record-struct (name type-params ...) (field ...)))
    ((_ name field ...) (record (name) field ...))))<commit_msg>Define typed 'records'<commit_after>#lang typed/racket/base
(provide
  record
  records
  record-struct
  )

(require
  (for-syntax
    "../idset.rkt"
    "../sugar.rkt"
    "../syntax.rkt"
    racket/base
    racket/function
    ))

(define-syntax (record-struct stx)
  (syntax-case stx (:)
    ((_ (name type-params ...) ((field-name : field-type) ...) struct-rest ...)
     #'(begin
         (struct (type-params ...) name ((field-name : field-type) ...)
                 #:transparent struct-rest ...)))))

(define-syntax record
  (syntax-rules ()
    ((_ (name type-params ...) field ...)
     (record-struct (name type-params ...) (field ...)))
    ((_ name field ...) (record (name) field ...))))

(define-syntax (records stx)
  (syntax-case stx (:)
    ((_ (name type-params ...) (rec-name (field-name : field-type) ...) ...)
     (let* ((params (syntax->list #'(type-params ...)))
            (useds (map (compose1 idset->list (curry typenames-used params))
                        (syntax->list #'((() field-type ...) ...))))
            (templates
              (map syntax->list (syntax->list
                #'((rec-name ((field-name : field-type) ...)) ...))))
            (recs (forl
                    used <- useds
                    (list rname rfields) <- templates
                    #`(record (#,rname #,@used) #,@rfields))))
       #`(begin #,@recs)))))
{'fraction_non_alphanumeric': 0.2127016129032258, 'fraction_numerical': 0.0005040322580645161, 'mean_word_length': 1.885174418604651, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2922745', 'n_tokens_mistral': 672, 'n_tokens_neox': 619, 'n_words': 133}