danielnarey/elm-toolkit/6.2.0

NOTE: this package is not compatible with Elm 0.19.1

Toolkit.Function.Operators

Some experimental operators for function application

Apply List

(|>.) : a -> List (a -> b) -> List b

Alias for Toolkit.Function.applyList

Given a list containing any number of functions and a value accepted by every function in the list, return a list containing all of the results. Note that to use this operator, all of the results must be of the same type.

"a"
  |>.
    [ flip (++) "b"
    , flip (++) "c"
    , flip (++) "d"
    ]


--> ["ab", "ac", "ad"]

Uncurrying

(@@|>) : ( a, b ) -> (a -> b -> c) -> c

Forward operator for uncurry with 2 parameters

(1,2)
@@|> (+)


--> 3

Flipping arguments

(#) : (a -> b -> c) -> b -> a -> c

An operator for flip. Think of the # symbol as appearing where the missing argument would go.

4
  |> (/) 2


--> 0.5


4
  |> flip (/) 2


--> 2


4
  |> (/) # 2


--> 2

Precedence

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

Forward function application with precedence set to 9. Allows you to avoid parentheses when you want the argument to appear before the function name in an inline expression.

1 ||> toString ++ 2 ||> toString


--> "12"