[Haskell-cafe] Painting logs to get a coloured tree

minh thu noteed at gmail.com
Tue Feb 10 04:05:59 EST 2009

2009/2/10 minh thu <noteed at gmail.com>:
> 2009/2/10 Joachim Breitner <mail at joachim-breitner.de>:
>> Hi,
>> Am Montag, den 09.02.2009, 16:41 -0700 schrieb Luke Palmer:
>>> 2009/2/9 Joachim Breitner <mail at joachim-breitner.de>
>>>         Now while this works, and while ST is still somewhat pure, I'm
>>>         wondering
>>>         if there is no better way of expressing "This piece of
>>>         information came
>>>         from the point in a data structure, so something else can be
>>>         put here
>>>         easily".
>>> You might want to look into zippers:
>>> http://haskell.org/haskellwiki/Zipper
>> I thought about Zippers, but I understand that they improve _navigating_
>> in a Tree-like structure, or to refrence _one_ position in a tree.
>> But if I would deconstruct my tree to the list of _all_ locations, with
>>> type Loc a = (Tree a, Cxt a)
>> and then run my algorithm that returns [(Loc a, Info)], it's still not
>> clear to me how I can combine all of these locations to get back my
>> original Tree, annotated with the Info returned.
> I guess I just repeat your last praragraph of your original mail but it seems
> to me you can mapAccump some 'names' on the tree, process an
> association list (or an IntMap) of the (name,log) then map the three
> again using the result.
> In spirits, it's the same thing than the STRef solution but it seems
> cleaner to me.

I forgot to mention you can try to tie the knot too, using the result
of the processing in the first mapping (and then you don't need the
second one)...

More information about the Haskell-Cafe mailing list