Hi Marek,

Marek Paśnikowski <[email protected]> skribis:

> (define* (fold-services services #:key (target-type system-service-type))
>  ...
>  ...
>  ...
>  (match (filter ... services)
>   ((sink) (run-with-state ...))
>   (() (raise ...))
>   (x (raise ...))))
>
> My current understanding is that the filter may return one of three patterns:
> 1. An empty list when the list of services does not contain the target-type.
> 2. A single-element list when a correctly formed list of services is provided.
> 3. A many-element list when the list of services contains multiple services 
> of target-type.

Correct.  This is exactly what the three clauses above match: the first
one matches one-element lists, the second one matches the empty list,
and the last clause matches lists of two or more elements.

> This does not make sense to me when comparing with the implementation of 
> pattern matching in the function.
> The Scheme Documentation on pattern matching is unhelpful, and neither are 
> the cryptic binding names in the function.

Note that ‘match’ here comes from Guile’s (ice-9 match):

  https://www.gnu.org/software/guile/manual/html_node/Pattern-Matching.html

There is no such thing in the Scheme standard.

HTH!

Ludo’.

Reply via email to