TLDR: Is there a Haskell library that offers function definitions (preferably with concise notation or naming) for handling common patterns of multi-argument function composition such as those in APL?
Full Question:
I'm new to Haskell and I have recently found myself asking the types of composition questions that other new Haskell users have asked such as how to compose a unary function with a binary function or how to compose two binary functions in a specific way. The point-free solutions to both of these are fairly unintuitive (either (.)(.)(.)
or LiftM2 (.)
) despite the goal of the function composition pattern being fairly clear (and probably quite common).
I have spent a little time with the APL language and really loved how simple and powerful the function composition model is. For example, here is a diagram of many composition patterns that can be accomplished in extremely terse notation that is actually fairly readable after one spends some time in the language.
Any of these APL patterns could be accomplished in Haskell by writing a simple lambda expression. For example, I have the following line in one of my Haskell files
(...) = (.)(.)(.)
which alternatively (and probably more clearly) could have been written
(...) = \f g x y = f (g x y)
or with a clearer name as
_1_atop_2 = \f g x y = f (g x y)
so that I can easily compose a unary function with a binary function in point-free style in the main portions of my code. For example, to define a distance function between real values, I just compose absolute value with subtraction:
dist = abs ... (-)
or
dist = _1_atop_2 abs (-)
(In this case, the more explicit style of dist x y = abs $ x - y
is arguably clearer, but in more elaborate cases the point free is nicer.)
My question is this: Is there any Haskell library that offers definitions of these composition patterns? I can obviously just create my own module with the trivial lambda definitions for these patterns, but I am wondering if there is some standard notation/naming convention for doing this.