Implements flatmap (#44792)
flatmap is the composition of map and flatten. It is important for functional programming patterns.
Some tasks that can be easily attained with list-comprehensions, including the composition of filter and mapping, or flattening a list of computed lists, can only be attained with do-syntax style if a flatmap functor is available. (Or appending a `|> flatten`, etc.)
Filtering can be implemented by outputing empty lists or singleton lists for the values to be removed or kept.