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:
parent
339585f4ba
commit
93eba20619
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user