Question

In: Computer Science

1. In your own words explain what a Monad is and why it is important in...

1. In your own words explain what a Monad is and why it is important in the composition of functions.

2. In terms of Reflex-FRP explain the following three terms

  1. behavior
  2. . event
  3. dynamic

3. Explain what a Monad Transformer does and why it is important

4. What is the difference between a partial function and a function that gives a valid result for any member of its type.

Solutions

Expert Solution

1) Monads is which allows us to defer some part of our program's evaluation while still writing functions that take one value and return one value. In the case of Maybe , we're deferring what to do about missing values or values that we cannot produce.

The reason why Monads are  important in the composition of functions is that they provide a uniform framework for describing a wide range of programming language features including, for example, state, I/O, continuations, exceptions, parsing and non-determinism, without leaving the frame- work of a purely functional language.

2) Reflex-FRP given three terms explanation:

a) A "Behavior" is a value that may change over time. This might be the current position of the mouse pointer, or   the current score in a game.

  b) An "Event"  is a thing that can happen. This might be something at a low level of abstraction, like a mouse being clicked. Or it might be something at a much higher level, such as moving a chess piece. But it happens at specific times, yielding specific values that describe what occurred.

c) A "Dynamic" is both a behavior and an event. It has a value over time, but the changes in that value are observable as an event that fires when updates are made.

3) Monad transformers are  used to compose features encapsulated by monads such as state, exception handling, and I/O in a modular way.  

Monad Transformer is important because it's IO allows world-changing side effects. Monad transformer modifies the behaviour of an underlying monad. Most of the monads in the "mtl library" have transformer equivalents. The transformer version of a monad has the same name, with a T stuck on the end. For example, the transformer equivalent of State is StateT, it adds mutable state to an underlying monad. The WriterT monad transformer makes it possible to write data when stacked on top of another monad.

4) The difference between a partial function and a function that gives a valid result for any member of its type:

Partial function: A function that is not defined for some inputs of the right type, that is, for some of a domain. For instance, division is a partial function since division by 0 is undefined. A partial function is a binary relation over two sets that associates to every element of the first set at most one element of the second set; it is thus a functional binary relation. It generalizes the concept of a function by not requiring every element of the first set to be associated to exactly one element of the second set.

Function that gives a valid result for any member of its type: A function which is defined for all inputs of the right type, that is, for all of a domain. Total functions are functions that give you a valid return value for every combination of valid arguments. They never throw errors and they don’t require checks of the return value. Total functions help you write more robust code and simpler code, free from defensive checks and errors.


Related Solutions

1. Explain in your own words what hypercycles are and why they are important during the origin of life.
  1. Explain in your own words what hypercycles are and why they are important during the origin of life. Explain Eigen's paradox and how hypercycles could help resolve Eigen's paradox. Give an example of conflict that can arise in a hypercycle and how this conflict could be resolved. Give an example of enhanced cooperation that could arise in a hypercycle and the conditions under which it could be selected. 2. The gap between eukaryotic and prokaryotic cells is one...
in your own words explain the colonies of New England. Why are they important in the...
in your own words explain the colonies of New England. Why are they important in the discussion of colonial America? What did they Contribute? only 10 sentence.
In your own words, explain why is it important to know the difference between hearing and...
In your own words, explain why is it important to know the difference between hearing and listening someone during a conversation? Explain your answers in 200 words.
a. Why is GPU important in a computer? Explain in your own words. b. If you...
a. Why is GPU important in a computer? Explain in your own words. b. If you are visiting the your college campus with the help of a head mounted display (HMD) that feels like you are at your campus physically where you are attending classes and roaming around with your friends.    i) What kind of technology can help getting you this kind of experience?    ii) Justify your answer with the technological aspects whether it used virtual or augmented reality?    iii)...
1-what is public administration using your own words? 2- why is it important to study it?
1-what is public administration using your own words? 2- why is it important to study it?
1- what is public management using your own words? 2- why is it important to study...
1- what is public management using your own words? 2- why is it important to study it? 3- how can the government hire the right person for a job?
1. Explain in your own words why regulation is important. I would like you to use...
1. Explain in your own words why regulation is important. I would like you to use 2 examples, one from human communities and one from the human body in your explanation. Make sure to include how regulation is enabled in each case (i.e. how is communication occurring?). 2. In order for an effector to respond to a command via either of the endocrine or nervous system, it must be able to respond to a chemical (hormone or neurotransmitter). Explain how...
In your own words, define public budgeting and explain why the federal budget is important to...
In your own words, define public budgeting and explain why the federal budget is important to you personally?
In your own words explain why appropriate kVp settings are important in digital radiography.
In your own words explain why appropriate kVp settings are important in digital radiography.
In your own words, explain integrated marketing communications and why it is important. Describe the four...
In your own words, explain integrated marketing communications and why it is important. Describe the four promotional methods an organization can use in its promotion mix.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT