fsharp / fsharp/fslang-suggestions

Async.map

Open
#859 8 comments 30 reactions 0 assignees View on GitHub
area: async-and-tasks
Dominant language
No language data
Stars
373
Forks
21
PR merge metrics
No merged PRs in 30d

Description

# Add Async.map in the Async Module
I propose we add a map function to the Async module.
The main reason is that it is so trivial to have and it would provide parity with other modules (List, Result, ...)

The existing way of approaching this problem in F# is writing the function yourself:

```fsharp
module Async =
let map f computation =
async.Bind(computation, f >> async.Return)
```

## Pros and Cons

The advantages of making this adjustment to F# are:
- Newcomers are expecting this method to be there in my opinion.
- It removes duplicate code in a lot of projects. (I have no numbers on this, call it a hunch).

The disadvantages of making this adjustment to F# are ...

- One small extra function to maintain.

## Extra information

Estimated cost (XS, S, M, L, XL, XXL): XS

Related suggestions:
- https://github.com/fsharp/fslang-suggestions/issues/318
Not sure why exactly this was rejected, I can't trace the replies back anymore.
**Yes, this was rejected in the past**, years later I wish to revisit this discussion. Purely for the `map` function that it.

## Affidavit (please submit!)

Please tick this by placing a cross in the box:
* [X] This is not a question (e.g. like one you might ask on [stackoverflow](http://stackoverflow.com)) and I have searched stackoverflow for discussions of this issue
* [X] I have [searched both open and closed suggestions on this site](http://github.com/fsharp/fslang-suggestions/issues) and believe this is not a duplicate
* [X] This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:
* [X] This is not a breaking change to the F# language design
* [X] I or my company would be willing to help implement and/or test this

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the Async.map proposal and its example in the issue, then read the related discussion in fslang-suggestions issue 318. Check how map is provided by the List and Result modules and how the Async module is organized. Done means the proposal has a decided API and an implementation and tests plan.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.