I wonder whether there is a good name for functions with the following signature and implementation (Haskell-notation):
humble :: (a -> a -> b) -> a -> b
humble f x = f x x
It seems somehow related to fold1
(fold
with no base case).
As has been mentioned by @4castle in the comments, the function you're looking for is join
in Control.Monad
. It's type is
join :: Monad m => m (m a) -> m a
The simple reader monad is (->) r
,so if we set m ~ (->) r
, we get
join :: (->) r ((->) r a) -> (->) r a
or, more concisely,
join :: (r -> r -> a) -> (r -> a)
which is what you want.