atitit Understanding Monad Attilax Summary
but one of the biggest problems with functional programming is that the function is a mathematical abstraction that does not exist in the real world, 1
Well, if that's enough, why Monad? The role of Monad is manifested here, it is a reinforcing glue function 1
but one of the biggest problems with functional programming is that the function is a mathematical abstraction that does not exist in the real world,
It has to be simulated. The computer that has been widely used so far is based on the Turing machine model, and the registers, caches and memory of the computer are used to record the state. To really understand programming, you must know how the state-of-the-way function is implemented on a state-full computer, so it is not possible to bypass non-functional programming. In addition, most of the functional programming languages are not purely functional, and are mixed with some features of other languages for practical consideration, and are not completely repulsive. The Haskell is known as pure functional language, with Monad to abstract state, theoretically can be justified, but in actual use actually still brought a lot of inconvenience (and then invented the Monad Transformer ... )。
C + + and Java's newest standards. Interestingly, OOP was first implemented in Lisp, and Lisp was seen by many as the beginning of functional programming. Similarly, a good programmer will use the appropriate programming style depending on the situation.
Well, if that's enough, why Monad? The role of Monad is reflected here, it is a reinforcing glue function
because it is inconvenient. The essence of functional programming is that we can use a lot of small functions, together, to form a large function, and finally write the whole program. If all the IO are to use the above model, we have to put all the necessary IO in the program together, input into a large data structure, output into a large data structure, and then to the model above, it is troublesome, this is not the essence.
The ideal scenario is this:
For example, we want to write a function
A-C
Then there are two small functions on hand:
A-B
B-C
So we use a glue function
(A-C), (c), (A-B)
Glue those two little functions together and make what we want.
A-C
This is a good fall.
The role of Monad is reflected here, and it is a reinforcing glue function. Io Monad is one of these glue, with it, we can not only the small function glue up, but also in the glue, the same time, the head into an input stream, their tail into an output stream, constitute the final IO function, do not Chi chi their own structure IO data structure.
So, Monad Glue In addition to the two small functions of the tail-to-toe together, but also to do something else, play a part of the role of packaging operations. Different glues work differently, so use different classes (IO, maybe, etc.) to separate the glue. And then
Illustrations Monad- Nanyi's blog . html
author :: Nickname : Old Wow's paw claw of Eagle idol wreck iconoclast image-smasher
  attilax akbar   Attilax   " baroque
Full Name: Attilax bin Mahmud bin Attila bin Solomon Akbar Al Rapanui
Attilax this Mahmoud this Attila Solomon Akbar al Rapa Nui
Common name : Etila ( Ayron) , email:[email protected]
reprint Please indicate source: attilax 's Column http://www.cnblogs.com/attilax/
--atiend
Atitit Understanding Monad Attilax Summary