-
Notifications
You must be signed in to change notification settings - Fork 0
/
Interfaces.cs
47 lines (40 loc) · 1.34 KB
/
Interfaces.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
// Usage Notes:
// - Only generic Value<T> and Maybe<T> should be inherited.
// - Non-generic interfaces are for type-level tests, e.g.:
// if (value is Just) ...
// - Only evaluating a Maybe should return Nothing, and MValue
// should only be used as the evaluation type of a Maybe.
using System;
namespace Settworks.LiftedValues {
/// <summary>
/// An MValue (Maybe Value) is either a Just Value, or Nothing.
/// </summary>
public interface MValue { }
/// <summary>
/// An MValue (Maybe Value) is either a Just Value, or Nothing.
/// </summary>
public interface MValue<T> : MValue {
Func<T> Eval { get; }
}
/// <summary>
/// Nothing represents the absence of value. Attempting to
/// evaluate Nothing causes a runtime exception!
/// </summary>
public interface Nothing { }
/// <summary>
/// A Just Value evaluates to a concrete value of its type.
/// </summary>
public interface Just { }
/// <summary>
/// A Just Value evaluates to a concrete value of its type.
/// </summary>
public interface Value<T> : MValue<T>, Just { }
/// <summary>
/// A Maybe evaluates to either a Just Value or Nothing.
/// </summary>
public interface IMaybe { }
/// <summary>
/// A Maybe evaluates to either a Just Value or Nothing.
/// </summary>
public interface Maybe<T> : Value<MValue<T>>, IMaybe { }
}