mirror of
https://github.com/github/semantic.git
synced 2024-11-28 01:47:01 +03:00
📝 unprefix’s parameters.
This commit is contained in:
parent
ab07e5a0d6
commit
e2ec37ebdb
@ -113,7 +113,10 @@ instantiateEither f = unScope >=> incr (f . Left) (>>= f . Right)
|
||||
-- | Unwrap a (possibly-empty) prefix of @a@s wrapping a @t@ using a helper function.
|
||||
--
|
||||
-- This allows us to peel a prefix of syntax, typically binders, off of a term, returning a stack of prefixing values (e.g. variables) and the outermost term rejected by the function.
|
||||
unprefix :: (Int -> t -> Maybe (a, t)) -> t -> (Stack a, t)
|
||||
unprefix
|
||||
:: (Int -> t -> Maybe (a, t)) -- ^ A function taking the 0-based index into the prefix & the current term, and optionally returning a pair of the prefixing value and the inner subterm.
|
||||
-> t -- ^ The initial term.
|
||||
-> (Stack a, t) -- ^ A stack of prefixing values & the final subterm.
|
||||
unprefix from = unprefixEither (matchMaybe . from)
|
||||
|
||||
unprefixEither :: (Int -> t -> Either (a, t) b) -> t -> (Stack a, b)
|
||||
|
Loading…
Reference in New Issue
Block a user