From 31038c2e82a122235a25287f2a5eefee507a9851 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Mon, 15 Jul 2024 13:13:36 +0200 Subject: [PATCH] Optimize arity wrapper for << and >> Prior to this, << (and similarly >>) would be compiled to var $elm$core$Basics$composeL = F3(function (g, f, x) { ... }) which doesn't match the call sites, which is always of the shape A2($elm$core$Basics$composeL, f, g) This change makes it so that composeL/composeR are now wrapped with A2, which improves the performance by about 30%. --- src/Basics.elm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Basics.elm b/src/Basics.elm index 477048bd..f0a01334 100644 --- a/src/Basics.elm +++ b/src/Basics.elm @@ -846,8 +846,9 @@ So our example expands out to something like this: \n -> not (isEven (sqrt n)) -} composeL : (b -> c) -> (a -> b) -> (a -> c) -composeL g f x = - g (f x) +composeL g f = + \x -> + g (f x) {-| Function composition, passing results along in the suggested direction. For @@ -857,8 +858,9 @@ example, the following code checks if the square root of a number is odd: -} composeR : (a -> b) -> (b -> c) -> (a -> c) -composeR f g x = - g (f x) +composeR f g = + \x -> + g (f x) {-| Saying `x |> f` is exactly the same as `f x`.