namespace CanonSharp.Combinator.Abstractions;
///
/// 失败解析结果基类
///
/// 输入流类型
/// 解析结果类型
public interface IFailedResult : IParseResult
{
T IParseResult.Value => throw Exception;
///
/// 当前读取到的状态
///
public IReadState State { get; }
///
/// 解析失败的消息
///
public string Message { get; }
///
/// 解析失败的异常
///
public ParseException Exception => new(Message);
///
/// 转换该失败结果的类型
///
/// 转换之后的结果类型
/// 转换之后的失败解析类型
public IFailedResult Convert();
IParseResult IParseResult.Next(
Func> nextParser,
Func, IParseResult> continuation)
=> continuation(Convert());
IParseResult IParseResult.Map(Func map)
=> Convert();
TResult IParseResult.CaseOf(Func, TResult> successfulHandler,
Func, TResult> failedHandler)
=> failedHandler(this);
}