DictionaryK

public class DictionaryK<K, A> : DictionaryKOf<K, A> where K : Hashable

DictionaryK is a Higher Kinded Type wrapper over Swift dictionaries.

  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ fa: DictionaryKOf<K, A>) -> DictionaryK<K, A>

    Parameters

    fa

    Value in the higher-kind form.

    Return Value

    Value cast to DictionaryK.

  • Initializes a DictionaryK.

    Declaration

    Swift

    public init(_ dictionary: [K : A])

    Parameters

    dictionary

    A Swift dictionary.

  • Obtains the wrapped dictionary.

    Declaration

    Swift

    public func asDictionary() -> [K : A]

    Return Value

    A Swift dictionary wrapped in this value.

  • Creates a new value transforming the type using the provided function, preserving the structure of the dictionary.

    Declaration

    Swift

    public func map<B>(_ f: (A) -> B) -> DictionaryK<K, B>

    Parameters

    f

    Transforming function.

    Return Value

    The result of transforming the value type using the provided function, maintaining the structure of the dictionary.

  • Zips this dictionary with another one and combines their values with the provided function.

    Declaration

    Swift

    public func map2<B, Z>(_ fb: DictionaryK<K, B>, _ f: (A, B) -> Z) -> DictionaryK<K, Z>

    Parameters

    fb

    A dictionary.

    f

    Combining function.

    Return Value

    Result of zipping the values of both dictionaries and combining their values.

  • Zips this dictionary with a potentially lazy one and combines their values with the provided function.

    Declaration

    Swift

    public func map2Eval<B, Z>(_ fb: Eval<DictionaryK<K, B>>, _ f: @escaping (A, B) -> Z) -> Eval<DictionaryK<K, Z>>

    Parameters

    fb

    A potentially lazy dictionary.

    f

    Combining function.

    Return Value

    Result of zipping the values of both dictionaries and combining their values.

  • Sequential application.

    Declaration

    Swift

    public func ap<AA, B>(_ fa: DictionaryK<K, AA>) -> DictionaryK<K, B> where A == (AA) -> B

    Parameters

    fa

    A dictionary.

    Return Value

    A dictionary with the result of applying the functions in this dictionary to the values in the argument.

  • Applies the provided function to all values in this dictionary, flattening the final result.

    Declaration

    Swift

    public func flatMap<B>(_ f: (A) -> DictionaryK<K, B>) -> DictionaryK<K, B>

    Parameters

    f

    Transforming function.

    Return Value

    A dictionary with the outputs of applying the function to all values in this dictionary.

  • Eagerly reduces the values of this dictionary to a summary value.

    Declaration

    Swift

    public func foldLeft<B>(_ b: B, _ f: (B, A) -> B) -> B

    Parameters

    b

    Initial value for the folding process.

    f

    Folding function.

    Return Value

    A summary value resulting from the folding process.

  • Lazily reduces the values of this dictionary to a summary value.

    Declaration

    Swift

    public func foldRight<B>(_ b: Eval<B>, _ f: (A, Eval<B>) -> Eval<B>) -> Eval<B>

    Parameters

    b

    Initial value for the folding process.

    f

    Folding function.

    Return Value

    A summary value resulting from the folding process.

  • Eagerly reduces the values of this dictionary to a summary dictionary.

    Declaration

    Swift

    public func foldLeft<B>(_ b: DictionaryK<K, B>, _ f: (DictionaryK<K, B>, (K, A)) -> DictionaryK<K, B>) -> DictionaryK<K, B>

    Parameters

    b

    Initial value for the folding process.

    f

    Folding function.

    Return Value

    A summary dictionary resulting from the folding process.