avh4 / elm-program-test / SimulatedEffect.Task

This module parallels elm/core's Task module. Pull requests are welcome to add any functions that are missing.

The functions here produce SimulatedTaskss instead of Taskss and SimulatedEffects instead of Cmds, which are meant to be used to help you implement the function to provide when using ProgramTest.withSimulatedEffects.

Tasks

perform : (a -> msg) -> ProgramTest.SimulatedTask Basics.Never a -> ProgramTest.SimulatedEffect msg

attempt : (Result x a -> msg) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedEffect msg

This is very similar to perform except it can handle failures!

Chains

andThen : (a -> ProgramTest.SimulatedTask x b) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedTask x b

Chain together a task and a callback.

succeed : a -> ProgramTest.SimulatedTask x a

A task that succeeds immediately when run.

fail : x -> ProgramTest.SimulatedTask x a

A task that fails immediately when run.

sequence : List (ProgramTest.SimulatedTask x a) -> ProgramTest.SimulatedTask x (List a)

Start with a list of tasks, and turn them into a single task that returns a list.

Maps

map : (a -> b) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedTask x b

Transform a task.

map2 : (a -> b -> result) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedTask x b -> ProgramTest.SimulatedTask x result

Put the results of two tasks together.

map3 : (a -> b -> c -> result) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedTask x b -> ProgramTest.SimulatedTask x c -> ProgramTest.SimulatedTask x result

Put the results of three tasks together.

map4 : (a -> b -> c -> d -> result) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedTask x b -> ProgramTest.SimulatedTask x c -> ProgramTest.SimulatedTask x d -> ProgramTest.SimulatedTask x result

Put the results of four tasks together.

map5 : (a -> b -> c -> d -> e -> result) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedTask x b -> ProgramTest.SimulatedTask x c -> ProgramTest.SimulatedTask x d -> ProgramTest.SimulatedTask x e -> ProgramTest.SimulatedTask x result

Put the results of five tasks together.

Errors

mapError : (x -> y) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedTask y a

Transform the error value.

onError : (x -> ProgramTest.SimulatedTask y a) -> ProgramTest.SimulatedTask x a -> ProgramTest.SimulatedTask y a

Recover from a failure in a task.