Elm Exactly

Rule 169e-msg-task

Messages⊢c◃x⇒v\effrecv{\effc}{\effx}{v}
⊢leaf(task,tk)◃v⇒v\frac{\begin{array}{c}\end{array}}{\begin{array}{c}\effrecv{\effleaf(\effmtask,\tk)}{v}{v}\end{array}}
(169)
Read it in its chapter·Permanent address: /standard/rules/e-msg-task

Comments

The input vv is the value with which the process performing tk\tk succeeds. The task of a leaf made by Task.perform or Task.attempt cannot fail. For Task.perform it is the task given, mapped, whose error type is Never, of which there is no value. For Task.attempt it is the task given with Task.onError applied, which turns a failure into a success whose value is the message made from Err. Either way the task that Perform carries has the error type Never (Section C.2). So every such process that ends gives a message.

Referred to from

TeX source
\defnrule[r:e-msg-task]
  {}
  {\effrecv{\effleaf(\effmtask,\tk)}{v}{v}}

Tests (6)

  • elm / MinimalTaskPerformTest
    The message of a performed task reaches update.
  • elm-core / CmdMapComposeTest
    `Cmd.map` applies its functions to a command's message, the innermost first.
  • elm-core / TaskAttemptErrorTest
    `Task.attempt` delivers both outcomes to `update` in a `Platform.worker`: `Ok` with the value of a succeeding task and `Err` with the error of a failing one.
  • elm-core / TaskPerformValueTest
    `Task.perform` delivers the task's value to `update` in a `Platform.worker`, for messages that carry an `Int`, a negative `Int` or a `String`, and for a message built by a function that ignores the value.
  • elm-core / TaskSucceedAsArgTest
    `Task.succeed`, passed as a function value to a polymorphic `apply : (a -> b) -> a -> b` with `a` instantiated to `Int`, produces a task that `Task.perform` delivers to `update` with the value 7.
  • elm-core / TimerEffectTest
    A `Platform.worker` that chains `Process.sleep` timers through `Task.perform` receives each timer message in turn and stops after five.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:e-msg-task] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.