# How to implement promotion for functions like \`collect\` and \`map\`?

**URL:** <https://discourse.julialang.org/t/how-to-implement-promotion-for-functions-like-collect-and-map/134912>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 6, 2026, 3:35pm UTC](https://discourse.julialang.org/t/how-to-implement-promotion-for-functions-like-collect-and-map/134912 "2026-01-06T15:35:08Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [January 7, 2026, 6:27pm UTC](https://discourse.julialang.org/t/how-to-implement-promotion-for-functions-like-collect-and-map/134912/8 "2026-01-07T18:27:49Z")

</div>

> [@Deduction42](#):
>
> Is there a way to call “map” with specifying the output type so that we can manually set a union instead of an abstract container?

`map(f, c)` is roughly equivalent to `collect(Iterators.map(f, c))`. `collect` also allows specifying the element type explicitly:

```julia
collect(T, Iterators.map(f, c))

```

There’s also my package, Collects.jl:

- [New package: Collects.jl - meant to improve upon and generalize the interface of collect](https://discourse.julialang.org/t/new-package-collects-jl-meant-to-improve-upon-and-generalize-the-interface-of-collect/129468)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-implement-promotion-for-functions-like-collect-and-map/134912)._
