[Haskell-beginners] Doing IO in terms of Arrow

Haisheng Wu freizl at gmail.com
Mon Jun 27 09:53:34 CEST 2011

  I'm wondering if it is possible doing IO in terms of Arrow.
  I got a function search all files under directory recursively and I'd like
to refartoring using Arrow terms.

  I tried to define a function like below but failed.
  isDirExist = Kleisli doesDirectoryExist

  Do I need to define a instance for IO to be Arrow? Or is there any
existing solutions?
  I'm a newbie of Haskell and thanks your help.

  getFilesInDir :: FilePath -> IO [FilePath]
  getFilesInDir inp = do
      isDir <- doesDirectoryExist inp
      files <- if isDir then
                      names <- getDirectoryContents inp
                      forM [ inp </> x | x <- names, isNotSpecialDir x ]
                   else return [[inp]]
      return $ concat files
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110627/3fd02a31/attachment.htm>

More information about the Beginners mailing list