4 ms·
The positive news is that while it might take a while to learn the conventions, usually the conventions are enforced all around. In your case, the conventions a
by ufo 13y ago
The positive news is that while it might take a while to learn the conventions, usually the conventions are enforced all around. In your case, the conventions are documented in the docs for Control.Monad, the library those functions are from:
The functions in this library use the following 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
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html http://www.haskell.org/ghc/docs/latest/html/libraries/base/C...
Personally, the things that I found hard were idioms (like learning that $ is just avoiding parenthesis, "go" is for loops, etc) and how theres a lot of libraries that make the code shorter at the expense of forcing you to be aware of them (for example, applicatives <$> <*> look alien until you learn what they are and monad transformers add a lot of "magic" to the code as well as force you to use annoying lifts all over the place)