-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFailure.cs
51 lines (42 loc) · 988 Bytes
/
Failure.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
namespace FPUtils
{
public sealed class Failure<T> : Try<T>
{
internal Failure() : base(default)
{
}
public override Try<T> Filter(Func<T, bool> predicate)
{
return this;
}
public override Try<V> FlatMap<V>(Func<T, Try<V>> transformation)
{
return new Failure<V>();
}
public override T GetOrElse(T other)
{
return other;
}
public override void IfSuccess(Action<T> action)
{
return;
}
public override bool IsFailure()
{
return true;
}
public override bool IsSuccess()
{
return false;
}
public override Try<V> Map<V>(Func<T, V> transformation)
{
return new Failure<V>();
}
public override Option<T> ToOption()
{
return new None<T>();
}
}
}