Stream: beginners

Topic: "Identity" Task?


view this post on Zulip Jared Cone (Oct 05 2024 at 06:22):

With backpassing gone, I feel like I have to rearrange the ! often when pipelining tasks (make sure it's only on the last task). Is there like an "identity" task or something I can throw on the end of a task chain just to always act as the final task to await on? So instead of:

            |> Task.fromResult
            |> Task.mapErr! (\_ -> "Failed to find enum $(enumName)")

something like:

            |> Task.fromResult
            |> Task.mapErr (\_ -> "Failed to find enum $(enumName)")
            |> Task.do!

view this post on Zulip Jared Cone (Oct 05 2024 at 06:27):

The issue I run in to is I'll write a single task, then realize I need to pipe it into another task like Task.mapError, but I forget to move the ! and it takes a while to figure out what the compiler is complaining about

view this post on Zulip Sven van Caem (Oct 05 2024 at 07:36):

I haven't tried it, but I believe just the identity function would work!


Last updated: Jul 06 2025 at 12:14 UTC