Array

@frozen
struct Array<Element> : _DestructorSafeContainer
  • Provides a Fold based on the Foldable instance of this type.

    Declaration

    Swift

    static var fold: Fold<Array<Element>, Element> { get }
  • Provides a Traversal based on the Traverse instance of this type.

    Declaration

    Swift

    static var traversal: Traversal<Array<Element>, Element> { get }
  • Undocumented

    Declaration

    Swift

    public typealias EachFoci = Element
  • Declaration

    Swift

    public static var each: Traversal<Array<Element>, Element> { get }
  • Undocumented

    Declaration

    Swift

    public typealias IndexType = Int
  • Undocumented

    Declaration

    Swift

    public typealias IndexFoci = Element
  • Declaration

    Swift

    public static func index(_ i: Int) -> Optional<Array<Element>, Element>
  • Undocumented

    Declaration

    Swift

    public typealias FilterIndexType = Int
  • Undocumented

    Declaration

    Swift

    public typealias FilterIndexFoci = Element
  • Declaration

    Swift

    public static func filter(_ predicate: @escaping (Int) -> Bool) -> Traversal<Array<Element>, Element>
  • Undocumented

    Declaration

    Swift

    public typealias First = Element
  • Declaration

    Swift

    public static var cons: Prism<Array<Element>, (Element, Array<Element>)> { get }
  • Undocumented

    Declaration

    Swift

    public typealias Last = Element
  • Declaration

    Swift

    public static var snoc: Prism<Array<Element>, (Array<Element>, Element)> { get }
  • Provides a polymorphic Iso between Array and ArrayK

    Declaration

    Swift

    static func toPArrayK<B>() -> PIso<Array<Element>, Array<B>, ArrayK<Element>, ArrayK<B>>

    Return Value

    A polymorphic Iso between Array and ArrayK

  • Provides an Iso between Array and ArrayK

    Declaration

    Swift

    static var toArrayK: Iso<Array<Element>, ArrayK<Element>> { get }
  • Provides an Optional to retrieve the first element of an Array

    Declaration

    Swift

    static var head: Optional<Array<Element>, Element> { get }
  • Provides an Optional to retrieve the tail of an Array.

    Declaration

    Swift

    static var tail: Optional<Array<Element>, Array<Element>> { get }
  • Eagerly folds this array to a summary value from left to right.

    Declaration

    Swift

    func foldLeft<B>(_ b: B, _ f: @escaping (B, Element) -> B) -> B

    Parameters

    b

    Initial value for the folding process.

    f

    Folding function.

    Return Value

    Summary value resulting from the folding process.

  • Lazily folds this array to a summary value from right to left.

    Declaration

    Swift

    func foldRight<B>(_ b: Eval<B>, _ f: @escaping (Element, Eval<B>) -> Eval<B>) -> Eval<B>

    Parameters

    b

    Initial value for the folding process.

    f

    Folding function.

    Return Value

    Summary value resulting from the folding process.

  • Transforms the elements of this array to a type with a Monoid instance and folds them using the empty and combine methods of such Monoid instance.

    Declaration

    Swift

    func foldMap<B: Monoid>(_ f: @escaping (Element) -> B) -> B

    Parameters

    f

    Transforming function.

    Return Value

    Summary value resulting from the transformation and folding process.

  • Performs a monadic left fold from this array to the target monad.

    Declaration

    Swift

    func foldM<G: Monad, B>(_ b: B, _ f: @escaping (B, Element) -> Kind<G, B>) -> Kind<G, B>

    Parameters

    b

    Initial value for the fold.

    f

    Folding function.

    Return Value

    Summary value resulting from the folding process in the context of the target monad.

  • Performs a monadic left fold by mapping the values in this array to ones in the target monad context and using the Monoid instance to combine them.

    Declaration

    Swift

    func foldMapM<G: Monad, B: Monoid>(_ f: @escaping (Element) -> Kind<G, B>) -> Kind<G, B>

    Parameters

    f

    Trasnforming function.

    Return Value

    Summary value resulting from the transformation and folding process in the context of the target monad.

  • Combines the elements of this array using their MonoidK instance.

    Declaration

    Swift

    func reduceK<G, A>() -> Kind<G, A> where Element == Kind<G, A>, G : MonoidK

    Parameters

    fga

    Structure to be reduced.

    Return Value

    A value in the context providing the MonoidK instance.

  • Maps each element of this array to an effect, evaluates them from left to right and collects the results.

    Declaration

    Swift

    func traverse<G: Applicative, B>(_ f: @escaping (Element) -> Kind<G, B>) -> Kind<G, [B]>

    Parameters

    f

    A function producing an effect.

    Return Value

    Results collected under the context of the effect provided by the function.

  • Evaluate each effect in this array of values and collects the results.

    Declaration

    Swift

    func sequence<G, A>() -> Kind<G, [A]> where Element == Kind<G, A>, G : Applicative

    Return Value

    Results collected under the context of the effects.

  • A traverse followed by flattening the inner result.

    Declaration

    Swift

    func flatTraverse<G: Applicative, B>(_ f: @escaping (Element) -> Kind<G, [B]>) -> Kind<G, [B]>

    Parameters

    f

    A transforming function yielding nested effects.

    Return Value

    Results collected and flattened under the context of the effects.

  • Folds this array provided that its element type has an instance of Monoid.

    It uses the monoid empty value as initial value and the combination method for the fold.

    Declaration

    Swift

    func combineAll() -> Element

    Return Value

    Summary value resulting from the folding process.

  • Declaration

    Swift

    public func combine(_ other: Array<Element>) -> Array<Element>
  • Declaration

    Swift

    public static func empty() -> Array<Element>
  • Creates an ArrayK from this array.

    Declaration

    Swift

    func k() -> ArrayK<Element>

    Return Value

    An ArrayK wrapping this array.