Question: Create a Haskell program that behaves like a counter that can increment or decrement a value.... Create a Haskell program that behaves like a counter
Create a Haskell program that behaves like a counter that can increment or decrement a value....

Create a Haskell program that behaves like a counter that can increment or decrement a value a. Create a monad with two functions: b. increment C. decrement d. Use a return function to return the result. e. Use a bind function to use the result as the input for another function. f. See below for an example of how to create a 'twoStep' function that takes two steps forward and one step backward. g. See the output below for an example of the output: IGLT-0079:7 - Haskell tim.bazett-jones$ ghci GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help Prelude> :load counter.hs l of 11 Compiling Main Ok, modules loaded: Main. *Main> let twostep x = x >>== increment >>== increment >>== decrement >>== rtn *Main> twoStep (Result 4) Result 5 *Main> counter.hs, interpreted Create a Haskell program that behaves like a counter that can increment or decrement a value a. Create a monad with two functions: b. increment C. decrement d. Use a return function to return the result. e. Use a bind function to use the result as the input for another function. f. See below for an example of how to create a 'twoStep' function that takes two steps forward and one step backward. g. See the output below for an example of the output: IGLT-0079:7 - Haskell tim.bazett-jones$ ghci GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help Prelude> :load counter.hs l of 11 Compiling Main Ok, modules loaded: Main. *Main> let twostep x = x >>== increment >>== increment >>== decrement >>== rtn *Main> twoStep (Result 4) Result 5 *Main> counter.hs, interpreted
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
