
+1 for Herberts proposal. On 06.12.12 6:41 AM, Herbert Valerio Riedel wrote:
- from{Left,Right} are useful when working in the 'Maybe' monad or applicative functor for converting 'Either'-typed values (this also applies to the dual case of working in the 'Either' monad/app-functor and having to deal with 'Maybe' values)
- IMHO, 'maybeRight' has better readability than inlining 'either (const Nothing) Just' - for me it's not so much about typing less, as more about having code that is easier to read out loud.
- I often use the 'when'-like combinator 'whenJust' in monadic code:
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m () whenJust (Just x) a = a x whenJust _ _ = return ()
+1. whenJust is defined also in Agda.Utils.Monad, should also added to Control.Monad.
- As the types in Data.Either and Data.Maybe are part of the Haskell standard library, and IMHO basic primitives such as maybe{Left,Right} should be located in those modules as well.
+1 -- Andreas Abel <>< Du bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.abel@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/