// using System.Diagnostics.CodeAnalysis; // namespace SJK.Functional; // public interface IOption : IEquatable> // { // /// // /// Applies a function to the contained value if it exists (is not None), otherwise applies a default function. // /// // /// Function to apply if the option contains a value. // /// Function to apply if the option does not contain a value. // /// The result of applying either the onSome or onNone function. // TResult Match(Func onSome, Func onNone); // void Match(Action onSome,Action onNone); // /// // /// Chains operations on the contained value using a function that returns an option. // /// // /// A function that takes the contained value and returns an option. // /// An option resulting from applying the function f to the contained value. // IOption Bind(Func> f); // /// // /// Maps a function over the contained value if it exists (is not None). // /// // /// The function to apply to the contained value. // /// An option containing the result of applying f to the contained value. // IOption Map(Func f); // /// // /// Returns the contained value if it exists (is not None), otherwise returns the provided default value. // /// // /// The default value to return if the option does not contain a value. // /// The contained value or the default value. // T Or(T aDefault); // /// // /// Returns the contained value if it exists (is not None), otherwise calls the provided default function. // /// // /// The default value to return if the option does not contain a value. // /// The contained value or the default value. // T Or(Func aDefault); // /// // /// Checks if the option contains a value (is not None) and outputs it if true. // /// // /// An out parameter that will be assigned the contained value if it exists. // /// true if the option contains a value; false otherwise. // bool HasValue([NotNullWhen(true)]out T? value); // // [Obsolete] // bool HasValue(); // }