Skip to content

Commit bfd0c8a

Browse files
committedDec 13, 2021
1
1 parent c9295d1 commit bfd0c8a

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed
 

‎fa/fac/Info.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,14 @@ public static string GenerateCSharp () {
201201
_sb.AppendLine (" public string GetError () => err;");
202202
_sb.AppendLine (" public static Optional<T> FromValue (T _t) => new Optional<T> { t = _t };");
203203
_sb.AppendLine (" public static Optional<T> FromError (string _err) => new Optional<T> { err = _err };");
204-
//_sb.AppendLine (" public static T operator | (Optional<T> t1, T t2) => t1.HasValue () ? t1.GetValue () : t2; // operator ??");
205-
//_sb.AppendLine (" public static Optional<T> operator | (Optional<T> t1, Optional<T> t2) => t1.HasValue () ? t1 : t2; // operator ??");
206-
// FIXME: 支持“?? 异常”用法,但传字符串不对,假如出现 string? 类型的 ?? 就尴尬了
207204
_sb.AppendLine ("}");
205+
//_sb.AppendLine ("public class OptionalVoid {");
206+
//_sb.AppendLine (" public string err = \"\";");
207+
//_sb.AppendLine (" public bool HasValue () => err == \"\";");
208+
//_sb.AppendLine (" public string GetError () => err;");
209+
//_sb.AppendLine (" public static OptionalVoid FromValue () => new OptionalVoid {};");
210+
//_sb.AppendLine (" public static OptionalVoid FromError (string _err) => new OptionalVoid { err = _err };");
211+
//_sb.AppendLine ("}");
208212
_sb.AppendLine ("}");
209213
_sb.AppendLine ();
210214
_sb.AppendLine ();

‎src/fa/Error.fa

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public enum Error {
2+
DivideZero,
3+
IndexOutOfBounds,
4+
}

‎src/fa/Optional

Whitespace-only changes.

0 commit comments

Comments
 (0)
Please sign in to comment.