This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0
Functional combinators for Elm
version 1.0.1
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.1
Committed At 2018-02-21 18:23:40 UTC
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1
elm-community/elm-test 4.2.0 <= v < 5.0.0 4.2.0

Modules

README

Lambda

About

Lambda is an Elm library of combinators!

I think combinators are to functional programming what patterns are to object oriented programming.

Combinators are just functions that combine other functions.

For example, the map reduce pattern can be implemented as a combinator that takes the reducer function and the mapper function. Sum of squares can then easily be written as:

square x = x * x
sumOfSquares = mapReduce sum square
sumOfSquares [1, 2, 3] == 14

Another interesting combinator is the "blackbird":

blackbird f g x y = f (g x y)

We can use it to count the number of elements in a list of lists, for instance:

count ls = blackbird sum map length ls
count [[1,2], [3,4,5]] == 5

But we define blackbird as ... and use currying and eta-reductions to great effect:

aggregator = sum ... map
count xs = aggregator length xs
count = \xs -> aggregator length xs
count = aggregator length

Feel free to contribute :)

Testing

Testing is done with fuzzing, and I think they are much superior for combinators because they will check them thoroughly.