[Haskell-cafe] Name that function =)

Louis J Scoras louis.j.scoras at gmail.com
Tue Dec 12 12:53:33 EST 2006


On 12/12/06, Conal Elliott <conal at conal.net> wrote:

> Try foo = liftM2, and check out the recent haskell thread "Cannot understand
> liftM2".

That's actually what I reached for first.  The problem is that the
arguments aren't monads:

   *Main> :t (uncurry renameFile)
   (uncurry renameFile) :: (FilePath, FilePath) -> IO ()

   *Main> :t putDirs
   putDirs :: (String, String) -> IO ()

and liftM2 works on monadic arguments:

   liftM2 :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r

I need to somehow get the mapped elements to be applied to each of the
arguments before they can be combined.

Substituting liftM2 for (foo (>>)) yields:

   No instance for (Monad ((->) (String, String)))
     arising from use of `liftM2' at DCFiles.hs:30:9-14
   Probable fix: add an instance declaration for (Monad ((->)
(String, String)))

The foo function does the job, so I assume that I'm trying to solve a
different problem than liftM.  I wouldn't be surprised if I was wrong,
however.


-- 
Lou.


More information about the Haskell-Cafe mailing list