-
-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor QueueT and introduce Mailbox and Inbox for concurrency
This commit removes `QueueT` and its associated files, replacing it with `Mailbox` and `Inbox` for improved concurrency handling. It also introduces new contravariant functor traits (`Cofunctor` and `Divisible`) and updates relevant methods for better abstraction and composition. Additionally, minor naming adjustments (e.g., `Swap` to `SwapMaybe`) were made for clarity and consistency.
- Loading branch information
Showing
45 changed files
with
1,917 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace LanguageExt.Traits; | ||
|
||
public static class CofunctorExtensions | ||
{ | ||
/// <summary> | ||
/// The class of contravariant functors. | ||
/// Whereas one can think of a `Functor` as containing or producing values, a contravariant functor is a functor that | ||
/// can be thought of as consuming values. | ||
/// | ||
/// Contravariant functors are referred to colloquially as Cofunctor, even though the dual of a `Functor` is just | ||
/// a `Functor`. | ||
/// </summary> | ||
public static K<F, B> Contramap<F, A, B>(this K<F, B> fb, Func<A, B> f) | ||
where F : Cofunctor<F> => | ||
F.Contramap(fb, f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace LanguageExt.Traits; | ||
|
||
public static class Cofunctor | ||
{ | ||
/// <summary> | ||
/// The class of contravariant functors. | ||
/// Whereas one can think of a `Functor` as containing or producing values, a contravariant functor is a functor that | ||
/// can be thought of as consuming values. | ||
/// | ||
/// Contravariant functors are referred to colloquially as Cofunctor, even though the dual of a `Functor` is just | ||
/// a `Functor`. | ||
/// </summary> | ||
public static K<F, B> contraMap<F, A, B>(K<F, B> fb, Func<A, B> f) | ||
where F : Cofunctor<F> => | ||
F.Contramap(fb, f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using LanguageExt.Traits; | ||
|
||
namespace LanguageExt; | ||
|
||
public static partial class Prelude | ||
{ | ||
/// <summary> | ||
/// The class of contravariant functors. | ||
/// Whereas one can think of a `Functor` as containing or producing values, a contravariant functor is a functor that | ||
/// can be thought of as consuming values. | ||
/// | ||
/// Contravariant functors are referred to colloquially as Cofunctor, even though the dual of a `Functor` is just | ||
/// a `Functor`. | ||
/// </summary> | ||
public static K<F, B> contraMap<F, A, B>(K<F, B> fb, Func<A, B> f) | ||
where F : Cofunctor<F> => | ||
F.Contramap(fb, f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace LanguageExt.Traits; | ||
|
||
/// <summary> | ||
/// The class of contravariant functors. | ||
/// Whereas one can think of a `Functor` as containing or producing values, a contravariant functor is a functor that | ||
/// can be thought of as consuming values. | ||
/// | ||
/// Contravariant functors are referred to colloquially as Cofunctor, even though the dual of a `Functor` is just | ||
/// a `Functor`. | ||
/// </summary> | ||
/// <typeparam name="F">Self referring type</typeparam> | ||
public interface Cofunctor<F> | ||
{ | ||
public static abstract K<F, B> Contramap<A, B>(K<F, B> fb, Func<A, B> f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using static LanguageExt.Prelude; | ||
|
||
namespace LanguageExt.Traits; | ||
|
||
/// <summary> | ||
/// A `Divisible` contravariant functor is the contravariant analogue of `Applicative`. | ||
/// | ||
/// Continuing the intuition that 'Contravariant' functors (`Cofunctor`) consume input, a 'Divisible' | ||
/// contravariant functor also has the ability to be composed "beside" another contravariant | ||
/// functor. | ||
/// </summary> | ||
/// <typeparam name="F">Self referring type</typeparam> | ||
public static class Decidable | ||
{ | ||
/// <summary> | ||
/// Acts as identity to 'Choose'. | ||
/// </summary> | ||
public static K<F, A> lose<F, A>(Func<A, Void> f) | ||
where F : Decidable<F> => | ||
F.Lose(f); | ||
|
||
/// <summary> | ||
/// Acts as identity to 'Choose'. | ||
/// </summary> | ||
/// <remarks> | ||
/// lost = lose(identity) | ||
/// </remarks> | ||
public static K<F, Void> lost<F>() | ||
where F : Decidable<F> => | ||
lose<F, Void>(identity); | ||
|
||
/// <summary> | ||
/// Fan out the input | ||
/// </summary> | ||
public static K<F, A> route<F, A, B, C>(Func<A, Either<B, C>> f, K<F, B> fb, K<F, C> fc) | ||
where F : Decidable<F> => | ||
F.Route(f, fb, fc); | ||
|
||
/// <summary> | ||
/// Fan out the input | ||
/// </summary> | ||
/// <remarks> | ||
/// route(fb, fc) = route(id, fb, fc) | ||
/// </remarks> | ||
public static K<F, Either<A, B>> route<F, A, B>(K<F, A> fa, K<F, B> fb) | ||
where F : Decidable<F> => | ||
route<F, Either<A, B>, A, B>(identity, fa, fb); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using LanguageExt.Traits; | ||
|
||
namespace LanguageExt; | ||
|
||
/// <summary> | ||
/// A `Divisible` contravariant functor is the contravariant analogue of `Applicative`. | ||
/// | ||
/// Continuing the intuition that 'Contravariant' functors (`Cofunctor`) consume input, a 'Divisible' | ||
/// contravariant functor also has the ability to be composed "beside" another contravariant | ||
/// functor. | ||
/// </summary> | ||
/// <typeparam name="F">Self referring type</typeparam> | ||
public static partial class Prelude | ||
{ | ||
} |
Oops, something went wrong.