Questions

  1. Implement Monad[Try].
  2. Prove the right identity law for the State monad.
  3. Pick one of the monads we defined in this chapter and implement the go function, which will encode the notion of sinking the boat with a probability of 1%.
  4. Please do the same as question 3, but encode the notion of motor breaking in 1% of the moves, leaving the boat immobilized.
  5. Describe the essence of the monads we defined in this chapter by using the (loosely) following template—The state monad passes state between chained computations. The computation itself accepts the outcome of the previous calculation and returns the result, along with the new state.
  1. Define a go method that both tracks the position of the boat and takes the possibility of sinking the boat by using the structure with the following type:
type WriterOption[B] = Writer[Vector[(Double, Double)], Option[Boat]]
  1. Compare the answer to the 6th question and the way we combined Applicatives in the previous chapter.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.34.197