On this page:
3.2.1 Snippet Systems in General
unselected
unselected?
unselected-value
selected
selected?
selected-value
selectable?
selectable/  c
selectable-map
snippet-sys?
snippet-sys-impl?
prop:  snippet-sys
snippet-sys-snippet/  c
snippet-sys-dim-sys
snippet-sys-shape-snippet-sys
snippet-sys-snippet-degree
snippet-sys-snippet-with-degree/  c
snippet-sys-snippet-with-degree</  c
snippet-sys-snippet-with-degree=/  c
snippet-sys-snippet-with-0<degree/  c
snippet-sys-snippetof/  ob-c
snippet-sys-unlabeled-snippet/  c
snippet-sys-unlabeled-shape/  c
snippet-sys-snippet-zip-selective/  ob-c
snippet-sys-snippet-fitting-shape/  c
snippet-sys-shape->snippet
snippet-sys-snippet->maybe-shape
snippet-sys-snippet-set-degree-maybe
snippet-sys-snippet-done
snippet-sys-snippet-undone
snippet-sys-snippet-select-everything
snippet-sys-snippet-splice
snippet-sys-snippet-zip-map-selective
snippet-sys-snippet-zip-map
snippet-sys-snippet-any?
snippet-sys-snippet-all?
snippet-sys-snippet-each
snippet-sys-snippet-map-maybe
snippet-sys-snippet-map
snippet-sys-snippet-map-selective
snippet-sys-snippet-select
snippet-sys-snippet-select-if-degree
snippet-sys-snippet-select-if-degree<
snippet-sys-snippet-bind-selective
snippet-sys-snippet-join-selective
snippet-sys-snippet-bind
snippet-sys-snippet-join
make-snippet-sys-impl-from-various-1
3.2.2 Category-Theoretic Snippet System Manipulations
snippet-sys-morphism-sys?
snippet-sys-morphism-sys-impl?
prop:  snippet-sys-morphism-sys
snippet-sys-morphism-sys-source
snippet-sys-morphism-sys-replace-source
snippet-sys-morphism-sys-target
snippet-sys-morphism-sys-replace-target
snippet-sys-morphism-sys-dim-sys-morphism-sys
snippet-sys-morphism-sys-shape-snippet-sys-morphism-sys
snippet-sys-morphism-sys-morph-snippet
make-snippet-sys-morphism-sys-impl-from-morph
snippet-sys-morphism-sys/  c
snippet-sys-morphism-sys-identity
snippet-sys-morphism-sys-chain-two
snippet-sys-category-sys
snippet-sys-category-sys?
functor-from-snippet-sys-sys-apply-to-morphism
natural-transformation-from-from-snippet-sys-sys-apply-to-morphism
functor-from-dim-sys-to-snippet-sys-sys?
make-functor-from-dim-sys-to-snippet-sys-sys-impl-from-apply
functor-from-dim-sys-to-snippet-sys-sys-morphism-sys?
make-functor-from-dim-sys-to-snippet-sys-sys-morphism-sys-impl-from-apply
3.2.3 Snippet Format Systems in General
snippet-format-sys?
snippet-format-sys-impl?
prop:  snippet-format-sys
snippet-format-sys-functor
make-snippet-format-sys-impl-from-functor
3.2.4 Category-Theoretic Snippet Format System Manipulations
snippet-format-sys-morphism-sys?
snippet-format-sys-morphism-sys-impl?
prop:  snippet-format-sys-morphism-sys
snippet-format-sys-morphism-sys-source
snippet-format-sys-morphism-sys-replace-source
snippet-format-sys-morphism-sys-target
snippet-format-sys-morphism-sys-replace-target
snippet-format-sys-morphism-sys-functor-morphism
make-snippet-format-sys-morphism-sys-impl-from-morph
snippet-format-sys-morphism-sys/  c
snippet-format-sys-morphism-sys-identity
snippet-format-sys-morphism-sys-chain-two
snippet-format-sys-category-sys
snippet-format-sys-category-sys?
snippet-format-sys-endofunctor-sys?
make-snippet-format-sys-endofunctor-sys-impl-from-apply

3.2 Snippet Systems🔗ℹ

 (require punctaffy/hypersnippet/snippet)
  package: punctaffy-lib

3.2.1 Snippet Systems in General🔗ℹ

syntax

unselected

syntax

(unselected value)

match expander

(unselected value)

procedure

(unselected? v)  boolean?

  v : any/c

procedure

(unselected-value u)  any/c

  u : unselected?
Struct-like operations which construct and deconstruct a selectable? value that represents a value that has not been selected to be processed as part of a collection traveral.

Two unselected values are equal? if they contain equal? elements.

syntax

selected

syntax

(selected value)

match expander

(selected value)

procedure

(selected? v)  boolean?

  v : any/c

procedure

(selected-value s)  any/c

  s : selected?
Struct-like operations which construct and deconstruct a selectable? value that represents a value that has indeed been selected to be processed as part of a collection traveral.

Two selected values are equal? if they contain equal? elements.

procedure

(selectable? v)  boolean?

  v : any/c
Returns whether the given value is a possibly-selected value, which is an arbitrary value that may or may not have been selected to be processed as part of a collection traversal. A possibly-selected value is represented by either an unselected? value or a selected? value.

(TODO: Consider renaming selectable? to possibly-selected?.)

procedure

(selectable/c unselected/c selected/c)  contract?

  unselected/c : contract?
  selected/c : contract?
Returns a contract that recognizes a selectable? value where the value abides by unselected/c if it’s unselected or by selected/c if it’s selected.

The resulting contract has the same contract obstinacy as the most obstinate of the given contracts.

procedure

(selectable-map s v-to-v)  selectable?

  s : selectable?
  v-to-v : (-> any/c any/c)
Returns a selectable? value similar to the given one, but with its selected element (if any) transformed by the given function.

procedure

(snippet-sys? v)  boolean?

  v : any/c

procedure

(snippet-sys-impl? v)  boolean?

  v : any/c

value

prop:snippet-sys : (struct-type-property/c snippet-sys-impl?)

Structure type property operations for hypersnippet systems (aka snippet systems). These are systems of traversal and concatenation operations over some form of hypersnippet data, where the degrees of the hypersnippets range over some decided-upon dimension system.

See snippet-format-sys? for a similar bundle of operations which allows the dimension system to be decided upon by the caller.

procedure

(snippet-sys-snippet/c ss)  flat-contract?

  ss : snippet-sys?
Returns a flat contract which recognizes any hypersnippet of the given snippet system.

procedure

(snippet-sys-dim-sys ss)  dim-sys?

  ss : snippet-sys?
Returns the dimension system that operates on the degree numbers of the given snippet system’s hypersnippets.

Returns the snippet system that operates on the shapes of the given snippet system’s hypersnippets. These shapes are hypersnippets of their own, and they have the same arrangement of holes as the hypersnippets they’re the shapes of, but they don’t contain any content. They’re good for representing content-free areas where a hypersnippet’s content can be inserted, such as the holes of a fellow hypersnippet.

procedure

(snippet-sys-snippet-degree ss snippet)

  (dim-sys-dim/c (snippet-sys-dim-sys ss))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
Returns the degree (or dimension) of the given hypersnippet.

procedure

(snippet-sys-snippet-with-degree/c ss    
  degree/c)  flat-contract?
  ss : snippet-sys?
  degree/c : flat-contract?
Returns a flat contract which recognizes any hypersnippet of the given snippet system if its degree satisfies the given flat contract.

procedure

(snippet-sys-snippet-with-degree</c ss    
  degree)  flat-contract?
  ss : snippet-sys?
  degree : (dim-sys-dim/c (snippet-sys-dim-sys ss))

procedure

(snippet-sys-snippet-with-degree=/c ss    
  degree)  flat-contract?
  ss : snippet-sys?
  degree : (dim-sys-dim/c (snippet-sys-dim-sys ss))
Returns a flat contract which recognizes any hypersnippet of the given snippet system if its degree is strictly less than the given one, or if its degree is equal to the given one.

Returns a flat contract which recognizes any hypersnippet of the given snippet system if its degree is strictly greater than 0 (in the sense of dim-sys-dim-zero).

procedure

(snippet-sys-snippetof/ob-c ss 
  ob 
  h-to-value/c) 
  (obstinacy-contract/c ob)
  ss : snippet-sys?
  ob : obstinacy?
  h-to-value/c : 
(-> (snippet-sys-unlabeled-shape/c ss)
  (obstinacy-contract/c ob))
Returns a contract which recognizes any hypersnippet of the given snippet system if the values in its holes abide by the given contracts. The contracts are given by a function h-to-value/c that takes the hypersnippet shape of a hole and returns a contract for values residing in that hole.

This design allows us to require the values in the holes to somehow fit the shapes of the holes they’re carried in. It’s rather common for the value contracts to depend on at least the degree of the hole, if not on its complete shape.

The resulting contract is at least as reticent as the given contract obstinacy. The given contracts must also be at least that reticent.

Returns a flat contract which recognizes any hypersnippet of the given snippet system if it has only trivial? values in its holes.

Returns a flat contract which recognizes any hypersnippet shape of the given snippet system if it has only trivial? values in its holes.

procedure

(snippet-sys-snippet-zip-selective/ob-c ss 
  ob 
  shape 
  check-subject-hv? 
  hvv-to-subject-v/c) 
  (obstinacy-contract/c ob)
  ss : snippet-sys?
  ob : obstinacy?
  shape : (snippet-sys-snippet/c (snippet-sys-shape-snippet-sys ss))
  check-subject-hv? : (-> (snippet-sys-unlabeled-shape/c ss) any/c boolean?)
  hvv-to-subject-v/c : 
(-> (snippet-sys-unlabeled-shape/c ss) any/c any/c
  (obstinacy-contract/c ob))
Returns a contract which recognizes any hypersnippet of the given snippet system if some of its holes correspond with the holes of the given shape hypersnippet shape and if the values in those holes are somehow compatible with the values held in shape’s holes.

To determine which holes from the subject will be compared to those in shape, the given check-subject-hv? is called for each of the subject’s holes, passing it the hole’s shape and the data value it carries. It’s expected to return a boolean indicating whether this hole should correspond to some hole in shape.

To determine if a value in the subject’s holes is compatible with a corresponding (same-shaped) hole in shape, the hvv-to-subject-v/c function is called, passing it the hole’s shape, the value carried in shape’s hole, and the value carried in the subject’s hole. It’s expected to return a contract, and the value in the subject’s hole is expected to abide by that contract.

The resulting contract is at least as reticent as the given contract obstinacy. The given contracts must also be at least that reticent.

procedure

(snippet-sys-snippet-fitting-shape/c ss    
  shape)  flat-contract?
  ss : snippet-sys?
  shape : (snippet-sys-unlabeled-shape/c ss)
Returns a flat contract which recognizes any hypersnippet of the given snippet system if its holes of low enough degree correspond with the holes of the given shape hypersnippet shape and if there are only trivial? values in those holes. Only holes of degree less than the degree of shape are constrained this way; other holes don’t have to coincide with holes of shape, and they can have any contents.

This contract is fairly common because it’s the kind of compatibility that’s needed to concatenate hypersnippets (e.g. using snippet-sys-snippet-bind). It’s similar to joining two 3D polyhedra along a 2D face they share (and the 1D edges and 0D vertices of that face, which they also share).

Given a hypersnippet shape, returns an content-free hypersnippet which has that shape. The result has carries all the same values in its holes.

This operation can be inverted using snippet-sys-snippet->maybe-shape.

procedure

(snippet-sys-snippet->maybe-shape ss 
  snippet) 
  (maybe/c (snippet-sys-snippet/c (snippet-sys-shape-snippet-sys ss)))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
Checks whether a hypersnippet is content-free, and if it is, computes the hypersnippet’s shape.

The resulting shape, if any, carries all the same values in its holes.

This operation is invertible when it succeeds. The resulting shape, if any, can be converted back into a content-free hypersnippet by using snippet-sys-shape->snippet.

procedure

(snippet-sys-snippet-set-degree-maybe ss 
  degree 
  snippet) 
  (maybe/c (snippet-sys-snippet-with-degree=/c ss degree))
  ss : snippet-sys?
  degree : (dim-sys-dim/c (snippet-sys-dim-sys ss))
  snippet : (snippet-sys-snippet/c ss)
If possible, returns a hypersnippet just like the given one but modified to have the given degree.

The resulting hypersnippet, if any, has all the same content as the original and carries all the same values in its holes.

If the given degree is already the same as the given snippet’s degree, this operation succeeds (and returns a snippet equivalent to the original).

If the original snippet has nonzero degree, and if the given degree is greater than the snippet’s existing degree, this operation succeeds.

This operation is invertible when it succeeds. The resulting snippet, if any, can be converted back by calling snippet-sys-snippet-set-degree-maybe again with the snippet’s original degree.

procedure

(snippet-sys-snippet-done ss 
  degree 
  shape 
  data) 
  (snippet-sys-snippet-with-degree=/c ss degree)
  ss : snippet-sys?
  degree : (dim-sys-dim/c (snippet-sys-dim-sys ss))
  shape : 
(snippet-sys-snippet-with-degree</c
  (snippet-sys-shape-snippet-sys ss)
  degree)
  data : any/c
Given a hypersnippet shape, returns a content-free hypersnippet that fits into a hole of that shape and has its own hole of the same shape. The resulting snippet has the given degree, which must be high enough that a hole of shape shape is allowed. The resulting snippet’s shape-shaped hole carries the given data value, and its lower-degree holes carry the same data values carried by shape’s holes.

The results of this operation are the identity elements of hypersnippet concatenation (snippet-sys-snippet-join). It’s the identity on both sides: Filling a hypersnippet’s hole with one of these hypersnippets and concatenating has no effect, and filling this one’s shape-shaped hole with another hypersnippet and concatenating has no effect either.

This operation can be inverted using snippet-sys-snippet-undone.

The results of this operation are always content-free, so they can be successfully converted to shapes by snippet-sys-snippet->maybe-shape.

procedure

(snippet-sys-snippet-undone ss snippet)

  
(maybe/c
  (list/c
    (dim-sys-dim/c (snippet-sys-dim-sys ss))
    (snippet-sys-snippet/c (snippet-sys-shape-snippet-sys ss))
    any/c))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
Checks whether a hypersnippet is an identity element of hypersnippet concatenation, and if it is, obtains three values: Its degree, the shape of hole it interacts with in its role as an identity element, and the data value contained in its own hole of that shape.

The resulting hole shape, if any, carries all the same values in its holes that snippet carries in its low-degree holes.

This operation is invertible when it succeeds. The resulting shape, if any, can be converted back into a content-free hypersnippet by using snippet-sys-snippet-done.

(TODO: Consider renaming this to have "maybe" in the name, bringing it closer to snippet-sys-snippet->maybe-shape and snippet-sys-snippet-set-degree-maybe.)

procedure

(snippet-sys-snippet-select-everything ss 
  snippet) 
  
(and/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet))
  (snippet-sys-snippetof/ob-c ss (flat-obstinacy)
    (fn hole selected?)))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
Returns a hypersnippet like the given one, but where the data value carried in each hole has been selected for traversal in the sense of selectable?.

procedure

(snippet-sys-snippet-splice ss 
  snippet 
  hv-to-splice) 
  
(maybe/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet)))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
  hv-to-splice : 
(->i
  (
    [prefix-hole (snippet-sys-unlabeled-shape/c ss)]
    [data any/c])
  [_ (prefix-hole)
    (maybe/c
      (selectable/c any/c
        (and/c
          (snippet-sys-snippet-with-degree=/c ss
            (snippet-sys-snippet-degree ss snippet))
          (snippet-sys-snippet-fitting-shape/c ss
            prefix-hole))))])
Attempts to concatenate the given "prefix" hypersnippet snippet to any selected "suffix" hypersnippets computed from the hole data by the given selection-attempting data-transforming function hv-to-splice.

The hv-to-splice function is invoked with the shape and data value of each hole of the prefix, possibly stopping partway through if at least one of the invocations returns (nothing). If any invocation returns (nothing), the overall result is (nothing). Otherwise, the concatenation proceeds successfully.

When an invocation of hv-to-splice is successful for some hole of degree N, the result is expected to be a selectable? value. If it’s unselected?, a corresponding hole with the unselected-value appears verbatim in the concatenation result (without the value being concatenated to the prefix hypersnippet). If it’s selected?, its selected-value is expected to be a "suffix" hypersnippet, and it’s concatenated into the prefix hypersnippet along the hole it’s carried by in the prefix. For this concatenation to work, the suffix hypersnippet is expected to have the same degree as the prefix, and its holes of degree less than N are expected to contain trivial? values and to correspond to the holes of the prefix’s hole. Any holes of degree not less than N become holes in the concatenated result.

This operation obeys higher-dimensional algebraic laws. We haven’t really figured out how to express these laws yet, but they seem to correspond to the category-theoretic notion that this operation performs whiskering of higher-dimensional cells along various dimensions at once. (TODO: Do at least a little better. This could be an ongoing effort, but ideally we would have something to show in the #:should-be-equal DSL that we use for other documentation of algebraic laws.)

Some of the lawfulness is a kind of associativity: If we first concatenate along some selected holes and then concatenate along some other holes that weren’t selected the first time, that’s the same as concatenating along all those holes at once. If a hole’s suffix is itself a concatenation of some suffix-prefix to some suffix-suffix, then it doesn’t matter whether we concatenate those two parts to form the suffix first or if we concatenate the prefix to the suffix-prefix and then concatenate the suffix-suffix last.

Some of the lawfulness is a kind of unitality: If the concatenation is being performed along a hole where either the prefix or the suffix is an identity element produced by snippet-sys-snippet-done for that hole shape, then the result resembles the other snippet. (When the prefix is the identity, the result is equal to the suffix. When the suffix is the identity, the result is the prefix, but with its data value in that hole replaced with the data value that would have been passed to snippet-sys-snippet-done when creating the suffix.)

Some of the lawfulness is associativity in a bird’s-eye-view form: If all the hv-to-splice results are selected suffixes, and if the prefix is content-free (in the sense that it can be converted to a shape by snippet-sys-snippet->maybe-shape), then the result is the same as performing multiple concatenations to concatenate the suffixes with each other. In this sense, content-free hypersnippets are like concatenation operations in their own right, possibly like the composition cells of an opetopic higher-dimensional weak category in category theory.

procedure

(snippet-sys-snippet-zip-map-selective ss 
  shape 
  snippet 
  hvv-to-maybe-v) 
  
(maybe/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet)))
  ss : snippet-sys?
  shape : (snippet-sys-snippet/c (snippet-sys-shape-snippet-sys ss))
  snippet : 
(snippet-sys-snippetof/ob-c ss (flat-obstinacy)
  (fn hole selectable?))
  hvv-to-maybe-v : (-> (snippet-sys-unlabeled-shape/c ss) any/c any/c maybe?)
Attempts to use the data carried in the given hypersnippet shape to create a snippet like snippet, but with all its unselected? hole data values unwrapped and all its selected? values replaced by using hvv-to-maybe-v to combine shape’s data and snippet’s data.

The hvv-to-maybe-v function is invoked with the shape of each hole to be combined, the data value from that hole in shape, and the data value from that hole in snippet.

The traversal may stop partway through with a result of (nothing) if it proves to be impossible to align all the holes in shape with all the selected? holes in snippet, or if at least one of the hvv-to-maybe-v invocations returns (nothing).

This operation serves as a way to compare the shape of a snippet with a known shape. For example, when this operation is used with content-free snippets (those which correspond to shapes via snippet-sys-shape->snippet and by snippet-sys-snippet->maybe-shape), and when those snippets have all their data values selected, it effectively serves as a way to compare two shapes for equality. It can also serve as a way to compute whether a given snippet is a compatible fit for a given hole (even if the snippet has some high-degree holes beyond those accounted for in the hole’s shape).

When the "comparison" is successful, that means the shape and snippet have sufficiently similar layouts to combine their data values. That allows this comparison to double as a sort of zipping operation.

procedure

(snippet-sys-snippet-zip-map ss 
  shape 
  snippet 
  hvv-to-maybe-v) 
  
(maybe/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet)))
  ss : snippet-sys?
  shape : (snippet-sys-snippet/c (snippet-sys-shape-snippet-sys ss))
  snippet : (snippet-sys-snippet/c ss)
  hvv-to-maybe-v : (-> (snippet-sys-unlabeled-shape/c ss) any/c any/c maybe?)
Attempts to use the data carried in the given hypersnippet shape to create a snippet like snippet, but with all its hole data values replaced by using hvv-to-maybe-v to combine shape’s data and snippet’s data.

The hvv-to-maybe-v function is invoked with the shape of each hole to be combined, the data value from that hole in shape, and the data value from that hole in snippet.

The traversal may stop partway through with a result of (nothing) if it proves to be impossible to align all the holes in shape with all the holes in snippet, or if at least one of the hvv-to-maybe-v invocations returns (nothing).

This operation serves as a way to compare the shape of a snippet with a known shape. For example, when this operation is used with content-free snippets (those which correspond to shapes via snippet-sys-shape->snippet and by snippet-sys-snippet->maybe-shape), it effectively serves as a way to compare two shapes for equality.

When the "comparison" is successful, that means the shape and snippet have sufficiently similar layouts to combine their data values. That allows this comparison to double as a sort of zipping operation.

procedure

(snippet-sys-snippet-any? ss    
  snippet    
  check-hv?)  boolean?
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
  check-hv? : (-> (snippet-sys-unlabeled-shape/c ss) any/c boolean?)
Iterates over the given hypersnippet’s hole data values in some order and calls the given function on each one, possibly stopping early if at least one invocation of the function returns #t. If any of these invocations of the function returns #t, the result is #t. Otherwise, the result is #f.

This essentially does for hypersnippets what Racket’s ormap does for lists.

procedure

(snippet-sys-snippet-all? ss    
  snippet    
  check-hv?)  boolean?
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
  check-hv? : (-> (snippet-sys-unlabeled-shape/c ss) any/c boolean?)
Iterates over the given hypersnippet’s hole data values in some order and calls the given function on each one, possibly stopping early if at least one invocation of the function returns #f. If any of these invocations of the function returns #f, the result is #f. Otherwise, the result is #t.

This essentially does for hypersnippets what Racket’s andmap does for lists.

procedure

(snippet-sys-snippet-each ss    
  snippet    
  visit-hv)  void?
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
  visit-hv : (-> (snippet-sys-unlabeled-shape/c ss) any/c any)
Iterates over the given hypersnippet’s hole data values in some order and calls the given procedure on each one. The procedure is called only for its side effects. The overall result of this call is (void).

This essentially does for hypersnippets what Racket’s for-each does for lists.

procedure

(snippet-sys-snippet-map-maybe ss 
  snippet 
  hv-to-maybe-v) 
  
(maybe/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet)))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
  hv-to-maybe-v : (-> (snippet-sys-unlabeled-shape/c ss) any/c maybe?)
Iterates over the given hypersnippet’s hole data values in some order and calls the given function on each one, possibly stopping early if at least one invocation of the function returns (nothing). If any of these invocations of the function returns (nothing), the result is (nothing). Otherwise, the result is a just? of a hypersnippet where the values have been replaced with the corresponding hv-to-maybe-v function results.

procedure

(snippet-sys-snippet-map ss snippet hv-to-v)

  
(snippet-sys-snippet-with-degree=/c ss
  (snippet-sys-snippet-degree ss snippet))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
  hv-to-v : (-> (snippet-sys-unlabeled-shape/c ss) any/c any/c)
Transforms the given hypersnippet’s hole data values by calling the given function on each one.

procedure

(snippet-sys-snippet-map-selective ss 
  snippet 
  hv-to-v) 
  
(snippet-sys-snippet-with-degree=/c ss
  (snippet-sys-snippet-degree ss snippet))
  ss : snippet-sys?
  snippet : 
(snippet-sys-snippetof/ob-c ss (flat-obstinacy)
  (fn hole selectable?))
  hv-to-v : (-> (snippet-sys-unlabeled-shape/c ss) any/c any/c)
Transforms the given hypersnippet’s hole data values by calling the given function on each selected? one.

procedure

(snippet-sys-snippet-select ss 
  snippet 
  check-hv?) 
  
(and/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet))
  (snippet-sys-snippetof/ob-c ss (flat-obstinacy)
    (fn hole selectable?)))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
  check-hv? : (-> (snippet-sys-unlabeled-shape/c ss) any/c boolean?)
Turns the given hypersnippet’s hole data values into selectable? values by calling the given function to decide whether each one should be selected?.

procedure

(snippet-sys-snippet-select-if-degree ss 
  snippet 
  check-degree?) 
  
(and/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet))
  (snippet-sys-snippetof/ob-c ss (flat-obstinacy)
    (fn hole selectable?)))
  ss : snippet-sys?
  snippet : (snippet-sys-snippet/c ss)
  check-degree? : (-> (dim-sys-dim/c (snippet-sys-dim-sys ss)) boolean?)
Turns the given hypersnippet’s hole data values into selectable? values by calling the given function on each hole’s degree decide whether the value should be selected?.

procedure

(snippet-sys-snippet-select-if-degree< ss 
  degreee 
  snippet) 
  
(and/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet))
  (snippet-sys-snippetof/ob-c ss (flat-obstinacy)
    (fn hole selectable?)))
  ss : snippet-sys?
  degreee : (dim-sys-dim/c (snippet-sys-dim-sys ss))
  snippet : (snippet-sys-snippet/c ss)
Turns the given hypersnippet’s hole data values into selectable? values by selecting the values whose holes’ degrees are strictly less than the given one.

procedure

(snippet-sys-snippet-bind-selective ss 
  prefix 
  hv-to-suffix) 
  
(maybe/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss prefix)))
  ss : snippet-sys?
  prefix : (snippet-sys-snippet/c ss)
  hv-to-suffix : 
(->i
  (
    [prefix-hole (snippet-sys-unlabeled-shape/c ss)]
    [data any/c])
  [_ (prefix-hole)
    (selectable/c any/c
      (and/c
        (snippet-sys-snippet-with-degree=/c ss
          (snippet-sys-snippet-degree ss prefix))
        (snippet-sys-snippet-fitting-shape/c ss
          prefix-hole)))])
Concatenates the given "prefix" hypersnippet prefix to any selected "suffix" hypersnippets computed from the hole data by the given selection function hv-to-suffix.

When hv-to-suffix is invoked for some hole of degree N, the result is expected to be a selectable? value. If it’s unselected?, a corresponding hole with the unselected-value appears verbatim in the concatenation result (without the value being concatenated to the prefix hypersnippet). If it’s selected?, its selected-value is expected to be a "suffix" hypersnippet, and it’s concatenated into the prefix hypersnippet along the hole it’s carried by in the prefix. For this concatenation to work, the suffix hypersnippet is expected to have the same degree as the prefix, and its holes of degree less than N are expected to contain trivial? values and to correspond to the holes of the prefix’s hole. Any holes of degree not less than N become holes in the concatenated result.

This operation is a specialization of snippet-sys-snippet-splice to the case where the concatenation is always successful. It obeys similar higher-dimensional algebraic laws.

procedure

(snippet-sys-snippet-join-selective ss 
  snippet) 
  
(maybe/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet)))
  ss : snippet-sys?
  snippet : 
(and/c (snippet-sys-snippet/c ss)
  (snippet-sys-snippetof/ob-c ss (flat-obstinacy)
    (fn prefix-hole
      (selectable/c any/c
        (and/c
          (snippet-sys-snippet-with-degree=/c ss
            (snippet-sys-snippet-degree ss snippet))
          (snippet-sys-snippet-fitting-shape/c ss
            prefix-hole))))))
Concatenates the given "prefix" hypersnippet snippet to any selected "suffix" hypersnippets in its hole data values.

Each hole data value is expected to be a selectable? value. If it’s unselected?, a corresponding hole with the unselected-value appears verbatim in the concatenation result (without the value being concatenated to the prefix hypersnippet). If it’s selected?, its selected-value is expected to be a "suffix" hypersnippet, and it’s concatenated into the prefix hypersnippet along the hole it’s carried by in the prefix. For this concatenation to work, the suffix hypersnippet is expected to have the same degree as the prefix, and its holes of degree less than N are expected to contain trivial? values and to correspond to the holes of the prefix’s hole. Any holes of degree not less than N become holes in the concatenated result.

This operation is a specialization of snippet-sys-snippet-splice to the case where the concatenation is always successful and the transformation function is always the identity. It obeys higher-dimensional algebraic laws similar to those snippet-sys-snippet-splice obeys.

procedure

(snippet-sys-snippet-bind ss 
  prefix 
  hv-to-suffix) 
  
(maybe/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss prefix)))
  ss : snippet-sys?
  prefix : (snippet-sys-snippet/c ss)
  hv-to-suffix : 
(->i
  (
    [prefix-hole (snippet-sys-unlabeled-shape/c ss)]
    [data any/c])
  [_ (prefix-hole)
    (and/c
      (snippet-sys-snippet-with-degree=/c ss
        (snippet-sys-snippet-degree ss prefix))
      (snippet-sys-snippet-fitting-shape/c ss prefix-hole))])
Concatenates the given "prefix" hypersnippet prefix to the "suffix" hypersnippets computed from the hole data by the given selection function hv-to-suffix.

Each suffix hypersnippet is concatenated into the prefix hypersnippet along the hole it’s carried by in the prefix. For this concatenation to work, the suffix hypersnippet is expected to have the same degree as the prefix, and its holes of degree less than N are expected to contain trivial? values and to correspond to the holes of the prefix’s hole. Any holes of degree not less than N become holes in the concatenated result.

This operation is a specialization of snippet-sys-snippet-bind-selective to the case where every hole is selected. That, in turn, is a specialization of snippet-sys-snippet-splice. Each of these operations obeys similar higher-dimensional algebraic laws.

procedure

(snippet-sys-snippet-join ss snippet)

  
(maybe/c
  (snippet-sys-snippet-with-degree=/c ss
    (snippet-sys-snippet-degree ss snippet)))
  ss : snippet-sys?
  snippet : 
(and/c (snippet-sys-snippet/c ss)
  (snippet-sys-snippetof/ob-c ss (flat-obstinacy)
    (fn prefix-hole
      (and/c
        (snippet-sys-snippet-with-degree=/c ss
          (snippet-sys-snippet-degree ss snippet))
        (snippet-sys-snippet-fitting-shape/c ss
          prefix-hole)))))
Concatenates the given "prefix" hypersnippet snippet to the "suffix" hypersnippets in its hole data values.

Each suffix is concatenated into the prefix hypersnippet along the hole it’s carried by in the prefix. For this concatenation to work, the suffix hypersnippet is expected to have the same degree as the prefix, and its holes of degree less than N are expected to contain trivial? values and to correspond to the holes of the prefix’s hole. Any holes of degree not less than N become holes in the concatenated result.

This operation is a specialization of snippet-sys-snippet-join-selective to the case where every hole is selected. That, in turn, is a specialization of snippet-sys-snippet-splice. Each of these operations obeys similar higher-dimensional algebraic laws.

procedure

(make-snippet-sys-impl-from-various-1 
  snippet/c 
  dim-sys 
  shape-snippet-sys 
  snippet-degree 
  shape->snippet 
  snippet->maybe-shape 
  snippet-set-degree-maybe 
  snippet-done 
  snippet-undone 
  snippet-splice 
  snippet-zip-map-selective) 
  snippet-sys-impl?
  snippet/c : (-> snippet-sys? flat-contract?)
  dim-sys : (-> snippet-sys? dim-sys?)
  shape-snippet-sys : (-> snippet-sys? snippet-sys?)
  snippet-degree : 
(->i
  (
    [ss snippet-sys?]
    [snippet (ss) (snippet-sys-snippet/c ss)])
  [_ (ss) (dim-sys-dim/c (snippet-sys-dim-sys ss))])
  shape->snippet : 
(->i
  (
    [ss snippet-sys?]
    [shape (ss)
      (snippet-sys-snippet/c
        (snippet-sys-shape-snippet-sys ss))])
  [_ (ss shape)
    (snippet-sys-snippet-with-degree=/c ss
      (snippet-sys-snippet-degree
        (snippet-sys-shape-snippet-sys ss)
        shape))])
  snippet->maybe-shape : 
(->i
  (
    [ss snippet-sys?]
    [snippet (ss) (snippet-sys-snippet/c ss)])
  [_ (ss snippet)
    (maybe/c
      (snippet-sys-snippet/c
        (snippet-sys-shape-snippet-sys ss)))])
  snippet-set-degree-maybe : 
(->i
  (
    [ss snippet-sys?]
    [degree (ss) (dim-sys-dim/c (snippet-sys-dim-sys ss))]
    [snippet (ss) (snippet-sys-snippet/c ss)])
  [_ (ss degree)
    (maybe/c
      (snippet-sys-snippet-with-degree=/c ss degree))])
  snippet-done : 
(->i
  (
    [ss snippet-sys?]
    [degree (ss) (dim-sys-dim/c (snippet-sys-dim-sys ss))]
    [shape (ss degree)
      (snippet-sys-snippet-with-degree</c
        (snippet-sys-shape-snippet-sys ss)
        degree)]
    [data any/c])
  [_ (ss degree)
    (snippet-sys-snippet-with-degree=/c ss degree)])
  snippet-undone : 
(->i
  (
    [ss snippet-sys?]
    [snippet (ss) (snippet-sys-snippet/c ss)])
  [_ (ss snippet)
    (maybe/c
      (list/c
        (dim-sys-dim/c (snippet-sys-dim-sys ss))
        (snippet-sys-snippet/c
          (snippet-sys-shape-snippet-sys ss))
        any/c))])
  snippet-splice : 
(->i
  (
    [ss snippet-sys?]
    [snippet (ss) (snippet-sys-snippet/c ss)]
    [hv-to-splice (ss snippet)
      (->i
        (
          [prefix-hole (snippet-sys-unlabeled-shape/c ss)]
          [data any/c])
        [_ (prefix-hole)
          (maybe/c
            (selectable/c any/c
              (and/c
                (snippet-sys-snippet-with-degree=/c ss
                  (snippet-sys-snippet-degree ss snippet))
                (snippet-sys-snippet-fitting-shape/c ss
                  prefix-hole))))])])
  [_ (ss snippet)
    (maybe/c
      (snippet-sys-snippet-with-degree=/c ss
        (snippet-sys-snippet-degree ss snippet)))])
  snippet-zip-map-selective : 
(->i
  (
    [ss snippet-sys?]
    [shape (ss)
      (snippet-sys-snippet/c
        (snippet-sys-shape-snippet-sys ss))]
    [snippet (ss)
      (snippet-sys-snippetof/ob-c ss (flat-obstinacy)
        (fn hole selectable?))]
    [hvv-to-maybe-v (ss)
      (-> (snippet-sys-unlabeled-shape/c ss) any/c any/c
        maybe?)])
  [_ (ss snippet)
    (maybe/c
      (snippet-sys-snippet-with-degree=/c ss
        (snippet-sys-snippet-degree ss snippet)))])
Given implementations for the following methods, returns something a struct can use to implement the prop:snippet-sys interface.

The given method implementations should observe quite a few algebraic laws. At this point, we’re not entirely sure what the full extent of these laws should be yet. (TODO: Do at least a little better. This could be an ongoing effort, but ideally we would have something to show in the #:should-be-equal DSL that we use for other documentation of algebraic laws.) Even though this isn’t going to be comprehensive, here’s a rundown of quite a number of the assumptions we make about hypersnippet operations:

3.2.2 Category-Theoretic Snippet System Manipulations🔗ℹ

Structure type property operations for structure-preserving transformations from one snippet system’s dimension numbers, hypersnippet shapes, and hypersnippets to another’s. In particular, these preserve relatedness of these values under the various operations a snippet system supplies.

Returns a snippet-sys-morphism-sys? value’s source snippet system.

Returns a snippet-sys-morphism-sys? value like the given one, but with its source snippet system replaced with the given one. This may raise an error if the given value isn’t similar enough to the one being replaced. This is intended only for use by snippet-sys-morphism-sys/c and similar error-detection systems as a way to replace a value with one that reports better errors.

Returns a snippet-sys-morphism-sys? value’s target snippet system.

Returns a snippet-sys-morphism-sys? value like the given one, but with its target snippet system replaced with the given one. This may raise an error if the given value isn’t similar enough to the one being replaced. This is intended only for use by snippet-sys-morphism-sys/c and similar error-detection systems as a way to replace a value with one that reports better errors.

Given a snippet system, obtains the dimension system that governs the degrees of its hypersnippets.

Given a snippet system, obtains the snippet system that governs how its hypersnippet shapes interact with each other as hypersnippets in their own right.

Transforms a hypersnippet according to the given snippet-sys-morphism-sys? value.

procedure

(make-snippet-sys-morphism-sys-impl-from-morph 
  source 
  replace-source 
  target 
  replace-target 
  dim-sys-morphism-sys 
  shape-snippet-sys-morphism-sys 
  morph-snippet) 
  snippet-sys-morphism-sys-impl?
  source : (-> snippet-sys-morphism-sys? snippet-sys?)
  replace-source : 
(-> snippet-sys-morphism-sys? snippet-sys?
  snippet-sys-morphism-sys?)
  target : (-> snippet-sys-morphism-sys? snippet-sys?)
  replace-target : 
(-> snippet-sys-morphism-sys? snippet-sys?
  snippet-sys-morphism-sys?)
  dim-sys-morphism-sys : (-> snippet-sys-morphism-sys? dim-sys-morphism-sys?)
  shape-snippet-sys-morphism-sys : (-> snippet-sys-morphism-sys? snippet-sys-morphism-sys?)
  morph-snippet : 
(->i
  (
    [ms snippet-sys-morphism-sys?]
    [object (ms)
      (snippet-sys-snippet/c
        (snippet-sys-morphism-sys-source ms))])
  [_ (ms)
    (snippet-sys-snippet/c
      (snippet-sys-morphism-sys-target ms))])
Given implementations for the following methods, returns something a struct can use to implement the prop:snippet-sys-morphism-sys interface.

When the replace methods don’t raise errors, they should observe the lens laws: The result of getting a value after it’s been replaced should be the same as just using the value that was passed to the replacer. The result of replacing a value with itself should be the same as not using the replacer at all. The result of replacing a value and replacing it a second time should be the same as just skipping to the second replacement.

Moreover, the replace methods should not raise an error when a value is replaced with itself. They’re intended only for use by snippet-sys-morphism-sys/c and similar error-detection systems, which will tend to replace a replace a value with one that reports better errors.

The other given method implementations should observe some algebraic laws. As with the laws described in make-snippet-sys-impl-from-various-1, we’re not quite sure what these laws should be yet (TODO), but here’s an inexhaustive description:

procedure

(snippet-sys-morphism-sys/c source/c    
  target/c)  contract?
  source/c : contract?
  target/c : contract?
Returns a contract that recognizes any snippet-sys-morphism-sys? value whose source and target snippet systems are recognized by the given contracts.

The result is a flat contract as long as the given contracts are flat.

procedure

(snippet-sys-morphism-sys-identity endpoint)

  (snippet-sys-morphism-sys/c (ok/c endpoint) (ok/c endpoint))
  endpoint : snippet-sys?
Returns the identity snippet-sys-morphism-sys? value on the given snippet system. This is a transformation that goes from the given snippet system to itself, taking every dimension number, hypersnippet shape, and hypersnippet to itself.

Returns the composition of the two given snippet-sys-morphism-sys? values. This is a transformation that goes from the first transformation’s source snippet system to the second transformation’s target snippet system, transforming every dimension number, hypersnippet shape, and hypersnippet by applying the first transformation and then the second. The target of the first transformation should match the source of the second.

This composition operation is written in diagrammatic order, where in the process of reading off the arguments from left to right, we proceed from the source to the target of each transformation. Composition is often written with its arguments the other way around (e.g. in Racket’s compose operation).

Struct-like operations which construct and deconstruct a lathe-morphisms/in-fp/category category (category-sys?) where the objects are snippet systems and the morphisms are structure-preserving transformations between them (namely, snippet-sys-morphism-sys? values).

Every two snippet-sys-category-sys values are equal?. One such value is always an ok/c match for another.

procedure

(functor-from-snippet-sys-sys-apply-to-morphism fs 
  ssms) 
  
(category-sys-morphism/c (functor-sys-target fs)
  (functor-sys-apply-to-object fs
    (snippet-sys-morphism-sys-source ssms))
  (functor-sys-apply-to-object fs
    (snippet-sys-morphism-sys-target ssms)))
  fs : (functor-sys/c snippet-sys-category-sys? any/c)
  ssms : snippet-sys-morphism-sys?
Uses the given lathe-morphisms/in-fp/category functor to transform a snippet-sys-morphism-sys? value.

This is equivalent to (functor-sys-apply-to-morphism fs (snippet-sys-morphism-sys-source ssms) (snippet-sys-morphism-sys-target ssms) ssms).

procedure

(natural-transformation-from-from-snippet-sys-sys-apply-to-morphism 
  nts 
  ssms) 
  
(category-sys-morphism/c
  (natural-transformation-sys-endpoint-target nts)
  (functor-sys-apply-to-object
    (natural-transformation-sys-source nts)
    (snippet-sys-morphism-sys-source ssms))
  (functor-sys-apply-to-object
    (natural-transformation-sys-target nts)
    (snippet-sys-morphism-sys-target ssms)))
  nts : 
(natural-transformation-sys/c
  snippet-sys-category-sys? any/c any/c any/c)
  ssms : snippet-sys-morphism-sys?
Uses the given lathe-morphisms/in-fp/category natural transformation to transform a snippet-sys-morphism-sys? value.

This is equivalent to (natural-transformation-sys-apply-to-morphism fs (snippet-sys-morphism-sys-source ssms) (snippet-sys-morphism-sys-target ssms) ssms).

Returns whether the given value is a lathe-morphisms/in-fp/category functor from the category (dim-sys-category-sys) to the category (snippet-sys-category-sys).

procedure

(make-functor-from-dim-sys-to-snippet-sys-sys-impl-from-apply 
  apply-to-dim-sys 
  apply-to-dim-sys-morphism-sys) 
  functor-sys-impl?
  apply-to-dim-sys : 
(-> functor-from-dim-sys-to-snippet-sys-sys? dim-sys?
  snippet-sys?)
  apply-to-dim-sys-morphism-sys : 
(->i
  (
    [es functor-from-dim-sys-to-snippet-sys-sys?]
    [ms dim-sys-morphism-sys?])
  [_ (es ms)
    (snippet-sys-morphism-sys/c
      (ok/c
        (functor-sys-apply-to-object es
          (dim-sys-morphism-sys-source ms)))
      (ok/c
        (functor-sys-apply-to-object es
          (dim-sys-morphism-sys-target ms))))])
Given implementations for the following methods, returns something a struct can use to implement the prop:functor-sys interface in a way that makes it satisfy functor-from-dim-sys-to-snippet-sys-sys?.

These method implementations should observe the same algebraic laws as those required by make-functor-sys-impl-from-apply.

This is essentially a shorthand for calling make-functor-sys-impl-from-apply and supplying the appropriate source- and target-determining method implementations.

Returns whether the given value is a lathe-morphisms/in-fp/category natural transformation between two functors which each go from the category (dim-sys-category-sys) to the category (snippet-sys-category-sys).

This could be called ‘natural-transformation-from-from-dim-sys-to-to-snippet-sys-sys?‘, but that would be even more verbose.

Given implementations for the following methods, returns something a struct can use to implement the prop:natural-transformation-sys interface in a way that makes it satisfy functor-from-dim-sys-to-snippet-sys-sys-morphism-sys?.

These method implementations should observe the same algebraic laws as those required by make-natural-transformation-sys-impl-from-apply.

This is essentially a shorthand for calling make-natural-transformation-sys-impl-from-apply and supplying the appropriate endpoint-source- and endpoint-target-determining method implementations.

3.2.3 Snippet Format Systems in General🔗ℹ

Structure type property operations for snippet format systems. These are like snippet systems in that they determine operations over hypersnippet shapes and hypersnippets, but the dimension system is left undetermined until the caller chooses it.

Returns the lathe-morphisms/in-fp/category functor associated with the given snippet format system.

This functor takes dimension systems to snippet systems that use them. It also takes dim-sys-morphism-sys? values to snippet-sys-morphism-sys? values, which facilitates the conversion of hypersnippets between two snippet systems that differ only in their choice of dimension system.

Given an implementation for snippet-format-sys-functor, returns something a struct can use to implement the prop:snippet-format-sys interface.

The given method implementations should observe some algebraic laws. Namely, the result of applying the functor to a dimension system should be a snippet system that uses it as its snippet-sys-dim-sys. Likewise, the result of applying the functor to a dim-sys-morphism-sys? should be a snippet-sys-morphism-sys? that uses it as its snippet-sys-morphism-sys-dim-sys-morphism-sys. In more symbolic terms (using a pseudocode DSL):

(#:for-all
  sfs snippet-format-sys?
  #:let ffdstsss (snippet-format-sys-functor sfs)
  dms dim-sys-morphism-sys?
 
  (#:should-be-equal
    (snippet-sys-morphism-sys-dim-sys-morphism-sys
      (functor-from-dim-sys-sys-apply-to-morphism ffdstsss dms))
    dms))
3.2.4 Category-Theoretic Snippet Format System Manipulations🔗ℹ

Structure type property operations for structure-preserving transformations from one snippet format system to another. In practical terms, these are ways to transform one kind of hypersnippet to another kind of hypersnippet without caring about what dimension system is in use.

In terms of category theory, these are based on natural transformations which go beteween the respective snippet-format-sys-functor values, which means they’re transformations of dim-sys-morphism-sys? values to snippet-sys-morphism-sys? values which don’t necessarily take each identity morphism to an identity morphism. Unlike just any natural transformations, these also respect the fact that a snippet format system always produces a snippet system that uses the given dimension system. To respect this, this natural transformation takes a dim-sys-morphism-sys? value to a snippet-sys-morphism-sys? value which has it as its snippet-sys-morphism-sys-dim-sys-morphism-sys.

Returns a snippet-format-sys-morphism-sys? value like the given one, but with its source snippet format system replaced with the given one. This may raise an error if the given value isn’t similar enough to the one being replaced. This is intended only for use by snippet-format-sys-morphism-sys/c and similar error-detection systems as a way to replace a value with one that reports better errors.

Returns a snippet-format-sys-morphism-sys? value like the given one, but with its target snippet format system replaced with the given one. This may raise an error if the given value isn’t similar enough to the one being replaced. This is intended only for use by snippet-format-sys-morphism-sys/c and similar error-detection systems as a way to replace a value with one that reports better errors.

Returns the lathe-morphisms/in-fp/category natural transformation associated with the given snippet format system morphism.

This natural transformation takes dim-sys-morphism-sys? values to snippet-sys-morphism-sys? values that use them as their snippet-sys-morphism-sys-dim-sys-morphism-sys values.

Given implementations for the following methods, returns something a struct can use to implement the prop:snippet-format-sys-morphism-sys interface.

When the replace methods don’t raise errors, they should observe the lens laws: The result of getting a value after it’s been replaced should be the same as just using the value that was passed to the replacer. The result of replacing a value with itself should be the same as not using the replacer at all. The result of replacing a value and replacing it a second time should be the same as just skipping to the second replacement.

Moreover, the replace methods should not raise an error when a value is replaced with itself. They’re intended only for use by snippet-format-sys-morphism-sys/c and similar error-detection systems, which will tend to replace a replace a value with one that reports better errors.

The other given method implementation (snippet-format-sys-morphism-sys-functor-morphism) should observe some algebraic laws. Namely, when its resulting natural transformation is applied to a dim-sys-morphism-sys? value, it should result in a snippet-sys-morphism-sys? value that uses that value as its snippet-sys-morphism-sys-dim-sys-morphism-sys. In more symbolic terms (using a pseudocode DSL):

(#:for-all
  sfsms snippet-format-sys-morphism-sys?
 
  #:let ffdstsssms
  (snippet-format-sys-morphism-sys-functor-morphism sfsms)
 
  dms dim-sys-morphism-sys?
 
  (#:should-be-equal
    (snippet-sys-morphism-sys-dim-sys-morphism-sys
      (natural-transformation-from-from-dim-sys-sys-apply-to-morphism
        ffdstsssms dms))
    dms))

procedure

(snippet-format-sys-morphism-sys/c source/c    
  target/c)  contract?
  source/c : contract?
  target/c : contract?
Returns a contract that recognizes any snippet-format-sys-morphism-sys? value whose source and target snippet format systems are recognized by the given contracts.

The result is a flat contract as long as the given contracts are flat.

procedure

(snippet-format-sys-morphism-sys-identity endpoint)

  (snippet-format-sys-morphism-sys/c (ok/c endpoint) (ok/c endpoint))
  endpoint : snippet-format-sys?
Returns the identity snippet-format-sys-morphism-sys? value on the given snippet format system. This is a transformation that goes from the given snippet format system to itself, taking every dim-sys-morphism-sys? value to whatever snippet-sys-morphism-sys? value the snippet format system’s snippet-format-sys-functor takes it to.

Returns the composition of the two given snippet-format-sys-morphism-sys? values. This is a transformation that goes from the first transformation’s source snippet format system to the second transformation’s target snippet format system, transforming a dim-sys-morphism-sys? value by applying one of the snippet-format-sys-morphism-sys? values to it, applying the other to an identity dim-sys-morphism-sys? value, and composing the two results. The target of the first transformation should match the source of the second.

This composition operation is written in diagrammatic order, where in the process of reading off the arguments from left to right, we proceed from the source to the target of each transformation. Composition is often written with its arguments the other way around (e.g. in Racket’s compose operation).

Struct-like operations which construct and deconstruct a lathe-morphisms/in-fp/category category (category-sys?) where the objects are snippet format systems and the morphisms are structure-preserving transformations between them (namely, snippet-format-sys-morphism-sys? values).

Every two snippet-format-sys-category-sys values are equal?. One such value is always an ok/c match for another.

Returns whether the given value is a lathe-morphisms/in-fp/category functor from the category (snippet-format-sys-category-sys) to itself.

procedure

(make-snippet-format-sys-endofunctor-sys-impl-from-apply 
  apply-to-snippet-format-sys 
  apply-to-snippet-format-sys-morphism-sys) 
  functor-sys-impl?
  apply-to-snippet-format-sys : 
(-> snippet-format-sys-endofunctor-sys? snippet-format-sys?
  snippet-format-sys?)
  apply-to-snippet-format-sys-morphism-sys : 
(->i
  (
    [es snippet-format-sys-endofunctor-sys?]
    [ms snippet-format-sys-morphism-sys?])
  [_ (es ms)
    (snippet-format-sys-morphism-sys/c
      (ok/c
        (functor-sys-apply-to-object es
          (snippet-format-sys-morphism-sys-source ms)))
      (ok/c
        (functor-sys-apply-to-object es
          (snippet-format-sys-morphism-sys-target ms))))])
Given implementations for the following methods, returns something a struct can use to implement the prop:functor-sys interface in a way that makes it satisfy snippet-format-sys-endofunctor-sys?.

These method implementations should observe the same algebraic laws as those required by make-functor-sys-impl-from-apply.

This is essentially a shorthand for calling make-functor-sys-impl-from-apply and supplying the appropriate source- and target-determining method implementations.