Skip to content

Commit 31038c2

Browse files
committed
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%.
1 parent 65cea00 commit 31038c2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Basics.elm

+6-4
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,9 @@ So our example expands out to something like this:
846846
\n -> not (isEven (sqrt n))
847847
-}
848848
composeL : (b -> c) -> (a -> b) -> (a -> c)
849-
composeL g f x =
850-
g (f x)
849+
composeL g f =
850+
\x ->
851+
g (f x)
851852

852853

853854
{-| 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:
857858
858859
-}
859860
composeR : (a -> b) -> (b -> c) -> (a -> c)
860-
composeR f g x =
861-
g (f x)
861+
composeR f g =
862+
\x ->
863+
g (f x)
862864

863865

864866
{-| Saying `x |> f` is exactly the same as `f x`.

0 commit comments

Comments
 (0)