Lambda Lists bridge the gap between single and keyword/rest arguments
Many times I've pondered if Haskell could support variadic arguments or at least keywords, since sometimes they are more readable and I for one do prefer them:
(maybe 2 (+ 3) (Just 4))
-- vs.
(maybe
:default 2
:mapper (+ 3)
:maybe (Just 4))
Or
((+) [1, 2, 3, 4])
-- vs.
(+ 1 2 3 4)
The keyword syntax isn't always immediately better readable, however it's definitely less confusing in most cases. You don't necessarily have to remember what order which arguments are in when it comes to these functions where the order isn't universally obvious.
The "type" of the function
then is (&key (default b) (mapper (a -> b)) (maybe Maybe a)) -> b
or (&rest Int) -> Int
.
There's a question of how these would compose,
since as we see the :mapper
argument function doesn't take a lambda-list but a regular type.
In that case we could write foo :bar
to get a function which takes what the argument of :bar
would have been and returns the result.
Theoretically one could implement currying as well:
add x y = x + y
add :x :: Int -> (&key (y Int)) -> Int
add :x 2 :: (&key (y Int)) -> Int
Though I'm not 100% sure this wouldn't cause some typesystem problems.