tam-carre/and-collect/1.0.1

NOTE: the latest version is 1.0.2

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/tam-carre/and-collect is gone (deleted or private); Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 1.0.1 found (1 same-name repos checked); no cached copy. Use another version.

Details

Task.AndCollect

andCollect : (a -> Task e b) -> Task e a -> Task e ( a, b )

Combinator for interdependent Task values. Note the type signature similarities with Task.andThen:

andThen : (a -> Task e b) -> Task e a -> Task e b


andCollect : (a -> Task e b) -> Task e a -> Task e ( a, b )

Intended usage is turning interdependent Task values such as this...

computeAnswer : Task error Int
computeAnswer =
    getA
        |> Task.andThen
            (\a ->
                getB a
                    |> Task.andThen
                        (\b ->
                            getC a b
                                |> Task.andThen
                                    (\c ->
                                        solve a b c
                                    )
                        )
            )

... into this:

import Task.AndCollect as Task


computeAnswer : Task error Int
computeAnswer =
    getA
        |> Task.andCollect getB
        |> Task.andCollect (\( a, b ) -> getC a b)
        |> Task.andThen (\( ( a, b ), c ) -> solve a b c)