ArrayK

public final class ArrayK<A> : ArrayKOf<A>

ArrayK is a Higher Kinded Type wrapper over Swift arrays.

  • Concatenates two arrays

    Declaration

    Swift

    public static func + (lhs: ArrayK<A>, rhs: ArrayK<A>) -> ArrayK<A>

    Parameters

    lhs

    Left hand side of the concatenation.

    rhs

    Right hand side of the concatenation.

    Return Value

    An array that contains the elements of the two arrays in the order they appear in the original ones.

  • Prepends an element to an array.

    Declaration

    Swift

    public static func + (lhs: A, rhs: ArrayK<A>) -> ArrayK<A>

    Parameters

    lhs

    Element to prepend.

    rhs

    Array.

    Return Value

    An array containing the prepended element at the head and the other array as the tail.

  • Appends an element to an array.

    Declaration

    Swift

    public static func + (lhs: ArrayK<A>, rhs: A) -> ArrayK<A>

    Parameters

    lhs

    Array.

    rhs

    Element to append.

    Return Value

    An array containing all elements of the first array and the appended element as the last element.

  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ fa: ArrayKOf<A>) -> ArrayK<A>

    Parameters

    fa

    Value in the higher-kind form.

    Return Value

    Value cast to ArrayK.

  • Initializes an ArrayK.

    Declaration

    Swift

    public init(_ array: [A])

    Parameters

    array

    A Swift array of values.

  • Initializes an ArrayK.

    Declaration

    Swift

    public init(_ values: A...)

    Parameters

    values

    A variable number of values.

  • Initialises an ArrayK with the elements of a Foldable structure.

    Declaration

    Swift

    public init<F>(_ fa: Kind<F, A>) where F : Foldable

    Parameters

    fa

    The foldable structure whose elements will be added to this array.

  • Obtains the wrapped array.

    Declaration

    Swift

    public var asArray: [A] { get }
  • Obtains the first element of this array, or Option.none if it is empty.

    Declaration

    Swift

    public func firstOrNone() -> Option<A>

    Return Value

    An optional value containing the first element of the array, if present.

  • Obtains the last element of this array, or Option.none if it is empty.

    Declaration

    Swift

    public func lastOrNone() -> Option<A>

    Return Value

    An optional value containing the first element of the array, if present.

  • Obtains the element in the position passed as an argument, if any.

    Declaration

    Swift

    public func getOrNone(_ i: Int) -> Option<A>

    Parameters

    i

    Index of the element to obtain.

    Return Value

    An optional value containing the element of the array at the specified index, if present.

  • Obtains the element in the position passed as an argument, if any.

    Declaration

    Swift

    public subscript(index: Int) -> Option<A> { get }

    Parameters

    index

    Index of the element to obtain.

  • Drops the first element of this array.

    Declaration

    Swift

    public func dropFirst() -> ArrayK<A>

    Return Value

    A new array that contains all elements but the first.

  • Drops the last element of this array.

    Declaration

    Swift

    public func dropLast() -> ArrayK<A>

    Return Value

    A new array that contains all elements but the last.

  • Provides an Iso to go from/to this type to its Kind version.

    Declaration

    Swift

    static var fixIso: Iso<ArrayK<A>, ArrayKOf<A>> { get }
  • Provides a Fold based on the Foldable instance of this type.

    Declaration

    Swift

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

    Declaration

    Swift

    static var traversal: Traversal<ArrayK<A>, A> { get }
  • Undocumented

    Declaration

    Swift

    public typealias EachFoci = A
  • Declaration

    Swift

    public static var each: Traversal<ArrayK<A>, A> { get }
  • Undocumented

    Declaration

    Swift

    public typealias IndexType = Int
  • Undocumented

    Declaration

    Swift

    public typealias IndexFoci = A
  • Declaration

    Swift

    public static func index(_ i: Int) -> AffineTraversal<ArrayK<A>, A>
  • Undocumented

    Declaration

    Swift

    public typealias FilterIndexType = Int
  • Undocumented

    Declaration

    Swift

    public typealias FilterIndexFoci = A
  • Declaration

    Swift

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

    Declaration

    Swift

    public typealias First = A
  • Declaration

    Swift

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

    Declaration

    Swift

    public typealias Last = A
  • Declaration

    Swift

    public static var snoc: Prism<ArrayK<A>, (ArrayK<A>, A)> { get }
  • Provides a polymorphic Iso between ArrayK and Option of NonEmptyArray.

    Declaration

    Swift

    static func toPOptionNEA<B>() -> PIso<ArrayK<A>, ArrayK<B>, Option<NonEmptyArray<A>>, Option<NonEmptyArray<B>>>

    Return Value

    A polymorphic Iso between ArrayK and Option of NonEmptyArray.

  • Provides an Iso between ArrayK and Option of NonEmptyArray

    Declaration

    Swift

    static var toOptionNEA: Iso<ArrayK<A>, Option<NonEmptyArray<A>>> { get }
  • Provides an AffineTraversal to retrieve the first element of an ArrayK

    Declaration

    Swift

    static var head: AffineTraversal<ArrayK<A>, A> { get }
  • Provides an AffineTraversal to retrieve the tail of an ArrayK

    Declaration

    Swift

    static var tail: AffineTraversal<ArrayK<A>, ArrayK<A>> { get }
  • Declaration

    Swift

    public var description: String { get }
  • Declaration

    Swift

    public func combine(_ other: ArrayK<A>) -> ArrayK
  • Declaration

    Swift

    public static func empty() -> ArrayK
  • A lifted version of any. Retains the short-circuiting behavior.

    Declaration

    Swift

    func anyS<F: Selective>(_ p: @escaping (A) -> Kind<F, Bool>) -> Kind<F, Bool>

    Parameters

    p

    A lifted predicate to find any element of this array that matches it.

    Return Value

    A boolean computation describing if any element of the array matches the predicate.

  • A lifted version of all. Retains the short-circuiting behavior.

    Declaration

    Swift

    func allS<F: Selective>(_ p: @escaping (A) -> Kind<F, Bool>) -> Kind<F, Bool>

    Parameters

    p

    A lifted predicate to check all elements of this array match it.

    Return Value

    A boolean computation describing if all elements of the array match the predicate.