diff --git a/src/Data/Generics/Schemes.hs b/src/Data/Generics/Schemes.hs
--- a/src/Data/Generics/Schemes.hs
+++ b/src/Data/Generics/Schemes.hs
@@ -27,6 +27,7 @@
         somewhere,
         everything,
         everythingBut,
+        everythingWithContext,
         listify,
         something,
         synthesize,
@@ -111,6 +112,13 @@
                       in if stop
                            then v
                            else foldl k v (gmapQ (everythingBut k f) x)
+
+-- | Summarise all nodes in top-down, left-to-right order, carrying some state
+-- down the tree during the computation, but not left-to-right to siblings.
+everythingWithContext :: s -> (r -> r -> r) -> GenericQ (s -> (r, s)) -> GenericQ r
+everythingWithContext s0 f q x =
+  foldl f r (gmapQ (everythingWithContext s' f q) x)
+    where (r, s') = q x s0
 
 -- | Get a list of all entities that meet a predicate
 listify :: Typeable r => (r -> Bool) -> GenericQ [r]
diff --git a/syb.cabal b/syb.cabal
--- a/syb.cabal
+++ b/syb.cabal
@@ -1,5 +1,5 @@
 name:                 syb
-version:              0.3.6.2
+version:              0.3.7
 license:              BSD3
 license-file:         LICENSE
 author:               Ralf Lammel, Simon Peyton Jones, Jose Pedro Magalhaes
