[Haskell-cafe] replicateM should be called mreplicate?

Sjoerd Visscher sjoerd at w3future.com
Mon Apr 6 10:02:41 EDT 2009

Considering these naming conventions:

• A postfix 'M' always stands for a function in the Kleisli category:  
The monad type constructor m is added to function results (modulo  
currying) and nowhere else. So, for example,

   filter  ::              (a ->   Bool) -> [a] ->   [a]
   filterM :: (Monad m) => (a -> m Bool) -> [a] -> m [a]

• A postfix '_' changes the result type from (m a) to (m ()). Thus,  
for example:

   sequence  :: Monad m => [m a] -> m [a]
   sequence_ :: Monad m => [m a] -> m ()

• A prefix 'm' generalizes an existing function to a monadic form.  
Thus, for example:

   sum  :: Num a       => [a]   -> a
   msum :: MonadPlus m => [m a] -> m a

replicateM has the following type:

   replicateM :: Monad m => Int -> m a -> m [a]

Am I missing something or should this have been called mreplicate?

Sjoerd Visscher
sjoerd at w3future.com

More information about the Haskell-Cafe mailing list