Skip to content

Commit

Permalink
insertManySecond example
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjaguarpaw committed Oct 16, 2024
1 parent 2c35489 commit 3aec4cd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bluefin-internal/src/Bluefin/Internal/Examples.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3aec4cd

Please sign in to comment.