Problem understanding treesort in Haskell

Posted by Jerry on Stack Overflow See other posts from Stack Overflow or by Jerry
Published on 2010-05-20T01:47:57Z Indexed on 2010/05/20 2:00 UTC
Read the original article Hit count: 278

Filed under:
|
|

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 )?

© Stack Overflow or respective owner

Related posts about haskell

Related posts about sorting