map_parse
This commit is contained in:
parent
4352f4aa30
commit
b1a19cc9f5
@ -9,6 +9,15 @@ pub enum ResolutionError<L, P> {
|
||||
Parse(P),
|
||||
}
|
||||
|
||||
impl<L, P> ResolutionError<L, P> {
|
||||
pub fn map_parse<Px>(self, f: impl FnOnce(P) -> Px) -> ResolutionError<L, Px> {
|
||||
match self {
|
||||
ResolutionError::Lookup(l) => ResolutionError::Lookup(l),
|
||||
ResolutionError::Parse(p) => ResolutionError::Parse(f(p)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// See [`ResolutionResult`].
|
||||
pub type ResolutionFailure<'a, Ctx, A> =
|
||||
ResolutionError<<Ctx as Context<'a>>::LookupError, ParseError<'a, Ctx, Fctr<'a, Ctx, A>>>;
|
||||
|
@ -250,10 +250,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> BoundReference<'a, Ctx, A> {
|
||||
let bounds = self.bounds.clone();
|
||||
<Ctx::T as Functor>::fmap(self.reference.resolve(), move |resolution| {
|
||||
let node = resolution
|
||||
.map_err(|err| match err {
|
||||
ResolutionError::Lookup(lookup) => ResolutionError::Lookup(lookup),
|
||||
ResolutionError::Parse(avl) => ResolutionError::Parse(BoundError::Avl(avl)),
|
||||
})?
|
||||
.map_err(|e| e.map_parse(BoundError::Avl))?
|
||||
.as_ref()
|
||||
.clone();
|
||||
let (bl, br) = bounds
|
||||
|
@ -44,10 +44,7 @@ fn map_resolve<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>, B: Mentionable<'a,
|
||||
) -> Resolution<'a, Ctx, B> {
|
||||
Ctx::T::fmap(resolve(), move |resolved| match resolved {
|
||||
Ok(mentionable) => Ok(Rc::new(map_ok(mentionable))),
|
||||
Err(ResolutionError::Parse(parse_error)) => {
|
||||
Err(ResolutionError::Parse(map_err(parse_error)))
|
||||
}
|
||||
Err(ResolutionError::Lookup(lookup_error)) => Err(ResolutionError::Lookup(lookup_error)),
|
||||
Err(e) => Err(e.map_parse(map_err)),
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user