Program

public final class Program<F, A> : ProgramOf<F, A>

Program is a type that, given any type constructor, is able to provide a Monad instance, that can be interpreted into a more restrictive one.

As opposed to Free, Program does not require F to be a functor, which means that evaluation of map calls are deferred and left for the later interpretation in another monad.

  • Internal representation of Program

    Declaration

    Swift

    public let asFree: Free<CoyonedaPartial<F>, A>
  • Initializes a Program instance from the corresponding Free<CoyonedaPartial<F>>.

    Declaration

    Swift

    public init(asFree: Free<CoyonedaPartial<F>, A>)
  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ fa: ProgramOf<F, A>) -> Program<F, A>

    Parameters

    fa

    Value in the higher-kind form.

    Return Value

    Value cast to Program.

  • Lifts a value in the context of F into the Program context.

    Declaration

    Swift

    public static func liftF(_ fa: Kind<F, A>) -> Program<F, A>

    Parameters

    fa

    A value in the context of F.

    Return Value

    A Program value.

  • Interprets this Program value into the provided Monad.

    Declaration

    Swift

    public func foldMapK<M>(_ f: FunctionK<F, M>) -> Kind<M, A> where M : Monad

    Parameters

    f

    A natural transformation from F into the desired Monad.

    Return Value

    A value in the interpreted Monad.

  • Folds this program structure using the same Monad.

    Declaration

    Swift

    func run() -> Kind<F, A>

    Return Value

    Folded value.