Snoc

public protocol Snoc

Snoc defines a Prism between this structure and its init (all elements but the last one) and last elements. It can be seen as the reverse of Cons. It provides a way to attach or detach elements on the end side of a structure.

  • Undocumented

    Declaration

    Swift

    associatedtype Last
  • Provides a Prism between this structure and its init and last element.

    Declaration

    Swift

    static var snoc: Prism<Self, (Self, Last)> { get }
  • initialOption Extension method

    Provides an Optional between this structure and its initial part (all elements but the last one).

    Declaration

    Swift

    static var initialOption: Optional<Self, Self> { get }
  • lastOption Extension method

    Provides an Optional between this structure and its last element.

    Declaration

    Swift

    static var lastOption: Optional<Self, Last> { get }
  • snoc(_:) Extension method

    Pre-composes the Prism provided by this Snoc with an isomorphism.

    Declaration

    Swift

    static func snoc<B>(_ iso: Iso<B, Self>) -> Prism<B, (B, Last)>

    Parameters

    iso

    An isomorphism.

    Return Value

    A Prism between an structure that is isomorphic to this one and its init and last element.

  • snoc(_:) Extension method

    Post-composes the Prism provided by this Snoc with an isomorphism.

    Declaration

    Swift

    static func snoc<B>(_ iso: Iso<Last, B>) -> Prism<Self, (Self, B)>

    Parameters

    iso

    An isomorphism.

    Return Value

    A Prism between this structure and a new foci that is isomorphic to the original one.

  • initial Extension method

    Retrieves the initial part of this structure (all elements but the last one).

    Declaration

    Swift

    var initial: Option<Self> { get }
  • last Extension method

    Retrieves the last element of this structure.

    Declaration

    Swift

    var last: Option<Last> { get }
  • append(_:) Extension method

    Appends an element at the end of this structure.

    Declaration

    Swift

    func append(_ a: Last) -> Self

    Parameters

    a

    Element to append.

    Return Value

    A new structure with the provided element at the end.

  • unsnoc Extension method

    Deconstructs this structure into its initial part (all elements but the last one) and its last element.

    Declaration

    Swift

    var unsnoc: Option<(Self, Last)> { get }