tam-carre/and-collect/1.0.0

NOTE: the latest version is 1.0.2

Rerouted (fork, verified). The original repository is gone. This copy comes from a fork that still has the tag. The Lamdera package server serves a copy recovered from https://github.com/mtamc/and-collect (a fork).

What we checked: Rebuilt with git archive from commit 08b6188aba00 of https://github.com/mtamc/and-collect (a fork) (zip prefix tam-carre-and-collect-08b6188/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 fa7a963fb3e8a9eb034c45aae80eb5ed421fc690.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/tam-carre/and-collect/zipball/1.0.0/

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)