The Total Recall combinator

1/04/2009
infixr 9 .:

(.:) :: (b -> c) -> (a -> a1 -> b) -> a -> a1 -> c
(.:) = (.)(.)(.)

This can be used to compose a string of functions with a binary function stuck on the end. For example:

lookupPlusOne :: (Ord k, Monad m, Num n) => k -> Map k n -> m n
lookupPlusOne = liftM (+1) .: lookup

(picked up from some folks on #haskell)

There are 2 comments in this article:

  1. 1/04/2009Nathan says:

    I love the title of this post. :-)

  2. 3/04/2009jberryman says:

    Nathan, thanks :) Wish I could remember who came up with that moniker.

Write a comment: