Background and motivation
A generalization of F# collection's concat function.
Here's a possible generic definition let inline concat x = bind (toSeq >> ofSeq) x.
But we have to define its expected behaviour with different types, and what are the constraints for the input types.
For instance, the above definition would require 'M<'F<'T>> when M should be a monad (support for >>=) and F a foldable (support for toSeq) but it also should be a Collection (support for ofSeq).
Tricky types are options, dictionaries. For instance a dictionary of options won't work with the above definition.
Alternative Concerns
What is the expectation forL
concat (dict [ (1, [1;2;3]); (3, [6;7;8]) ])
concat (Some [1; 3])
Are you willing help with a pull-request?
Maybe
Background and motivation
A generalization of F# collection's
concatfunction.Here's a possible generic definition
let inline concat x = bind (toSeq >> ofSeq) x.But we have to define its expected behaviour with different types, and what are the constraints for the input types.
For instance, the above definition would require
'M<'F<'T>>when M should be a monad (support for>>=) and F a foldable (support fortoSeq) but it also should be a Collection (support forofSeq).Tricky types are options, dictionaries. For instance a dictionary of options won't work with the above definition.
Alternative Concerns
What is the expectation forL
concat (dict [ (1, [1;2;3]); (3, [6;7;8]) ])concat (Some [1; 3])Are you willing help with a pull-request?
Maybe