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