[Haskell-cafe] SYB supports genuine gmap. [Was: Polymorphic updating with TC/TFs?]
vogt.adam at gmail.com
Wed Dec 18 16:41:34 UTC 2013
Interesting. I wasn't aware of that one when I wrote the "fake"
version. I can see one small disadvantage for the "real" one: many
hand-written data instances (ex. Data.Map) have defined:
gunfold _ _ = error "gunfold"
So the "real" version will fail there. On the other hand, the gfoldl
defined in such instances is enough to support functions like
`everywhere (mkT (+ (1::Integer)))'.
For reference, the code moved from darcs.haskell.org to:
On Wed, Dec 18, 2013 at 4:06 AM, <oleg at okmij.org> wrote:
> adam vogt wrote
>> Changing type parameters isn't supported by the ones I know (syb), but
>> you can still fake it: <http://www.haskell.org/haskellwiki/SYB#fmap>.
> SYB supports the type-changing generic map, of the signature
>> gmap2 :: forall a b c . (Data a, Data b,
>> Data (c a), Data (c b), Data (c X)) =>
>> (a -> b) -> c a -> c b
> It was discovered back in 2008. Please see the following thread starting
> The fake described in haskellwiki/SYB#fmap with unsafeCoerce is not
> needed at all. There is a genuine gmap.
More information about the Haskell-Cafe