From 3aec4cd83e36ae889d011f115793dd29a2240172 Mon Sep 17 00:00:00 2001 From: Tom Ellis Date: Wed, 16 Oct 2024 08:27:58 +0100 Subject: [PATCH] insertManySecond example --- bluefin-internal/src/Bluefin/Internal/Examples.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bluefin-internal/src/Bluefin/Internal/Examples.hs b/bluefin-internal/src/Bluefin/Internal/Examples.hs index 875bb31..1c1d0ee 100644 --- a/bluefin-internal/src/Bluefin/Internal/Examples.hs +++ b/bluefin-internal/src/Bluefin/Internal/Examples.hs @@ -77,6 +77,17 @@ withYieldToListExample = runPureEff $ withYieldToList $ \y -> do yield y 100 pure length +-- This shows we can use forEach at any level of nesting with +-- insertManySecond +doubleNestedForEach :: + (forall e. Stream () e -> Eff (e :& es) ()) -> + Eff es () +doubleNestedForEach f = + withState () $ \_ -> do + withState () $ \_ -> do + forEach (insertManySecond . f) (\_ -> pure ()) + pure (\_ _ -> ()) + forEachExample :: ([Int], ()) forEachExample = runPureEff $ yieldToList $ \y -> do forEach (inFoldable [0 .. 4]) $ \i -> do