CS 119 Lab 11Monads

Objectives

  • Use a monadic type
  • Perform the following tasks in the order given.

    1. Download the Lab11 project and import it into Eclipse as a Haskell project.
       
    2. Test out the examples and make sure you understand how they work
       

    3.  
      Assignment:
      Write a function rollNDice :: Int -> Random [Int] that rolls dice n times and returns a list of n results.  Do this with >>= and return.

       

    4. We can test out your function with

      sumNDice :: Int -> Seed -> Int
      sumNDice n seed = foldl1 (+) (fst (apply (rollNDice n) seed))

      This function takes the first item from the pair in the result, which is the list of rolls, and adds them up using the higher order function foldl1.
       

    5. Email your modified zipped project to me for grading.