AutoPrism

public protocol AutoPrism : AutoOptics

Protocol for automatic derivation of Prism optics.

  • prism(for:) Extension method

    Generates a prism for an enum case with no associated values.

    Declaration

    Swift

    static func prism(for case: Self) -> Prism<Self, ()>

    Parameters

    case

    Case where the Prism must focus.

    Return Value

    A Prism focusing on the provided case.

  • prism(for:matching:) Extension method

    Generates a prism for an enum case with associated values.

    Declaration

    Swift

    static func prism<A>(for constructor: @escaping (A) -> Self, matching: @escaping (Self) -> A?) -> Prism<Self, A>

    Parameters

    constructor

    Constructor for the case with associated values.

    matching

    Closure that matches the focused case of this prism and returns its associated values.

    Return Value

    A Prism focusing on the provided case.