[Haskell-cafe] Proposal: (.:) operator in base.
Joachim Breitner
mail at joachim-breitner.de
Fri Aug 19 18:50:44 UTC 2016
Hi,
Am Freitag, den 19.08.2016, 11:16 -0700 schrieb Theodore Lief Gannon:
> Well... there's that rather worrisome introductory paragraph of the
> Data.Composition docs, though:
>
> "This module is for convenience and demonstrative purposes more than
> it is for providing actual value. I do not recommend that you rely on
> this module for performance-sensitive code. Because this module is
> not based on Prelude's (.), some chances at optimization might be
> missed by your compiler."
I wonder if that is really something to worry about. Prelude’s (.) is
not special in any way:
-- | Function composition.
{-# INLINE (.) #-}
-- Make sure it has TWO args only on the left, so that it inlines
-- when applied to two functions, even if there is no final argument
(.) :: (b -> c) -> (a -> b) -> a -> c
(.) f g = \x -> f (g x)
The INLINE pragma and the definition with the right arity could be used
in Data.Composition as well, and it would yield the same results.
Greetings,
Joachim
--
Joachim “nomeata” Breitner
mail at joachim-breitner.de • https://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: 801 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160819/6bc5e395/attachment.sig>
More information about the Haskell-Cafe
mailing list