about summary refs log tree commit diff
path: root/users/grfn/xanthous/src/Xanthous/Util.hs
diff options
context:
space:
mode:
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous/Util.hs')
-rw-r--r--users/grfn/xanthous/src/Xanthous/Util.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/Util.hs b/users/grfn/xanthous/src/Xanthous/Util.hs
index 6678cffe6a..f918340f05 100644
--- a/users/grfn/xanthous/src/Xanthous/Util.hs
+++ b/users/grfn/xanthous/src/Xanthous/Util.hs
@@ -34,7 +34,7 @@ module Xanthous.Util
   , times, times_, endoTimes
 
     -- * State utilities
-  , modifyK, modifyKL
+  , modifyK, modifyKL, useListOf
 
     -- * Type-level programming utils
   , KnownBool(..)
@@ -311,6 +311,14 @@ modifyK k = get >>= k >>= put
 modifyKL :: MonadState s m => LensLike m s s a b -> (a -> m b) -> m ()
 modifyKL l k = get >>= traverseOf l k >>= put
 
+-- | Use a list of all the targets of a 'Fold' in the current state
+--
+-- @@
+-- evalState (useListOf folded) === toList
+-- @@
+useListOf :: MonadState s m => Getting (Endo [a]) s a -> m [a]
+useListOf = gets . toListOf
+
 --------------------------------------------------------------------------------
 
 -- | A newtype wrapper around 'Char' whose 'Enum' and 'Bounded' instances only