Atitit Understanding Monad Attilax Summary

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.