Free

public final class Free<F, A> : FreeOf<F, A> where F : Functor

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

  • Internal representation of a Free value

    See more

    Declaration

    Swift

    public enum _Free<F, A> where F : Functor
  • Undocumented

    Declaration

    Swift

    public let value: _Free<F, A>
  • Creates a Free value.

    Declaration

    Swift

    public static func free(_ fa: Kind<F, Free<F, A>>) -> Free<F, A>

    Parameters

    fa

    Value to be embedded in Free.

    Return Value

    A Free value.

  • Lifts a value in the context of the Functor into the Free context.

    Declaration

    Swift

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

    Parameters

    fa

    A value in the context of the provided Functor.

    Return Value

    A Free value.

  • Safe downcast.

    Declaration

    Swift

    public static func fix(_ fa: FreeOf<F, A>) -> Free<F, A>

    Parameters

    fa

    Value in the higher-kind form.

    Return Value

    Value cast to Free.

  • Interprets this Free 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 the internal Functor into the desired Monad.

    Return Value

    A value in the interpreted Monad.

  • Folds this free structure using the same Monad.

    Declaration

    Swift

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

    Return Value

    Folded value.