-
Safe downcast.
Declaration
Swift
public static func fix(_ fa: OptionTOf<F, A>) -> OptionT<F, A>Parameters
faValue in the higher-kind form.
Return Value
Value cast to OptionT.
-
Applies the provided closures based on the content of the nested
Optionvalue.Declaration
Swift
public func fold<B>(_ ifEmpty: @escaping () -> B, _ f: @escaping (A) -> B) -> Kind<F, B>Parameters
ifEmptyClosure to apply if the contained value in the nested
Optionis absent.fClosure to apply if the contained value in the nested
Optionis present.Return Value
Result of applying the corresponding closure to the nested
Option, wrapped in the effect. -
Applies the provided closures based on the content of the nested
Optionvalue.Declaration
Swift
public func cata<B>(_ ifEmpty: @autoclosure @escaping () -> B, _ f: @escaping (A) -> B) -> Kind<F, B>Parameters
ifEmptyClosure to apply if the contained value in the nested
Optionis absent.fClosure to apply if the contained value in the nested
Optionis present.Return Value
Result of applying the corresponding closure to the nested
Option, wrapped in the effect. -
Obtains the value of the nested
Optionor a default value, wrapped in the effect.Declaration
Swift
public func getOrElse(_ defaultValue: A) -> Kind<F, A>Parameters
defaultValueValue for the absent case in the nested
Option.Return Value
Value contained in the nested
Optionif present, or the default value otherwise, wrapped in the effect. -
Convert this
OptionTto anEitherT.Declaration
Swift
public func toLeft<R>(_ defaultRight: @escaping () -> R) -> EitherT<F, A, R>Parameters
defaultRightFunction returning a default value to use as right if the
OptionTis none.Return Value
An
EitherTcontaining the value as left or as right with the default value if theOptionTcontains a none. -
Convenience
toLeftallowing a constant as the parameter.Declaration
Swift
public func toLeft<R>(_ defaultRight: @autoclosure @escaping () -> R) -> EitherT<F, A, R>Parameters
defaultRightFunction returning a default value to use as right if the
OptionTis none.Return Value
An
EitherTcontaining the value as left or as right with the default value if theOptionTcontains a none. -
Convert this
OptionTto anEitherT.Declaration
Swift
public func toRight<L>(_ defaultLeft: @escaping () -> L) -> EitherT<F, L, A>Parameters
defaultLeftFunction returning a default value to use as left if the
OptionTis none.Return Value
Returns: An
EitherTcontaining the value as right or as left with the default value if theOptionTcontains a none. -
Convenience
toRightallowing a constant as the parameter.Declaration
Swift
public func toRight<L>(_ defaultLeft: @autoclosure @escaping () -> L) -> EitherT<F, L, A>Parameters
defaultLeftFunction returning a default value to use as left if the
OptionTis none.Return Value
Returns: An
EitherTcontaining the value as right or as left with the default value if theOptionTcontains a none.
-
Obtains this value if the value contained in the nested option is present, or a default value if it is absent.
Declaration
Swift
public func orElse(_ defaultValue: OptionT<F, A>) -> OptionT<F, A>Parameters
defaultValueDefault value to return when the nested option is empty.
Return Value
This
OptionTif the nested option is present, or the default value otherwise. -
Obtains this value if the value contained in the nested option is present, or a default value if it is absent.
Parameters
defaultValueDefault value to return when the nested option is empty.
Return Value
This
OptionTif the nested option is present, or the default value otherwise. -
Flatmaps a function that produces an effect and lifts if back to
OptionT.Declaration
Swift
public func semiflatMap<B>(_ f: @escaping (A) -> Kind<F, B>) -> OptionT<F, B>Parameters
fA function producing an effect.
Return Value
Result of flatmapping and lifting the function to this value.
-
Obtains the value contained in the nested
Optionif present, or a default value otherwise.Parameters
defaultValueDefault value to return when the nested option is empty.
Return Value
The value in the nested option wrapped in the effect if it is present, or the default value otherwise.
Install in Dash
OptionT Class Reference