From d4814c76480c76827ef1b4b8d914f91dfc25b1f1 Mon Sep 17 00:00:00 2001 From: Paul Louth Date: Sun, 18 Aug 2024 22:02:41 +0100 Subject: [PATCH] Fix for explicitly implemented operators in IO --- LanguageExt.Core/Effects/IO/IO.cs | 4 ++-- Samples/Streams/RecursionIO.cs | 2 +- Samples/Streams/SumOfSquares.cs | 2 +- Samples/Streams/Zipping.cs | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/LanguageExt.Core/Effects/IO/IO.cs b/LanguageExt.Core/Effects/IO/IO.cs index 027c505df..a66db23ed 100644 --- a/LanguageExt.Core/Effects/IO/IO.cs +++ b/LanguageExt.Core/Effects/IO/IO.cs @@ -354,10 +354,10 @@ public IO SelectMany(Func> bind, Func pr public static IO operator |(IO lhs, IO rhs) => lhs.Catch(rhs).As(); - static IO Fallible, IO, Error, A>.operator |(K lhs, IO rhs) => + public static IO operator |(IO lhs, K rhs) => lhs.Catch(rhs).As(); - static IO Fallible, IO, Error, A>.operator |(IO lhs, K rhs) => + public static IO operator |(K lhs, IO rhs) => lhs.Catch(rhs).As(); public static IO operator |(IO lhs, Pure rhs) => diff --git a/Samples/Streams/RecursionIO.cs b/Samples/Streams/RecursionIO.cs index ad400552a..63a95719a 100644 --- a/Samples/Streams/RecursionIO.cs +++ b/Samples/Streams/RecursionIO.cs @@ -10,7 +10,7 @@ public static class RecursionIO public static IO run => from _ in writeLine("Enter a number to count from") from s in readLine - from n in parseInt(s) | @catch(IO.fail("expected a number!")) + from n in parseInt(s) | IO.fail("expected a number!") from r in recurse(n) >> emptyLine select r; diff --git a/Samples/Streams/SumOfSquares.cs b/Samples/Streams/SumOfSquares.cs index 90078231c..c7195740d 100644 --- a/Samples/Streams/SumOfSquares.cs +++ b/Samples/Streams/SumOfSquares.cs @@ -16,7 +16,7 @@ public static class SumOfSquares public static IO run => from _ in writeLine("Enter a number to find the sum of squares") from s in readLine - from n in parseInt(s) | @catch(IO.fail("expected a number!")) + from n in parseInt(s) | IO.fail("expected a number!") from x in example(n).Iter().As() select unit; diff --git a/Samples/Streams/Zipping.cs b/Samples/Streams/Zipping.cs index 46b6ac530..e4539125f 100644 --- a/Samples/Streams/Zipping.cs +++ b/Samples/Streams/Zipping.cs @@ -15,12 +15,6 @@ from v in evens(n).Zip(odds(n)) from _ in writeLine(v) where false select unit; - - static bool isOdd(int n) => - (n & 1) == 1; - - static bool isEven(int n) => - !isOdd(n); static StreamT evens(int n) => from x in Range(0, n).AsStream() @@ -31,4 +25,10 @@ static StreamT odds(int n) => from x in Range(0, n).AsStream() where isOdd(x) select x; + + static bool isOdd(int n) => + (n & 1) == 1; + + static bool isEven(int n) => + !isOdd(n); }