So far the comments here only increase my confusion (which as I say, is not bad because it means that I am learning something!).
As a Haskell newbie, the first thing I learned about monads is that they have a type signature that creates a kind of mud you can't wash off. eg. f :: String -> MyMonad String By mentioning the monad, you get to use its special functions but as a hard price, you must return a value with a type signature that locks it within the monad (although you can remove the signature within other monads using "<-"). As some people have hinted, perhaps the problem is that most Haskell newbies are introduced to monads through the IO monad and other monads are different. When I plunged into Haskell earlier this year, I had no problem with understanding static typing, higher level functions and even separating pure functions from IO functions. The more I learn about monads, however, the less I understand them. I've seen plenty of comments suggesting that monads are easy to understand, but for me they are not. Cheers, Kevin On Jul 30, 12:29 pm, Tillmann Rendel <ren...@informatik.uni- marburg.de> wrote: > C K Kashyap wrote: > > I am of the > > understanding that once you into a monad, you cant get out of it? > > That's not correct. > > There are many monads, including Maybe, [], IO, ... All of these monads > provide operations (>>=), return and fail, and do notation implemented > in terms of these functions, as a common interface. Using just this > common interface, you cannot "get out of the monad". > > But most if not all monads also provide additional operations, specific > to the monad in question. Often, these operations can be used to "get > out of that monad". For example, with Maybe, you can use pattern matching: > > case do x <- return 5 > fail "some message" > return (x + 3) of > Just a -> a > Nothing -> 0 > > So we can get out of many monads, but we need to know which one it is to > use the appropriate operation. > > Kevin Jardine wrote: > > I'm still trying to understand how monads interact with types so I am > > interested in this as well. > > From my point of view, the most important fact about monads is: > > There is nothing special about monads! > > The type class Monad behaves like very other type class. A monadic type > constructor behaves like every other type constructor. The type class > methods (>>=), return and fail behave like every other type class > method. There is nothing special about monads. > > The only speciality of monads is do notation, but do notation is only a > syntactic convenience, and can be translated into calls of (>>=), return > and fail, which, as noted above, are not special in any way. > > So, back to your question, since there is nothing special about monads, > monads do not interact with types in any special way. > > Tillmann > _______________________________________________ > Haskell-Cafe mailing list > haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe