I am trying to figure out how exactly does treesort from here work (I understand flatten, insert and foldr).
I suppose what's being done in treesort is applying insert for each element on the list thus generating a tree and then flattening it. The only problem I can't overcome here is where the list (that is the argument of the function) is hiding (because it is not written anywhere as an argument except for the function type declaration).
One more thing: since dot operator is function composition, why is it an error when I change: treesort = flatten . foldr insert Leaf
to treesort = flatten( foldr insert Leaf )
?