3One-page reference for the Strom API.
12- Emits values of type `a`
13- May fail with errors in `err`
14- Requires context `ctx`
15- Performs effects in Om
21succeed a -- Single element
22fail err -- Immediate failure
24fromArray [1, 2, 3] -- From array
25fromFoldable list -- From any Foldable
26fromOm omEffect -- From Om effect
27fromAff affEffect -- From Aff effect
29range 1 100 -- Integers [1..100)
30iterate (+ 1) 0 -- 0, 1, 2, 3, ...
31repeat "x" -- "x", "x", "x", ...
32repeatOm fetchData -- Repeat effect
34unfold f seed -- Pure unfold
35unfoldOm f seed -- Effectful unfold
41runCollect stream -- Om ctx err (Array a)
42runDrain stream -- Om ctx err Unit
43runFold init f stream -- Om ctx err b
44traverse_ handler stream -- Om ctx err Unit
45subscribe handler stream -- Om ctx err (Om ctx err Unit)
51stream # map f -- Pure map
52stream # mapM f -- Effectful map
53stream # mapParallel 5 f -- Parallel (max 5)
54stream >>= toStream -- Monadic bind (flatten)
55stream # scan f init -- Running fold
56stream # mapAccum f state -- Stateful map
57stream # tap observer -- Pure observe
58stream # tapM observer -- Effectful observe
64stream # take 10 -- First 10
65stream # takeWhile predicate -- While true
66stream # takeUntil predicate -- Until true (inclusive)
68stream # drop 5 -- Skip first 5
69stream # dropWhile predicate -- Skip while true
71stream # filter predicate -- Pure filter
72stream # filterM predicate -- Effectful filter
73stream # collect partialFn -- Filter + map
74stream # collectM partialFn -- Effectful collect
76stream # changes -- Remove consecutive dups
82s1 `append` s2 -- Sequential concat
83s1 <> s2 -- Same (Semigroup)
84concat [s1, s2, s3] -- Multiple streams
86s1 `merge` s2 -- Non-deterministic
87zip s1 s2 -- Tuple pairs
88zipWith f s1 s2 -- Zip with function
89interleave s1 s2 -- Deterministic alternating
91race [s1, s2, s3] -- First to emit
97stream # grouped 10 -- Chunks of 10
98stream # chunked 50 -- Batches of 50
99partition predicate stream -- Split in two
105stream # catchAll handler -- Catch and recover
106s1 `orElse` s2 -- Alternative on fail
107s1 <|> s2 -- Same (Alt)
115 # Strom.mapParallel 10 fetchUser
116 # Strom.filter (_.active)
118 # Strom.traverse_ saveBatch
123Strom.unfoldOm fetchPage token
131 # Strom.filter isValid
133 # Strom.mapM enrichEvent
135 # Strom.traverse_ processBatch
141 (\(Tuple a b) -> Just (Tuple a (Tuple b (a + b))))
157 (\i x -> Tuple (i + 1) { index: i, item: x })
163cancel <- Strom.subscribe handler stream
171- `Functor` - use `map`
172- `Apply` / `Applicative` - use `pure` / `<*>`
173- `Bind` / `Monad` - use `>>=` / do-notation
174- `Semigroup` / `Monoid` - use `<>` / `mempty`
175- `Alt` / `Plus` / `Alternative` - use `<|>` / `empty`
182 # Strom.filter predicate
183 # Strom.map transform
188### Parallel Processing
191stream # Strom.mapM fetchData
194stream # Strom.mapParallel 10 fetchData
198Always use `take` or `takeWhile` before running!
201 # Strom.take 100 -- ← Important!
206Use `runDrain` or `traverse_` instead of `runCollect` for large streams:
208-- ❌ Loads everything into memory
209results <- stream # Strom.runCollect
211-- ✅ Processes incrementally
212stream # Strom.traverse_ processOne
216Group items for efficient bulk operations:
220 # Strom.traverse_ bulkInsert
224Use Om's `ask` in effectful operations:
227 # Strom.mapM (\item -> do
228 ctx <- Om.ask -- Access context
229 processWithContext ctx item
235- **Chunked**: Processes ~1000 elements at a time internally
236- **Lazy**: Values computed only when pulled
237- **Backpressure**: Consumer controls pace
238- **Parallel**: `mapParallel n` runs up to `n` concurrent effects
243- Data processing pipelines
252- Small collections (use Array)
253- UI events (use Bolson Events)
254- Simple transformations (use Array.map)
258| Need | Array | Bolson Event | Strom |
259|------|-------|--------------|-------|
260| Small collection | ✅ | ❌ | ❌ |
261| Large dataset | ❌ | ❌ | ✅ |
262| UI events | ❌ | ✅ | ❌ |
263| API pipeline | ❌ | ❌ | ✅ |
264| Backpressure | ❌ | ❌ | ✅ |
265| Parallel processing | ⚠️ | ❌ | ✅ |
269### 1. Infinite Streams
272Strom.repeat 42 # Strom.runCollect
275Strom.repeat 42 # Strom.take 10 # Strom.runCollect
278### 2. Effects in `map`
280-- ❌ Effects won't run!
281stream # Strom.map (\x -> Om.fromAff $ log x)
284stream # Strom.mapM (\x -> Om.fromAff $ log x)
287### 3. Forgetting to Run
289-- ❌ Just a value, doesn't run!
290let result = stream # Strom.map (+ 1)
292-- ✅ Actually execute it
304import Effect.Aff (Aff, launchAff_)
305import Effect.Class.Console as Console
307import Yoga.Om.Strom as Strom
309type Context = { apiKey :: String }
312main = launchAff_ $ Om.runOm context handlers program
314 context = { apiKey: "secret" }
315 handlers = { exception: \err -> Console.log (show err) }
317program :: Om Context () Unit
319 results <- Strom.range 1 100
320 # Strom.filter (\n -> n `mod` 2 == 0)
321 # Strom.mapParallel 5 (\n -> do
323 -- Use apiKey to fetch data
327 # Strom.tapM (\batch ->
328 Om.fromAff $ Console.log $ "Processing batch of " <> show (Array.length batch)
333 Om.fromAff $ Console.log $ "Final results: " <> show results
338- **README.md** - Comprehensive guide
339- **DEMO.md** - API showcase with examples
340- **COMPARISON.md** - vs ZIO ZStream
341- **SUMMARY.md** - What we built
342- **QUICKREF.md** - This file
346Check the examples in `src/Yoga/Om/Strom/Examples.purs` - 18 comprehensive examples covering all use cases!
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list