Module

Yoga.Om.Strom.Examples

Package
purescript-yoga-om-strom
Repository
rowtype-yoga/purescript-yoga-om-strom

#example1 Source

example1 :: Om (Record ()) () (Array Int)

Simple range and mapping

#LoggerContext Source

type LoggerContext = { logger :: String -> Aff Unit }

#example2 Source

example2 :: Om LoggerContext () Unit

Stream with effectful mapping and tapping

#fetchUser Source

fetchUser :: Int -> Om (Record ()) () String

Process items in parallel (simulating API calls)

#example3 Source

#example4 Source

example4 :: Om (Record ()) () (Array Int)

Running total using scan

#example4b Source

example4b :: Om (Record ()) () (Array String)

Stateful map with accumulator

#example5 Source

example5 :: Om (Record ()) () (Array (Tuple Int String))

Zip two streams

#example5b Source

example5b :: Om (Record ()) () (Array Int)

Interleave two streams deterministically

#example5c Source

example5c :: Om (Record ()) () (Array Int)

Merge streams (non-deterministic, race-based)

#example6 Source

example6 :: Om (Record ()) () (Array Int)

Take from an infinite stream

#example6b Source

example6b :: Om (Record ()) () (Array Int)

Repeat with condition

#example7 Source

example7 :: Om (Record ()) () (Array (Array Int))

Group elements into chunks

#example7b Source

example7b :: Om LoggerContext () Unit

Process in batches

#example8 Source

example8 :: Om (Record ()) () (Array Int)

Remove consecutive duplicates

#User Source

type User = { active :: Boolean, id :: Int, name :: String }

#example9 Source

example9 :: Om LoggerContext () Unit

Fetch users from API, process active ones, and save

#fibonacciStream Source

fibonacciStream :: forall ctx err. Strom ctx err Int

Generate Fibonacci sequence

#example10 Source

example10 :: Om (Record ()) () (Array Int)

#Page Source

type Page = { items :: Array String, nextToken :: Maybe String }

Unfold with effects (e.g., paginated API)

#fetchPage Source

fetchPage :: String -> Om (Record ()) () Page

#example10b Source

#example11 Source

example11 :: Om (Record ()) () (Array Int)

Race multiple data sources

#example12 Source

example12 :: Om (Record ()) () { evens :: Array Int, odds :: Array Int }

Split stream into two based on predicate

#parseNumbers Source

parseNumbers :: String -> Maybe Int

Extract and transform in one pass

#example13 Source

example13 :: Om (Record ()) () (Array Int)

#example13b Source

example13b :: Om (Record ()) () (Array Int)

Collect with Om effect

#example14 Source

example14 :: Om (Record ()) () (Array Int)

Skip elements

#example14b Source

example14b :: Om (Record ()) () (Array Int)

Drop while condition holds

#example15 Source

example15 :: Om LoggerContext () Unit

Subscribe to a stream and cancel later

#Department Source

type Department = { employees :: Array String, name :: String }

Flatten nested data structures

#example16 Source

#example17 Source

example17 :: Om (Record ()) (networkError :: String) (Array Int)

Catch errors and provide fallback

#example17b Source

example17b :: Om (Record ()) (networkError :: String) (Array Int)

Provide alternative stream on failure

#Event Source

type Event = { action :: String, timestamp :: Int, userId :: String }

#eventProcessingPipeline Source

eventProcessingPipeline :: Om LoggerContext () Unit

Complete event processing pipeline

#runExample Source

runExample :: forall a. Show a => Om (Record ()) () a -> Aff Unit

#runExampleWithLogger Source

runExampleWithLogger :: forall a. Show a => Om LoggerContext () a -> Aff Unit