Monday, March 19, 2018

[mjdtvttx] Flipping function composition

Here is how to refer to the function composition operator in Haskell when it has a qualified prefix: "Prelude..".  It certainly looks very weird.  Here it is in the context of creating an operator which puts its arguments in an order which some might consider more natural.

import Prelude hiding ((.));
import qualified Prelude;
(.) :: (a -> b) -> (b -> c) -> a -> c;
(.) = flip (Prelude..);

But consider just using the builtin operator Control.Category.>>> instead of redefining "." in this way.

No comments :