← all modules

Sky.Core.Task

Sky.Core.Task
  Sky.Core.Task — deferred-effect combinators (Layer 3 Sky source).

Types
  type Step state a = Loop state | Done a
  type ShouldRetry e = RetryAlways | RetryWhen (e -> Bool)
  type alias RetryPolicy e = { maxAttempts : Int , baseMs : Int , jitter : Bool , kind : Int , shouldRetry : ShouldRetry e }

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 b
  andThenResult : (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 a
  forever : Task e a -> Task e b
      `forever task` — run `task` again and again until it fails, then fail
  fromResult : 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`
  loop : (state -> Task e (Step state a)) -> state -> Task e a
      `loop step initial` — run `step` on `initial`, then on each new state it
  map : (a -> b) -> Task e a -> Task e b
  map2 : (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 d
  map4 : (a -> b -> c -> d -> f) -> Task e a -> Task e b -> Task e c -> Task e d -> Task e f
  map5 : (a -> b -> c -> d -> f -> g) -> Task e a -> Task e b -> Task e c -> Task e d -> Task e f -> Task e g
  mapError : (e -> e2) -> Task e a -> Task e2 a
  onError : (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
  parallelN : Int -> List (Task e a) -> Task e (List a)
      Like `parallel`, but runs at most `limit` tasks concurrently (a
  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.
  spawn : Task e a -> Task e ()
      Run a task on a background goroutine and return AT ONCE — fire-and-forget.
  succeed : a -> Task e a
  withBaseMs : 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