1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

📝 unprefix’s purpose.

This commit is contained in:
Rob Rix 2019-08-06 11:59:20 -04:00
parent 7b0a4155da
commit ab07e5a0d6
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -111,6 +111,8 @@ 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 from = unprefixEither (matchMaybe . from)