Added another helper function to the Utils module
This commit is contained in:
parent
7f8ced3c3a
commit
904b913ebd
|
@ -363,3 +363,12 @@ labelMapWithNodeId f = gmap (\(x,n,l,y) -> (x,n,f n l,y))
|
||||||
|
|
||||||
reverseLookup :: (Ord k, Eq v) => v -> Map.Map k v -> Maybe k
|
reverseLookup :: (Ord k, Eq v) => v -> Map.Map k v -> Maybe k
|
||||||
reverseLookup x m = lookup x $ map revPair $ Map.toList m
|
reverseLookup x m = lookup x $ map revPair $ Map.toList m
|
||||||
|
|
||||||
|
-- Where you have a wrapper for an inner monadic action, but you want to apply
|
||||||
|
-- this to an action that has state wrapped around it:
|
||||||
|
liftWrapStateT :: Monad m => (forall b. m b -> m b) -> StateT s m a -> StateT s m a
|
||||||
|
liftWrapStateT wrap m
|
||||||
|
= do st <- get
|
||||||
|
(x, st') <- lift $ wrap (runStateT m st)
|
||||||
|
put st'
|
||||||
|
return x
|
||||||
|
|
Loading…
Reference in New Issue
Block a user