Auto Rename Transformers
auto-rename-in
auto-rename-out
auto-rename-in/  out
transform-in
transform-out
transform-in/  out
1 Transformers
transform/  filter
transform/  when
transform/  remove
transform/  unless
transform/  map
transform/  for
transform/  append-map
transform/  for*
transform/  matches
transform/  replace
2 Miscellaneous Definitions
filter/  c
reducing-function/  c
im/  export/  c
im/  export-name
im/  export-map-name
transform/  compose
3 Internationalisation Support
3.1 British and American English
for-british
for-american
3.2 Other languages
en-français
auf-deutsch
magyarul
8.16

Auto Rename Transformers🔗ℹ

eutro

 (requireauto-rename) package:auto-rename

A package for programmatic require and provide filters and renamings.

Example:
(module fancy-lib racket
  (provide (all-defined-out))
  (struct fancy (x y z) #:transparent))

 

> (require (transform-in
            'fancy-lib
            #:transform (transform/replace "fancy" "not-so-fancy")))
> (not-so-fancy 1 2 3)

(fancy 1 2 3)

> struct:not-so-fancy

#<struct-type:fancy>

syntax

(auto-rename-in require-spec ...+ #:transform transform ...)

syntax

(auto-rename-out provide-spec ...+ #:transform transform ...)

syntax

(auto-rename-in/out spec ...+ #:transform transform ...)

 
  transform : filter/c
Require and provide transformers which apply the given transforms to all the imports and exports from the specs.

syntax

(transform-in require-spec ...+ #:transform transforms ...)

syntax

(transform-out provide-spec ...+ #:transform transforms ...)

syntax

(transform-in/out spec ...+ #:transform transforms ...)

1 Transformers🔗ℹ

 (requireauto-rename/filters) package:auto-rename

These bindings are provided by both auto-rename and auto-rename/filters. auto-rename additionally provides these bindings with tx/ replacing transformer/.

procedure

(transform/filter accept?)  filter/c

  accept? : (-> string? any/c)
Include only imports/exports for which accept? produces a true value.

syntax

(transform/when x accept?-expr)

Equivalent to (transform/filter(λ(x)accept?-expr)).

procedure

(transform/remove reject?)  filter/c

  reject? : (-> string? any/c)
Exclude any imports/exports for which reject? produces a true value.

syntax

(transform/unless x reject?-expr)

Equivalent to (transform/remove(λ(x)reject?-expr)).

procedure

(transform/map renamer)  filter/c

  renamer : (-> string? string?)
Change the name of any imports/exports to the result of applying renamer to the original name.

syntax

(transform/for x name-expr)

Equivalent to (transform/map(λ(x)name-expr)).

procedure

(transform/append-map renamer)  filter/c

  renamer : (-> string? (sequence/c string?))
Change the name of any imports/exports to the results of applying renamer to the original name. That is, the binding is imported/exported under every name that renamer returns, or no names at all if the returned sequence is empty.

syntax

(transform/for* x names-expr)

Equivalent to (transform/append-map(λ(x)names-expr)).

procedure

(transform/matches pattern)  filter/c

  pattern : (or/c string? regexp?)
Include only imports/exports whose name matches pattern. Equivalent to (transform/whenname(regexp-match?patternname)).

procedure

(transform/replace pattern replacement)  filter/c

  pattern : (or/c string? regexp?)
  replacement : (or/c string? (string? string? ... . -> . string?))
Replace all occurrences of pattern in import/export names with replacement, as if by regexp-replace*.

Equivalent to (transform/forname(regexp-replace*patternnamereplacement)).

2 Miscellaneous Definitions🔗ℹ

value

filter/c : contract?

 = 
(-> (reducing-function/c im/export/c A)
    (reducing-function/c im/export/c A))

procedure

(reducing-function/c input/c accumulator/c)  contract?

  input/c : contract?
  accumulator/c : contract?
 = 
(case->
 (input/c accumulator/c . -> . accumulator/c)
 (accumulator/c . -> . accumulator/c))
A filter is a composable function which transforms streams of imports/exports. auto-rename uses filters to modify the sequence of imports/exports that auto-rename-in/out produce. Typically one would use the transform/xyz functions available in auto-rename/filters to construct these, rather than writing them by hand.

A reducing function is a type of procedure which accumulates inputs into an accumulator. auto-rename uses reducing functions to transform a sequence of imports/exports into the list of imports/exports produced by auto-rename-in/out. Typically, one does not see reducing functions unless they are writing a filter by hand.

Specifically (reducing-function/cin/cacc/c) is a contract for a procedure rf suitable for the expression (rf(foldlrfaccins)), where acc and ins conform to acc/c and (listofin/c) respectively, and a filter is a function which maps an import/export reducing function to a new import/export reducing function, which may rename, remove, duplicate, or otherwise modify the stream of imports/exports that the original reducing function receives, but may not observe or modify the accumulator.

Some illustrative, but not terribly useful, examples:
; A transformer which drops all imports/exports.
(define (transform/none rf)
  (case-lambda
    [(im/ex acc) acc]
    [(acc) acc]))
 
; A transformer which drops imports randomly.
(define (transform/drop-randomly rf)
  (case-lambda
    [(im/ex acc)
     (if (zero? (random 2))
         acc
         (rf im/ex acc))]
    [(acc) acc]))

A import or an export.

procedure

(im/export-name im/ex)  string?

  im/ex : im/export/c
Get the name of an import/export.

procedure

(im/export-map-name im/ex proc)  im/export/c

  im/ex : im/export/c
  proc : (-> string? string?)
Return a copy of im/ex with its name transformed by proc.

procedure

(transform/compose transform ...)  filter/c

  transform : filter/c
Compose the given transforms. The effects of the transformations are performed left to right.

3 Internationalisation Support🔗ℹ

Bindings detailed in this section are experimental, and may not be up to the same quality as those exported by auto-rename. I make no backwards-compatibility guarantees.

3.1 British and American English🔗ℹ

 (requireauto-rename/language/british-english)
  package:auto-rename

This module provides require/provide transformers for importing and exporting bindings with British English spelling.

Examples:
> (require auto-rename/language/british-english
           (for-british racket))
> (normalise-arity 1)

1

> (rationalise 1/4 1/10)

1/3

> (parameterise ([error-print-width 5])
    (car (expt 10 1024)))

car: contract violation

  expected: pair?

  given: 10...

> (string-normalise-spaces "  foo bar  baz \r\n\t")

"foo bar baz"

syntax

(for-british spec ...+)

A require and provide transformer which renames identifiers using American English spellings to use British English spellings instead.

syntax

(for-american spec ...+)

A require and provide transformer which renames identifiers using British English spellings to use American English spellings instead.

3.2 Other languages🔗ℹ

 (requireauto-rename/language/polyglot)
  package:auto-rename

This module provides require/provide transformers for importing and exporting bindings in languages like French, German and Hungarian. Due to the automated and word-based nature of these translations they may not be very good, but they are predictable. Sometimes.

Examples:
> (require auto-rename/language/polyglot)
> (require (en-français racket racket/generator))
> (se-dresser inconvénients nul (liste 1 2 3))

'(3 2 1)

> (|jeter-un-coup-d'œil-octets| 4 0 (ouvrir-saisir-chaîne "abcd"))

#"abcd"

> (exiger (auf-deutsch racket))
> (sogar? (länge (nachteile 0 (nachteile 1 null))))

#t

> (lassen-werte ([(rohr-ein rohr-aus) (machen-rohr)])
    (schreiben-saite (saite-oben "efgh\nijkl") rohr-aus)
    (schließen-ausgabe-hafen rohr-aus)
    (beginnen0
      (hafen->linien rohr-ein)
      (schließen-eingang-hafen rohr-ein)))

'("EFGH" "IJKL")

> (erfordern (magyarul racket racket/generator))
> (meghatároz funkció
    (ügy-lambda
     [() (hozam 1) (hozam 2) (hozam 3)]
     [(x y) (hányados/maradék x y)]))
> (funkció 100 7)

14

2

> (definieren |l'ensemble| (veränderlich-satz))
> (für ([w (dans-générateur
             (dynamique-vent
              (λ () (kijelző "Be "))
              funkció
              (λ () (anzeige "Aus "))))]
        [x (in-reichweite 5)]
        [y (-ben-természetes 3)]
        [z (dans-faire-du-vélo (dans-valeur 2))])
    (satz-hinzufügen!
     |l'ensemble|
     (dans-le-monde-ior
      (arithmetik-schicht w x)
      (rationalisieren (/ y) (/ z)))))

Be Aus Be Aus Be Aus Be Aus

> |l'ensemble|

(mutable-set 1 12 4)

syntax

(en-français spec ...+)

syntax

(auf-deutsch spec ...+)

syntax

(magyarul spec ...+)

Require and provide transformers which renames identifiers to be in the corresponding language.

This works by splitting each identifier into tokens of (English) alphabet characters, and applying pre-defined translations (if any) to each token individually.

 
close