-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(SourceT): add fromConsumableActionStep that creates a StepT from…
… an action that consumes some data
- Loading branch information
Giulio Foresto
authored and
Giulio Foresto
committed
Feb 18, 2022
1 parent
d35b3e9
commit 2947532
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
synopsis: Add a `StepT` constructor method that consumes a resource | ||
prs: #1533 | ||
issues: #1448 | ||
|
||
description: { | ||
|
||
`fromActionStep` always runs the same action, which makes it impossible with such monadic actions to | ||
"consume" a resource (that is to say to pass the modified resource to the following action), or | ||
"unfold" an input structure. | ||
|
||
`unfoldStep` gives this possibility. | ||
|
||
This allows for example to build a `StepT m` directly from a `Streaming.Prelude.Stream`, by passing | ||
`unfoldStep` the following argument: | ||
|
||
```haskell | ||
import Streaming.Prelude as S | ||
|
||
action :: Stream (Of a) m r -> m (Maybe ( a, Stream (Of a) m r )) | ||
action = S.uncons | ||
``` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters