Skip to content

Commit

Permalink
Make StreamT experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
louthy committed Dec 18, 2024
1 parent 1c4074b commit 84c66e7
Show file tree
Hide file tree
Showing 42 changed files with 132 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using System;
using System.Collections.Generic;
using LanguageExt.Traits;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/DataTypes/Range/Range.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using LanguageExt.Traits;
#pragma warning disable LX_StreamT

using LanguageExt.Traits;
using System;
using System.Collections.Generic;
using System.Collections;
Expand Down
27 changes: 27 additions & 0 deletions LanguageExt.Core/Effects/IO/Free/IOMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
using System;
using LanguageExt.DSL;
using LanguageExt.Traits;
namespace LanguageExt;
record IOMap<A, B>(IO<A> Value, Func<A, B> F) : IO<B>
{
public override IO<C> Map<C>(Func<B, C> f) =>
new IOMap<A, C>(Value, x => f(F(x)));
public override IO<C> Bind<C>(Func<B, K<IO, C>> f) =>
new IOMap<A, K<IO, C>>(Value, x => f(F(x)).As()).Bind(x => x);
public override IO<C> ApplyBack<C>(K<IO, Func<B, C>> mf) =>
mf switch
{
IOPure<Func<B, C>> (var f) => new IOMap<A, C>(Value, x => f(F(x))),
IOPureAsync<Func<B, C>> (var tf) => new IOMap<A, IO<C>>(Value, x => IO.pureAsync(tf.Map(f => f(F(x))))).Bind(x => x),
IOFail<Func<B, C>> (var v) => new IOFail<C>(v),
IOBind<Func<B, C>> (var f) => new IOBind<C>(f.Map(x => x.Apply(this).As())),
IOCatch<Func<B, C>> mc => Value.Bind(a => IO.pure(F(a)).ApplyBack(mc)),
_ => throw new InvalidOperationException()
};
}
*/
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/IO/IO.Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
Expand Down
9 changes: 9 additions & 0 deletions LanguageExt.Core/Effects/IO/IO.Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ public partial class IO
public static IO<A> pure<A>(A value) =>
IO<A>.Pure(value);

/// <summary>
/// Lift a pure value into an IO computation
/// </summary>
/// <param name="value">value</param>
/// <typeparam name="A">Bound value type</typeparam>
/// <returns>IO in a success state. Always yields the lifted value.</returns>
internal static IO<A> pureAsync<A>(Task<A> value) =>
new IOPureAsync<A>(value);

/// <summary>
/// Put the IO into a failure state
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/IO/IO.Prelude.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Effects/Prelude.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using LanguageExt.Traits;

namespace LanguageExt;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/Source/Source.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using System;
using System.Collections.Concurrent;
using System.Threading;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/Source/Sub.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using LanguageExt.Traits;

namespace LanguageExt;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/StreamT/StreamT.Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/StreamT/StreamT.Module.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt.Traits;
using System.Collections.Generic;

Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/StreamT/StreamT.Monad.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using System;
using System.Collections.Generic;
using LanguageExt.Traits;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/StreamT/StreamT.Prelude.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt.Traits;

namespace LanguageExt;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Effects/StreamT/StreamT.Prelude.mapapply.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using LanguageExt.Traits;

namespace LanguageExt;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Effects/StreamT/StreamT.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using static LanguageExt.Prelude;
Expand All @@ -11,6 +12,7 @@ namespace LanguageExt;
/// <summary>
/// Lazy sequence monad transformer
/// </summary>
[Experimental("LX_StreamT")]
public record StreamT<M, A>(Func<K<M, MList<A>>> runListT) :
K<StreamT<M>, A>,
Monoid<StreamT<M, A>>
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Immutable Collections/Arr/Arr.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Immutable Collections/Iterable/Iterable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Immutable Collections/List/Lst.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Immutable Collections/Seq/Seq.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma warning disable CS0693 // Type parameter has the same name as the type parameter from outer type
#pragma warning disable LX_StreamT

#pragma warning disable CS0693 // Type parameter has the same name as the type parameter from outer type

using System;
using System.Collections;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Immutable Collections/Set/Set.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Collections.Generic;
using System.Collections;
using static LanguageExt.Prelude;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Monads/Alternative Monads/Either/Either.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Collections;
using System.Collections.Generic;
using static LanguageExt.Prelude;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using LanguageExt.Traits;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Core/Monads/Alternative Monads/Fin/Fin.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using System;
using LanguageExt.Common;
using LanguageExt.Traits;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Monads/Alternative Monads/FinT/FinT.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Diagnostics.Contracts;
using LanguageExt.Common;
using LanguageExt.Traits;
Expand Down
4 changes: 3 additions & 1 deletion LanguageExt.Core/Monads/Alternative Monads/Option/Option.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Linq;
using System.Collections.Generic;
using static LanguageExt.Prelude;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Diagnostics.Contracts;
using System.IO;
using System.Runtime.CompilerServices;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Collections.Generic;
using static LanguageExt.Prelude;
using System.Diagnostics.Contracts;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
#pragma warning disable LX_StreamT

using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using LanguageExt.Common;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Tests/TraitTests/ApplicativeLawTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using Xunit;
namespace LanguageExt.Tests.TraitTests;

Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Tests/TraitTests/FunctorLawTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using Xunit;
using LanguageExt.Common;
namespace LanguageExt.Tests.TraitTests;
Expand Down
2 changes: 2 additions & 0 deletions LanguageExt.Tests/TraitTests/MonadLawsTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using Xunit;

namespace LanguageExt.Tests.TraitTests;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/CountForever.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using static LanguageExt.Prelude;
using static Streams.Console;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/CountForeverAsync.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using static LanguageExt.Prelude;
using static Streams.Console;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/Folding.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using static Streams.Console;
using static LanguageExt.Prelude;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/Grouping.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using static LanguageExt.Prelude;
using static Streams.Console;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/HeadsAndTails.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using static LanguageExt.Prelude;
using static Streams.Console;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/Merging.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using static Streams.Console;
using static LanguageExt.Prelude;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/OptionalItems.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using static LanguageExt.Prelude;

Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/SourceStream.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using LanguageExt.Common;
using static Streams.Console;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/SumOfSquares.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using LanguageExt.Common;
using LanguageExt.Traits;
Expand Down
2 changes: 2 additions & 0 deletions Samples/Streams/Zipping.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable LX_StreamT

using LanguageExt;
using static Streams.Console;
using static LanguageExt.Prelude;
Expand Down

0 comments on commit 84c66e7

Please sign in to comment.