Skip to content

Commit

Permalink
Remand to FlatMap()
Browse files Browse the repository at this point in the history
  • Loading branch information
aahoogendoorn committed Dec 29, 2015
1 parent ba1c7ee commit 0d7c02e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Monads/Monads.Test/TryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void TestMap()
public void TestFlatMap()
{
var result = Try<Employee>.Invoke(() => repo.Create("Kees"))
.MapFlat(e => e.IsNameKees())
.FlatMap(e => e.IsNameKees())
.Get();

Assert.IsTrue(result);
Expand All @@ -41,7 +41,7 @@ public void TestFailureOnMap()
public void TestRecoverOnFlatMap()
{
var result = Try<Employee>.Invoke(() => repo.Create("Kees"))
.MapFlat(e => e.WillThrowException())
.FlatMap(e => e.WillThrowException())
.Recover(ex => repo.Create("Jaap"));

Assert.IsTrue(result.IsSuccess);
Expand All @@ -51,7 +51,7 @@ public void TestRecoverOnFlatMap()
public void TestSpecificRecoverOnFlatMap()
{
var result = Try<Employee>.Invoke(() => repo.Create("Kees"))
.MapFlat(e => e.WillThrowTryException())
.FlatMap(e => e.WillThrowTryException())
.Recover<TryException>(e => repo.Create("Jaap"))
.Recover(ex => repo.Create("Jan"));

Expand All @@ -63,7 +63,7 @@ public void TestSpecificRecoverOnFlatMap()
public void TestRecoverSkippingSpecificRecoverOnFlatMap()
{
var result = Try<Employee>.Invoke(() => repo.Create("Kees"))
.MapFlat(e => e.WillThrowException())
.FlatMap(e => e.WillThrowException())
.Recover<TryException>(e => repo.Create("Jaap"))
.Recover(ex => repo.Create("Jan"));

Expand Down
2 changes: 1 addition & 1 deletion Monads/Monads/Failure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override Try<U> Map<U>(Func<T, U> mapper)
return new Failure<U>(exception);
}

public override Try<U> MapFlat<U>(Func<T, Try<U>> mapper)
public override Try<U> FlatMap<U>(Func<T, Try<U>> mapper)
{
return new Failure<U>(exception);
}
Expand Down
2 changes: 1 addition & 1 deletion Monads/Monads/Success.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override Try<U> Map<U>(Func<T, U> mapper)
return Try<U>.Invoke(() => mapper.Invoke(value));
}

public override Try<U> MapFlat<U>(Func<T, Try<U>> mapper)
public override Try<U> FlatMap<U>(Func<T, Try<U>> mapper)
{
return Try<U>.Invoke(() => mapper.Invoke(value).Get());
}
Expand Down
2 changes: 1 addition & 1 deletion Monads/Monads/Try.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static Try<U> Invoke<U>(Func<U> mapper)

public abstract Try<U> Map<U>(Func<T, U> mapper);

public abstract Try<U> MapFlat<U>(Func<T, Try<U>> mapper);
public abstract Try<U> FlatMap<U>(Func<T, Try<U>> mapper);

public abstract Try<T> Recover(Func<Exception, T> recover);

Expand Down

0 comments on commit 0d7c02e

Please sign in to comment.