[Hs-Generics] Inlining and generic programming
José Pedro Magalhães
jpm at cs.uu.nl
Wed Mar 14 08:53:54 CET 2012
Simon,
Thanks a lot for looking into this. One question regarding maps that I
still don't understand: can you explain me if it is indeed to be expected
that GHC won't fuse `map f . map g` into `map (f . g)` by default? Also,
same for `map f [x]` ~> `[f x]`?
Regarding your reply:
2012/3/9 Simon Peyton-Jones <simonpj at microsoft.com>
> You wondered why it made a difference whether you said
>
> instance GEnum Nat where
> genum = map to genum'
> or
> instance GEnum Nat -- Fill in from default method
>
> Well, it turns out that the difference is largely accidental.
I understand your explanation for why this can result in different
behaviour. But I think we should try to find a way to address this. We came
up with DefaultSignatures to simplify instantiating generic functions, but
now it turns out that using them can make the code slower! This is rather
unexpected. Could we perhaps have a way to let users specify rewrite rules
involving `cast`?
Cheers,
Pedro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/generics/attachments/20120314/c08667a3/attachment.htm>
More information about the Generics
mailing list