-
-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace
Error.New("None")
with Errors.None
And added ToString to Error types
- Loading branch information
Showing
9 changed files
with
70 additions
and
35 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,41 @@ | ||
namespace TestBed; | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using LanguageExt; | ||
using System.Threading.Tasks; | ||
using static LanguageExt.Prelude; | ||
|
||
public static class ApplicativeTest | ||
{ | ||
static Aff<Unit> delay(int milliseconds) => | ||
Aff(async () => | ||
{ | ||
await Task.Delay(milliseconds); | ||
return unit; | ||
}); | ||
|
||
static Aff<int> parse(string str) => | ||
from x in parseInt(str).ToAff() | ||
from _ in delay(1000) | ||
select x; | ||
|
||
static Aff<int> add(string sx, string sy) => | ||
SuccessAff((int x, int y) => x + y) | ||
.Apply(parse(sx)) | ||
.Apply(parse(sy)); | ||
|
||
public static async Task Test() | ||
{ | ||
await Report(add("100", "200")); | ||
await Report(add("zzz", "yyy")); | ||
} | ||
|
||
static async Task Report<A>(Aff<A> ma) | ||
{ | ||
var sw = Stopwatch.StartNew(); | ||
var r = await ma.Run(); | ||
sw.Stop(); | ||
Console.WriteLine($"Result: {r} in {sw.ElapsedMilliseconds}ms"); | ||
} | ||
} |
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