
On 2005-04-19 at 10:26+0400 Dmitry Vyal wrote:
I started to refactor my code as you suggested. I inserted update function in the middle of parameter list of ins_in_tree function. Just because this order seemed to be logical to me. ins_in_tree :: (Ord a) => BinTree a -> (a->a) -> a -> BinTree a
But soon I found that i need partial parametrization in order to rewrite old ins_list: ins_list lst = foldl ins_in_tree Leaf (map wrap lst)
So i had to change parameter order in ins_in_tree: ins_in_tree :: (Ord a) => (a->a) -> BinTree a -> a -> BinTree a [...] That worked, but what if i would need another order somethere further?
Just use Prelude.flip:: forall c a b. (a -> b -> c) -> b -> a -> c Which leads me to my own question: in current implementations, if I have a data structure containing a function (D f, say), and from it I generate anoter (D (flip f)), and then later (D (flip (flip f))) and so on, do the flips get reduced (to nothing if there's an even number of them) when the field of D is evaluated? -- Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk