In another thread, I wrote:
main = (>> return ()) $ runListT $ do arg <- ListT getArgs n <- ListT $ return [1..3] liftIO $ putStrLn ((show n) ++ ") " ++ arg)
The frequent occurence of "ListT $ return" in my code when I use the ListT monad transformer has made me wonder why there isn't a standard typeclass `MonadList', like those for the other monad transformers, encapsulating the essence of being a "list-like" monad -- in this case, the ability to select from a list of things. I quickly wrote one for myself: class MonadList m where option :: [a] -> m a instance MonadList [] where option = id instance (Monad m) => MonadList (ListT m) where option = ListT . return Has anyone else thought about or done something like this? Mike _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe