Claus Reinke | 29 Jul 21:25

Re: compositional gMap in SYB1

> Hello!

Hello again!-)

> Claus wrote:
>> Perhaps we can combine our versions to get the best of both?
>
> I have done so. I have committed a new version of
> /comparison/SYB1_2/GMap.lhs

[for readers of libraries@: that is in the generics code repo at
http://darcs.haskell.org/generics/comparison/SYB1_2/GMap.lhs ,
look for gmap2/gmapt and comments; the topic is defining Functor
fmap generically (hence gmap) in terms of Data/Typeable]

Ah, of course! Silly me, if I had followed my own choice of
metaphor to the end, I would have known that X marks the
spot only on a map, not on the real thing (or else everyone
could find the treasure..). Your shallow, incrementally built
not-quite copy is just another representation of a map, and
since both map and X are hidden from users of the function,
everyone is happy.

That something out of nothing trick is also used in the PlateData
optimization and in my adaptation of it. The difference, apart
from choice of representation, is mainly in whether to extract
substructure placeholders/types on a type basis once per
traversal or on a value basis, incrementally.

Here is a re-run of the technique, for defining traverse in terms
(Continue reading)


Gmane