Sky.Core.Task
Sky.Core.Task — deferred-effect combinators (Layer 3 Sky source).
Types
type ShouldRetry = RetryAlways | RetryWhen (e -> Bool)
type alias RetryPolicy
Values
andMap : Task e a -> Task e (a -> b) -> Task e b
Applicative application — VALUE first, FUNCTION second, matching
andThen : (a -> Task e b) -> Task e a -> Task e bandThenResult : (a -> Result e b) -> Task e a -> Task e b
Chain a Result-returning step after a Task — flattens what
defaultRetryPolicy : RetryPolicy e
A sensible default: 3 attempts, 500 ms exponential base, no
exponentialBackoff : Int -> Int -> RetryPolicy e
`exponentialBackoff maxAttempts baseMs` — wait
fail : e -> Task e afromResult : Result e a -> Task e a
Lift a Result-returning step into a Task pipeline. Bridges the
lazy : (() -> a) -> Task e a
Defer evaluation of a pure thunk into a Task — handy for
linearBackoff : Int -> Int -> RetryPolicy e
`linearBackoff maxAttempts delayMs` — sleep the same `delayMs`
map : (a -> b) -> Task e a -> Task e bmap2 : (a -> b -> c) -> Task e a -> Task e b -> Task e c
Combine two tasks with a binary function.
map3 : (a -> b -> c -> d) -> Task e a -> Task e b -> Task e c -> Task e dmap4 : (a -> b -> c -> d -> f) -> Task e a -> Task e b -> Task e c -> Task e d -> Task e fmap5 : (a -> b -> c -> d -> f -> g) -> Task e a -> Task e b -> Task e c -> Task e d -> Task e f -> Task e gmapError : (e -> e2) -> Task e a -> Task e2 aonError : (e -> Task e2 a) -> Task e a -> Task e2 a
Recover from a Task error by producing a new Task — the
parallel : List (Task e a) -> Task e (List a)
Run a list of tasks concurrently (goroutine-backed); the first
perform : Task e a -> Result e a
Force a Task synchronously and return its Result. Same shape
retryAlways : ShouldRetry e
The default "always retry" predicate. Equivalent to
retryOn : (e -> Bool) -> RetryPolicy e -> RetryPolicy e
`retryOn predicate policy` — only retry when the predicate
retryWith : RetryPolicy e -> Task e a -> Task e a
`retryWith policy task` — run `task`, retrying on Err per
run : Task e a -> Result e a
Force a Task to a Result. Used at module-top-level discard
sequence : List (Task e a) -> Task e (List a)
Run a list of tasks sequentially; first error short-circuits.
succeed : a -> Task e awithBaseMs : Int -> RetryPolicy e -> RetryPolicy e
Override the base delay (ms). Used as the fixed delay under
withJitter : RetryPolicy e -> RetryPolicy e
`withJitter policy` — randomise each delay across
withKind : Int -> RetryPolicy e -> RetryPolicy e
Override the backoff kind. `0 = linear`, `1 = exponential`.
withMaxAttempts : Int -> RetryPolicy e -> RetryPolicy e
Override the maximum number of attempts.
withRetryOn : (e -> Bool) -> RetryPolicy e -> RetryPolicy e
`withRetryOn predicate policy` — clearer-named alias for