jamesrweb/elm-combinators/2.0.0

Rerouted (retagged, needs approval). The tag now points at a different commit than when this version was published. The Lamdera package server serves a copy recovered from https://github.com/jamesrweb/elm-combinators.

What we checked: Tag 2.0.0 is still on github.com/jamesrweb/elm-combinators; its commit 3a6bfd4fff4e is from 2026-08-30 04:45 UTC, after the version was published (2026-08-30 03:44 UTC); elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one and nothing else confirms its contents.

We could not verify this copy against what was published, so the Lamdera compiler asks before using it (y/n). Without a terminal, as in CI, it stops with an error unless approved:

  • lamdera make --auto-approve-package-rerouting approves rerouted versions for that run,
  • LAMDERA_AUTO_APPROVE_PACKAGE_REROUTING=1 does the same for every run in that environment,
  • LAMDERA_CACHE=off skips the Lamdera package server altogether: packages come from package.elm-lang.org and GitHub only, as with elm, and a rerouted version then fails to download.

Details · package.elm-lang.org's zip: https://github.com/jamesrweb/elm-combinators/zipball/2.0.0/

Combinators

a : (a -> b) -> a -> b

The A combinator.

Implemented in terms of the I combinator.

Combinators.a String.fromInt 1 --> "1"


Combinators.a List.sum [ 1, 2, 3 ] --> 6
b : (b -> c) -> (a -> b) -> a -> c

The B combinator.

The equivilent of the composition operator ((<<)) in Elm.

isEven : Int -> Bool
isEven n = modBy 2 n == 0


double : number -> number
double = ((*) 2)


Combinators.b not isEven 2 --> False
Combinators.b not isEven 1 --> True
Combinators.b String.fromInt double 4 --> "8"
b1 : (b -> c) -> (a -> d -> b) -> a -> d -> c

The B1 combinator.

Combinators.b1 String.toFloat String.append "3" ".14" --> Just 3.14


Combinators.b1 (modBy 2) (\x y -> x * y) 2 3 --> 0
b2 : (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e

The B2 combinator.

createUser : String -> Int -> Bool -> { name : String , age : Int , online : Bool }
createUser name age online = {
    name = name ,
    age = age ,
    online = online
    }


incrementUserAge : { name : String , age : Int , online : Bool } -> { name : String , age : Int , online : Bool }
incrementUserAge user =
    { user | age = user.age + 1 }


Combinators.b2 List.sum (\x y z -> [x, y, z]) 1 2 3 --> 6
Combinators.b2 incrementUserAge createUser "John" 36 True --> { name = "John", age = 37, online = True }
b3 : (c -> d) -> (b -> c) -> (a -> b) -> a -> d

The B3 combinator.

Combinators.b3 (\n -> n + 15) (\n -> n - 10) (\n -> n * 2) 50 --> 105


Combinators.b3 (Combinators.c String.append "1") ((++) "2") String.fromInt 50 --> "2501"
bp : (a -> c -> d) -> a -> (b -> c) -> b -> d

The B Prime (B') combinator.

Combinators.bp (+) 1 Basics.identity 2 --> 3


Combinators.bp (++) [ 1, 2, 3 ] List.singleton 4 --> [1, 2, 3, 4]
c : (a -> b -> c) -> b -> a -> c

The C combinator.

Takes a binary function and two further arguments which are then applied inversely.

multiplyList : List Int -> Int -> List Int
multiplyList items multiple =
    List.map ((*) multiple) items


Combinators.c multiplyList 10 [1, 2, 3] --> [10, 20, 30]

Useful in pipelines where the piped value is required to be the first argument to a function.

[1, 2, 3]
    |> Combinators.c multiplyList 5
    |> List.sum
--> 30
cp : (c -> a -> d) -> (b -> c) -> a -> b -> d

The C Prime (C') combinator.

Combinators.cp (+) (\x -> x * 2) 3 4 --> 11


Combinators.cp List.append List.singleton [ 3, 2, 1 ] 4 --> [4, 3, 2, 1]
cs : (a -> c -> b -> d) -> a -> b -> c -> d

The C Star (C*) combinator.

Flips the third and fourth arguments when applied to the given ternary function.

Combinators.cs Basics.clamp 100 200 150 --> 150


Combinators.cs (\four six three -> four + six * three) 4 3 6 --> 22
css : (a -> b -> d -> c -> e) -> a -> b -> c -> d -> e

The C Star Star (C**) combinator.

Flips the fourth and fifth arguments when applied to the given quaternary function.

Combinators.css (\two four six three -> (two - four + six) * three) 2 4 3 6 --> 12
d : (a -> c -> d) -> a -> (b -> c) -> b -> d

The D combinator.

Calls a given function with a given argument.

Sometimes referred to as "the reverse pipe operator".

The equivilent of the "pipe left" operator (<|) in Elm.

Combinators.d (+) 5 Basics.identity 2 --> 7
d1 : (a -> b -> d -> e) -> a -> b -> (c -> d) -> c -> e

The D1 Combinator.

Combinators.d1 Basics.clamp 100 200 ((*) 2) 110 --> 200
d2 : (c -> d -> e) -> (a -> c) -> a -> (b -> d) -> b -> e

The D2 combinator.

Combinators.d2 (+) Basics.identity 2 ((*) 2) 11 --> 24
e : (a -> d -> e) -> a -> (b -> c -> d) -> b -> c -> e

The E combinator.

Combinators.e (+) 6 (*) 2 3 --> 12
eb : (e -> f -> g) -> (a -> b -> e) -> a -> b -> (c -> d -> f) -> c -> d -> g

The Ê Combinator.

Named 'eb' for alphabetic consistency with the e combinator.

I would have named this function 'ê' but Elm does not support that as a function name in the @docs block. Accordingly, this was the next best name I could think of based on other language / library implementations I have seen.

Combinators.eb (+) (-) 50 25 (*) 3 2 --> 31
f : a -> b -> (b -> a -> c) -> c

The F combinator.

Combinators.f 6 2 (-) --> -4


Combinators.f "Hi" 3 String.repeat --> "HiHiHi"
fs : (c -> b -> a -> d) -> a -> b -> c -> d

The F Star (F*) combinator.

Equivilant to S Prime here and known to Haskell programmers as liftA2 and liftM2 for the Applicative and Monadic instances of (->).

Combinators.fs Basics.clamp 120 200 100 --> 120
fss : (a -> d -> c -> b -> e) -> a -> b -> c -> d -> e

The F Star Star (F**) combinator.

Flips the third and fifth arguments when applied to the given quaternary function.

g : (b -> c -> d) -> (a -> c) -> a -> b -> d

The G combinator.

Combinators.g (+) ((*) 2) 6 1 --> 13
h : (a -> b -> a -> c) -> a -> b -> c

The H combinator.

Combinators.h (\x1 y x2 -> ( x1, x2, y )) 1 2 --> (1, 1, 2)
i : a -> a

The I combinator.

Returns whatever it is given.

Combinators.i 1 --> 1


Combinators.i [ 1, 2, 3 ] --> [1, 2, 3]


Combinators.i String.fromInt --> String.fromInt
is : (a -> b) -> a -> b

The I Star (I*) combinator

Implemented in terms of the I combinator.

Combinators.is (\n -> n - 1) 10 --> 9
iss : (a -> b -> c) -> a -> b -> c

The I Star Star (I**) combinator.

Implemented in terms of the I combinator.

Combinators.iss (\n m -> n - m) 10 4 --> 6
j : (a -> b -> b) -> a -> b -> a -> b

The J combinator.

This is the J combinator of the literature.

Combinators.j (+) 10 20 40 --> 70
js : (a -> c) -> a -> b -> c

The J Star (J*) combinator.

This is the J combinator of Joy. It is not the jay combinator (J) of the literature.

Credit: Rayward-Smith and Burton (See Antoni Diller 'Compiling Functional Languages' page 104).

Combinators.js Basics.identity 10 20 --> 10
jp : (a -> b -> d) -> a -> b -> c -> d

The J Prime (J') combinator - prime of the J Star (Joy) combinator.

Credit: Rayward-Smith and Burton (See Antoni Diller 'Compiling Functional Languages' page 104).

Combinators.jp (+) 10 20 40 --> 30
k : a -> b -> a

The K combinator.

Corresponds to the encoding of true in lambda calculus.

Returns the first argument provided, ignoring the second.

Combinators.k "hello" 2 --> "hello"


Combinators.k Nothing [ 1, 2, 3 ] --> Nothing


Combinators.k String.fromInt (Just 2) --> String.fromInt
ki : a -> b -> b

The KI combinator.

Corresponds to the encoding of false in lambda calculus.

Returns the second argument provided, ignoring the first.

Combinators.ki "hello" 2 --> 2


Combinators.ki Nothing [ 1, 2, 3 ] --> [ 1, 2, 3 ]


Combinators.ki String.fromInt (Just 2) --> Just 2
o : ((a -> b) -> a) -> (a -> b) -> b

The O combinator.

Combinators.o (\f -> f 2 6) (+) 5 --> 13
p : (b -> b -> c) -> (a -> b) -> a -> a -> c

The P combinator.

Transforms two inputs and combines the outputs.

Equivelent of the on operator in Haskell.

add : number -> number -> number
add = (+)


double : number -> number
double = ((*) 2)


Combinators.p add double 3 12 --> 30
px : (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d

The Pheonix (Big Phi) combinator, also known as Turner's S Prime (S') combinator.

Equivilant to S Prime here and known to Haskell programmers as liftA2 and liftM2 for the Applicative and Monadic instances of (->).

Combinators.px (+) ((*) 2) ((-) 3) 5 --> 8
q : (a -> b) -> (b -> c) -> a -> c

The Q combinator.

Reverse function composition.

Combinators.q ((+) 2) ((*) 4) 10 --> 48


Combinators.q String.toUpper (\name -> "My name is " ++ name) "John" --> "My name is JOHN"
q1 : (b -> c) -> a -> (a -> b) -> c

The Q1 combinator.

Combinators.q1 ((+) 2) 10 ((*) 4) --> 42


Combinators.q1 String.toUpper "John" (\name -> "My name is " ++ name) --> "MY NAME IS JOHN"
q2 : a -> (b -> c) -> (a -> b) -> c

The Q2 combinator.

Combinators.q2 10 ((+) 2) ((*) 4) --> 42


Combinators.q2 "John" String.toUpper (\name -> "My name is " ++ name) --> "MY NAME IS JOHN"
q3 : (a -> b) -> a -> (b -> c) -> c

The Q3 combinator.

Combinators.q3 ((+) 2) 10 ((*) 4) --> 48


Combinators.q3 String.toUpper "John" (\name -> "My name is " ++ name) --> "My name is JOHN"
q4 : a -> (a -> b) -> (b -> c) -> c

The Q4 combinator.

Combinators.q4 10 ((+) 2) ((*) 4) --> 48


Combinators.q4 "John" String.toUpper (\name -> "My name is " ++ name) --> "My name is JOHN"
r : a -> (b -> a -> c) -> b -> c

The R combinator.

Combinators.r 10 (-) 12 --> 2


Combinators.r "second" (\a b -> a ++ " " ++ b) "first" --> "first second"
rs : (b -> c -> a -> d) -> a -> b -> c -> d

The R Star (R*) combinator.

Reverses the second, third and fourth arguments when applied to the given ternary function.

Combinators.rs Basics.clamp 10 100 200 --> 100


Combinators.rs Basics.clamp 110 100 200 --> 110


Combinators.rs Basics.clamp 220 100 200 --> 200
rss : (a -> c -> d -> b -> e) -> a -> b -> c -> d -> e

The R Star Star (R**) combinator.

Flips the third and fifth arguments when applied to the given quaternary function.

Combinators.rss (\six nine ten four -> six - nine + ten * four) 6 4 9 10 --> 37
s : (a -> b -> c) -> (a -> b) -> a -> c

The S combinator.

Combinators.s (+) ((*) 2) 10 --> 30


Combinators.s (-) (\v -> v * 7) 4 --> -24


Combinators.s (\user newAge -> { user | age = newAge }) (\user -> user.age + 1) { age = 35 } --> { age = 36 }
sp : (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d

The S Prime (S') combinator.

Combinators.sp (+) ((*) 2) ((-) 3) 5 --> 8
t : a -> (a -> b) -> b

The T combinator.

Sometimes referred to as "the forward pipe operator".

The equivilent of the "pipe right" operator (|>) in Elm.

Combinators.t 1 Basics.identity --> 1


Combinators.t 20 ((+) 2) --> 22


Combinators.t "Hello" (\v -> v ++ " world!") --> "Hello world!"
v : a -> b -> (a -> b -> c) -> c

The V combinator.

Combinators.v 1 2 (+) --> 3


Combinators.v 3 "Hello" String.repeat --> "HelloHelloHello"
vs : (b -> a -> b -> d) -> a -> b -> b -> d

The V Star (V*) combinator.

Combinators.vs (\two one three -> one + two - three) 1 2 3 --> 0
vss : (a -> c -> b -> c -> e) -> a -> b -> c -> c -> e

The V Star Star (V**) combinator.

Combinators.vss (\one four two three -> (one + two) - (three + four)) 1 2 3 4 --> -4
w : (a -> a -> b) -> a -> b

The W combinator.

Provides a given argument as both values to a given binary function.

Combinators.w (+) 2 --> 4
w1 : a -> (a -> a -> b) -> b

The W1 combinator.

The W combinator but with the arguments reversed.

Converse warbler.

Combinators.w1 2 (+) --> 4
ws : (a -> b -> b -> c) -> a -> b -> c

The W Star (W*) combinator.

Warbler once removed.

Combinators.ws (\x y z -> [ x, y, z ]) 1 2 --> [1, 2, 2]
wss : (a -> b -> c -> c -> d) -> a -> b -> c -> d

The W Star Star (W**) combinator.

Warbler twice removed.

Combinators.wss (\w x y z -> [ w, x, y, z ]) 1 2 3 --> [1, 2, 3, 3]