 }
 
 /**
-This function is documented with the FilterFunction type.
-
-:see: FilterFunction
+Builds a filter that takes a single argument of type `T` and performs custom
+rendering.
+
+If the template argument evaluates to a missing value, or a value which is not
+of type T, the filter returns an error of domain `GRMustacheErrorDomain` and
+code `GRMustacheErrorCodeRenderingError`.
+
+If the template provides more than one argument, the filter returns an error of
+domain `GRMustacheErrorDomain` and code `GRMustacheErrorCodeRenderingError`.
+
+See the documentation of the `RenderFunction` type for a detailed discussion of
+the `RenderingInfo` and `Rendering` types.
+
+For an example of such a filter, see the documentation of
+`func Filter(filter: (Int, RenderingInfo, NSErrorPointer) -> Rendering?) -> FilterFunction`.
+This example processes `Int` instead of `T`, but the idea is the same.
+
+:param: filter a function `(T, RenderingInfo, NSErrorPointer) -> Rendering?`
+:returns: a FilterFunction
 */
 public func Filter<T>(filter: (T, RenderingInfo, NSErrorPointer) -> Rendering?) -> FilterFunction {
-    // The roles of core functions are clear:
-    // - transforming values is the role of FilterFunction
-    // - performing custom rendering is the role of RenderFunction
-    //
-    // Hence, a "filter that performs custom rendering" is simply a
-    // FilterFunction which returns a RenderFunction:
     return Filter { (t: T, error: NSErrorPointer) in
+        // Box a RenderFunction
         return Box { (info: RenderingInfo, error: NSErrorPointer) in
             return filter(t, info, error)
         }

}

/**
This function is documented with the FilterFunction type.

:see: FilterFunction
*/
public func Filter(filter: (Double, RenderingInfo, NSErrorPointer) -> Rendering?) -> FilterFunction {
    // The roles of core functions are clear:
    // - transforming values is the role of FilterFunction
    // - performing custom rendering is the role of RenderFunction
    //
    // Hence, a "filter that performs custom rendering" is simply a
    // FilterFunction which returns a RenderFunction:
    return Filter { (double: Double, error: NSErrorPointer) in
        return Box { (info: RenderingInfo, error: NSErrorPointer) in
            return filter(double, info, error)
        }

}

/**
Returns a filter than accepts any number of arguments.

For example:

    // `sum(x, ...)` evaluates to the sum of provided integers
    let sum = VariadicFilter { (boxes: [MustacheBox], _) in
        // Extract integers out of input boxes, assuming zero for non numeric values
        let integers = map(boxes) { (box) in box.intValue ?? 0 }
        let sum = reduce(integers, 0, +)
        return Box(sum)
    }

    let template = Template(string: "{{ sum(a,b,c) }}")!
    template.registerInBaseContext("sum", Box(sum))

    // Renders "6"
    template.render(Box(["a": 1, "b": 2, "c": 3]))!

If your filter is given too many or too few arguments, you should return nil and
set error to an NSError of domain `GRMustacheErrorDomain` and code
`GRMustacheErrorCodeRenderingError`.

:param: filter a function `(boxes: [MustacheBox], error: NSErrorPointer) -> Rendering?`
:returns: a FilterFunction
*/
public func VariadicFilter(filter: (boxes: [MustacheBox], error: NSErrorPointer) -> MustacheBox?) -> FilterFunction {
    return _VariadicFilter([], filter)
