1module Data.OpenUnion.Extra
4 , pattern SingletonUnion
8import Control.Applicative
10import Data.OpenUnion.Internal
12import TypeFun.Data.List hiding (Union)
14class TryLiftUnion xs where
15 tryLiftUnion :: (Alternative m, Typeable x) => x -> m (Union xs)
17instance TryLiftUnion '[] where
18 tryLiftUnion _ = empty
21 (Typeable y, SubList ys (y : ys), TryLiftUnion ys)
22 => TryLiftUnion (y ': ys)
24 tryLiftUnion (x :: x) = case eqT @x @y of
25 Nothing -> reUnion <$> tryLiftUnion @ys x
26 Just Refl -> pure $ liftUnion x
28-- | Like '@>', but enforces a specific type list order.
29-- (Useful for deconstruction-directed type inference.)
30(@@>) :: Typeable a => (a -> b) -> (Union xs -> b) -> Union (a ': xs) -> b
31r @@> l = either l r . restrict'
33 restrict' :: Typeable a => Union (a ': aa) -> Either (Union aa) a
34 restrict' (Union d) = maybe (Left $ Union d) Right $ fromDynamic d
39pattern SingletonUnion :: (Typeable a, Elem a s) => a -> Union s
40pattern SingletonUnion x <-
41 ((\(Union y) -> fromDynamic y) -> Just x)
43 SingletonUnion x = liftUnion x
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list