Created
November 17, 2020 05:36
-
-
Save altbodhi/4da039522a3bd3cff76f1d68077fbb4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class ValidateResult : Result<bool, string> | |
{ | |
} | |
public abstract class Result<TValue, TError> | |
{ | |
public bool IsOk => this is Ok; | |
public sealed class Ok : Result<TValue, TError> | |
{ | |
public TValue Value { get; } | |
internal Ok(TValue value) => Value = value; | |
} | |
public sealed class Err : Result<TValue, TError> | |
{ | |
public TError Error { get; } | |
internal Err(TError error) => Error = error; | |
} | |
public static Result<TValue, TError> NewErr(TError error) => new Err(error); | |
public static Result<TValue, TError> NewOk(TValue value) => new Ok(value); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match result with | |
| :? ValidateResult.Err as e -> //<= The type 'Err' is not defined. | |
log(e) | |
| _ -> () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed by ->
`
match result with
| :? Result<bool, string>.Err as e -> log ("[ERR]: " + e.Error)
| :? Result<bool, string>.Ok as o -> log ("[OKE]: " + o.Value.ToString())