Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
fawdlstty committed Dec 13, 2021
1 parent c9295d1 commit bfd0c8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fa/fac/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,14 @@ public static string GenerateCSharp () {
_sb.AppendLine (" public string GetError () => err;");
_sb.AppendLine (" public static Optional<T> FromValue (T _t) => new Optional<T> { t = _t };");
_sb.AppendLine (" public static Optional<T> FromError (string _err) => new Optional<T> { err = _err };");
//_sb.AppendLine (" public static T operator | (Optional<T> t1, T t2) => t1.HasValue () ? t1.GetValue () : t2; // operator ??");
//_sb.AppendLine (" public static Optional<T> operator | (Optional<T> t1, Optional<T> t2) => t1.HasValue () ? t1 : t2; // operator ??");
// FIXME: 支持“?? 异常”用法,但传字符串不对,假如出现 string? 类型的 ?? 就尴尬了
_sb.AppendLine ("}");
//_sb.AppendLine ("public class OptionalVoid {");
//_sb.AppendLine (" public string err = \"\";");
//_sb.AppendLine (" public bool HasValue () => err == \"\";");
//_sb.AppendLine (" public string GetError () => err;");
//_sb.AppendLine (" public static OptionalVoid FromValue () => new OptionalVoid {};");
//_sb.AppendLine (" public static OptionalVoid FromError (string _err) => new OptionalVoid { err = _err };");
//_sb.AppendLine ("}");
_sb.AppendLine ("}");
_sb.AppendLine ();
_sb.AppendLine ();
Expand Down
4 changes: 4 additions & 0 deletions src/fa/Error.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public enum Error {
DivideZero,
IndexOutOfBounds,
}
Empty file added src/fa/Optional
Empty file.

0 comments on commit bfd0c8a

Please sign in to comment.