
Hello,
On 3/20/06, John Meacham
... it looks very interesting. I use the mtl extensively in pretty much everything I do and am interested in any developments with it. a couple things
whenM,forEach2_, and forEach3_ should have types whenM :: Monad m => m Bool -> m a -> m () forEach2_ :: Monad m => [a] -> [b] -> (a -> b -> m c) -> m () forEach3_ :: Monad m => [a] -> [b] -> [c] -> (a -> b -> c -> m d) -> m () This is quite reasonable for 'forEach23_', and perhaps by symmetry for 'whenM'. One thing about 'whenM' however is that to implement it I'll need to add an extra 'return ()' to the parameter computation. This is probably not a big deal, but given that most of the time the computation used in 'whenM' is already of type 'm ()', I wonder if leaving it to the programmer to add the 'return ()' is not a better idea. What do you think?
Also, I am curious why some of the names seem to have been changed from what the mtl provides, it would be nice if it were mostly a drop in replacement as there is substantial mtl code out there.
mainly I am thinking of ask -> getR local -> updateR
also, it looks like some of the very useful utility routines in the current mtl such as 'asks' arn't included. I didn't add 'asks' because to me it seems redundant. Instead of "asks field" I write "field # getR" (or 'field # ask' if we were to use the 'mtl' terminology). Are there other useful methods
Some of the other names I changed because I didn't like (e.g. I like get/set for state, rather then get/put in 'mtl'). These two (getR,localR) I am not too happy with (also the name of the ReadUpdM class). I picked them because they resemble the state ones, but perhaps the 'mtl' ones are better, although I am not sure about that. Note however that 'monadLib' is not a drop in replacement for 'mtl', as other things differ as well, for example 'monadLib' has a different monad class hierarchy. that I missed?
though, I would be very happy to shorten 'Identity' to 'Id'. having a standard identity newtype is surprising useful all over the place, even when not used as a monad. That's interesting to know. I have not used it for anything else, do you have examples of how you use it?
deriving Typeable for everything would be good too. I have never used 'Typeable', but perhaps I will take a look. I would like 'monadLib' to stay simple, but if people use 'Typeable' on monadic computations I could probably add some instances. Are there any examples of when it is useful to do things like that? Does Hugs support Typeable?
Also, it looks like some of your monads overlap with what is provided by the Applicative (Idiom) and friends classes to be included in the next version of ghc, perhaps you can make a version of monadLib that builds on those? I am aware of that, and once they are released I will probably make use of them, because I think that they have some nice ideas. In the mean time however 'monadLib' provides 'Monad.ForEach' and 'Monad.Combinators'.
Thanks for the comments! -Iavor