15 Jan 01:52
Re: Re: walking a directory tree efficiently
Luke Palmer <lrpalmer <at> gmail.com>
2009-01-15 00:52:38 GMT
2009-01-15 00:52:38 GMT
On Wed, Jan 14, 2009 at 5:04 PM, Paolo Losi <paolo <at> hypersonic.it> wrote:
mapM' is generic and already implemented: fmap2) I have written some support functions: mapM' and filterM'
Are they well written and generic?
(Note that a Monad is also a Functor)
Except for when it isn't, which is really annoying because it ought to be. I just pretend it is, and then grit my teeth and kill a baby when I get bitten.
And mapM' is not fmap, but fmap.fmap (or liftM.map if you prefer).
filterM' is specific enough not to deserve any package
filterM' = fmap . map
Uh, I think you're looking at the wrong one.
filterM' :: (a -> m Bool) -> m [a] -> m [a]
I would write this as:
filterM' p = filterM p . return
And then probably just go inline it.
that I like more...I find it readable... It's ok IMO.Are they already available in some package?
Can you suggest better names?
3) I find
(,) node `liftM` walkTree' path
not very readable.
Is it possible to express it in a more (not too much) verbose way?
A bit ugly, perhaps. With the notation from Control.Applicative:
(,) node <$> walkTree' path
I would really like to be able to do a proper-looking tuple section though;
(node,) <$> walkTree' path
Luke
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RSS Feed