[commit: ghc] master: Add a comment to the mapFB rules (665cefe)

Joachim Breitner mail at joachim-breitner.de
Thu Mar 9 15:56:13 UTC 2017


Hi,

Am Donnerstag, den 09.03.2017, 15:21 +0000 schrieb Simon Peyton Jones
via ghc-devs:
> >  +-- The "mapFB" rule optimises compositions of map and
> >  +-- the "mapFB/id" rule get rids of 'map id' calls.
> >  +-- (Any similarity to the Functor laws for [] is expected.)
> 
> Yes, obviously.  But did you have a use-case, or did you just to this
> on principle?  If you don't have this rule what goes wrong.  You must
> have had a proximate reason for adding it.

Just on principle. I saw "map id" in some code dump and thought that
this should not be there.

> Oh. And I've just realised that 
>    mapFB c id
> will turn into
>    \x y. c x y
> as soon as you inline mapFB. So why do you need a RULE to do
> that?  Why not leave it for the inliner?

Because we have to keep mapFB around to rewrite it back with this rule
 "mapList"   [1]  forall f.      foldr (mapFB (:) f) []  = map f

This is explained in Note [Inline FB functions] in GHC.List, which is
referenced from the
{-# INLINE [0] mapFB #-}
pragma.

Greetings,
Joachim

-- 
Joachim “nomeata” Breitner
  mail at joachim-breitner.dehttps://www.joachim-breitner.de/
  XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
  Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20170309/1479b27f/attachment.sig>


More information about the ghc-devs mailing list