[Haskell-cafe] Proposal: (.:) operator in base.

David Feuer david.feuer at gmail.com
Sat Aug 20 17:29:37 UTC 2016


On Fri, Aug 19, 2016 at 10:38 PM, David Menendez <dave at zednenem.com> wrote:

> Any RULEs involving Prelude’s (.) would need to be copied as well.

There aren't any, and if there are any then they're almost certainly
broken. The INLINE pragma on (.) isn't marked with a simplifier phase,
so it will be inlined almost immediately when optimization begins, as
long as it has at least two arguments. There is no time for rules
involving it to take effect. Rewrite rules end up working with the
inlined version. For example, Data.Sequence has a rule saying

forall f g xs . fmapSeq f (fmapSeq g xs) = fmapSeq (f . g) xs

So if you write

fmap f . fmap g

for sequences, this will specialize to

fmapSeq f . fmapSeq g

and inline to

\xs -> fmapSeq f (fmapSeq g xs)

at which point the rewrite rule will fire, changing it to

\xs -> fmapSeq (f . g) xs

This, in turn, will inline as well, to

\xs -> fmapSeq (\x -> f (g x)) xs


More information about the Haskell-Cafe mailing list