1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Rename un/unEither to unprefix/unprefixEither.

This commit is contained in:
Rob Rix 2019-08-06 11:55:43 -04:00
parent 339585f4ba
commit 93eba20619
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
2 changed files with 7 additions and 7 deletions

View File

@ -143,7 +143,7 @@ do' bindings = fromMaybe unit (foldr bind Nothing bindings)
where bind (n :<- a) v = maybe (a >>>) ((>>>=) . (:<- a)) n <$> v <|> Just a
unstatements :: (Member Core sig, RightModule sig) => Term sig a -> (Stack (Maybe (Named (Either Int a)) :<- Term sig (Either Int a)), Term sig (Either Int a))
unstatements = un (unstatement . Left) . fmap Right
unstatements = unprefix (unstatement . Left) . fmap Right
data a :<- b = a :<- b
deriving (Eq, Foldable, Functor, Ord, Show, Traversable)

View File

@ -12,8 +12,8 @@ module Data.Scope
, instantiate1
, instantiate
, instantiateEither
, un
, unEither
, unprefix
, unprefixEither
) where
import Control.Applicative (liftA2)
@ -110,11 +110,11 @@ instantiateEither :: Monad f => (Either a b -> f c) -> Scope a f b -> f c
instantiateEither f = unScope >=> incr (f . Left) (>>= f . Right)
un :: (Int -> t -> Maybe (a, t)) -> t -> (Stack a, t)
un from = unEither (matchMaybe . from)
unprefix :: (Int -> t -> Maybe (a, t)) -> t -> (Stack a, t)
unprefix from = unprefixEither (matchMaybe . from)
unEither :: (Int -> t -> Either (a, t) b) -> t -> (Stack a, b)
unEither from = go (0 :: Int) Nil
unprefixEither :: (Int -> t -> Either (a, t) b) -> t -> (Stack a, b)
unprefixEither from = go (0 :: Int) Nil
where go i bs t = case from i t of
Left (b, t) -> go (succ i) (bs :> b) t
Right b -> (bs, b)